YearPigBaseController.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package com.huimv.management.controller;
  2. import java.util.Arrays;
  3. import java.util.Map;
  4. import io.swagger.annotations.Api;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.PathVariable;
  7. import org.springframework.web.bind.annotation.RequestBody;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestParam;
  10. import org.springframework.web.bind.annotation.RestController;
  11. import com.huimv.management.entity.YearPigBaseEntity;
  12. import com.huimv.management.service.YearPigBaseService;
  13. import com.huimv.common.utils.PageUtils;
  14. import com.huimv.common.utils.R;
  15. /**
  16. * 年猪基本
  17. *
  18. * @author yinhao
  19. * @email yinhao@163.com
  20. * @date 2021-05-07 15:32:42
  21. */
  22. @Api(tags = "年猪基本")
  23. @RestController
  24. @RequestMapping("management/yearpigbase")
  25. public class YearPigBaseController {
  26. @Autowired
  27. private YearPigBaseService yearPigBaseService;
  28. /**
  29. * 列表
  30. */
  31. @RequestMapping("/list")
  32. public R list(@RequestParam Map<String, Object> params){
  33. PageUtils page = yearPigBaseService.queryPage(params);
  34. return R.ok().put("page", page);
  35. }
  36. /**
  37. * 信息
  38. */
  39. @RequestMapping("/info/{id}")
  40. public R info(@PathVariable("id") Integer id){
  41. YearPigBaseEntity yearPigBase = yearPigBaseService.getById(id);
  42. return R.ok().put("yearPigBase", yearPigBase);
  43. }
  44. /**
  45. * 保存
  46. */
  47. @RequestMapping("/save")
  48. public R save(@RequestBody YearPigBaseEntity yearPigBase){
  49. yearPigBaseService.save(yearPigBase);
  50. return R.ok();
  51. }
  52. /**
  53. * 修改
  54. */
  55. @RequestMapping("/update")
  56. public R update(@RequestBody YearPigBaseEntity yearPigBase){
  57. yearPigBaseService.updateById(yearPigBase);
  58. return R.ok();
  59. }
  60. /**
  61. * 删除
  62. */
  63. @RequestMapping("/delete")
  64. public R delete(@RequestBody Integer[] ids){
  65. yearPigBaseService.removeByIds(Arrays.asList(ids));
  66. return R.ok();
  67. }
  68. /*@RequestMapping("/batchLairage")
  69. public R batchLairage(@RequestBody Map<String, Object> map){
  70. String eartags = (String)map.get("eartags");
  71. Integer periodId = (Integer)map.get("periodId");
  72. String[] split = eartags.split(",");
  73. yearPigBaseService.batchLairage(split,periodId);
  74. return R.ok();
  75. } */
  76. @RequestMapping("/batchLairage")
  77. public R batchLairage(@RequestBody YearPigBaseEntity yearPigBase){
  78. for (String eartage : yearPigBase.getEartag().split(",")) {
  79. yearPigBase.setEartag(eartage);
  80. yearPigBaseService.save(yearPigBase);
  81. }
  82. return R.ok();
  83. }
  84. }