PastureAreaController.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package com.huimv.management.controller;
  2. import java.util.Arrays;
  3. import java.util.List;
  4. import java.util.Map;
  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.PastureAreaEntity;
  12. import com.huimv.management.service.PastureAreaService;
  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-06-24 09:55:37
  21. */
  22. @RestController
  23. @RequestMapping("management/pasturearea")
  24. public class PastureAreaController {
  25. @Autowired
  26. private PastureAreaService pastureAreaService;
  27. /**
  28. * 列表
  29. */
  30. @RequestMapping("/list")
  31. public R list(@RequestParam Map<String, Object> params){
  32. PageUtils page = pastureAreaService.queryPage(params);
  33. return R.ok().put("page", page);
  34. }
  35. /**
  36. * 信息
  37. */
  38. @RequestMapping("/info/{id}")
  39. public R info(@PathVariable("id") Integer id){
  40. PastureAreaEntity pastureArea = pastureAreaService.getById(id);
  41. return R.ok().put("pastureArea", pastureArea);
  42. }
  43. /**
  44. * 保存
  45. */
  46. @RequestMapping("/save")
  47. public R save(@RequestBody PastureAreaEntity pastureArea){
  48. pastureAreaService.save(pastureArea);
  49. return R.ok();
  50. }
  51. /**
  52. * 修改
  53. */
  54. @RequestMapping("/update")
  55. public R update(@RequestBody PastureAreaEntity pastureArea){
  56. pastureAreaService.updateById(pastureArea);
  57. return R.ok();
  58. }
  59. /**
  60. * 删除
  61. */
  62. @RequestMapping("/delete")
  63. public R delete(@RequestBody Integer[] ids){
  64. pastureAreaService.removeByIds(Arrays.asList(ids));
  65. return R.ok();
  66. }
  67. /**
  68. * 查询所有
  69. */
  70. @RequestMapping("/findAll")
  71. public R findAll(@RequestBody Integer formFarmId){
  72. if (formFarmId == null){
  73. return R.error("请先选择牧场");
  74. }
  75. List list = pastureAreaService.findAll(formFarmId);
  76. return R.ok().put("all",list);
  77. }
  78. }