PigpenController.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package com.ruoyi.web.controller.app;
  2. import java.util.List;
  3. import javax.servlet.http.HttpServletResponse;
  4. import com.ruoyi.app.domain.PigCategory;
  5. import org.springframework.security.access.prepost.PreAuthorize;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.validation.annotation.Validated;
  8. import org.springframework.web.bind.annotation.GetMapping;
  9. import org.springframework.web.bind.annotation.PostMapping;
  10. import org.springframework.web.bind.annotation.PutMapping;
  11. import org.springframework.web.bind.annotation.DeleteMapping;
  12. import org.springframework.web.bind.annotation.PathVariable;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import com.ruoyi.common.annotation.Log;
  17. import com.ruoyi.common.core.controller.BaseController;
  18. import com.ruoyi.common.core.domain.AjaxResult;
  19. import com.ruoyi.common.enums.BusinessType;
  20. import com.ruoyi.app.domain.Pigpen;
  21. import com.ruoyi.app.service.IPigpenService;
  22. import com.ruoyi.common.utils.poi.ExcelUtil;
  23. import com.ruoyi.common.core.page.TableDataInfo;
  24. /**
  25. * 待宰圈Controller
  26. *
  27. * @author coede
  28. * @date 2025-03-19
  29. */
  30. @RestController
  31. @RequestMapping("/app/pigpen")
  32. public class PigpenController extends BaseController
  33. {
  34. @Autowired
  35. private IPigpenService pigpenService;
  36. /**
  37. * 查询待宰圈列表
  38. */
  39. @PreAuthorize("@ss.hasPermi('app:pigpen:list')")
  40. @GetMapping("/list")
  41. public TableDataInfo list(Pigpen pigpen)
  42. {
  43. startPage();
  44. List<Pigpen> list = pigpenService.selectPigpenList(pigpen);
  45. return getDataTable(list);
  46. }
  47. /**
  48. * 导出待宰圈列表
  49. */
  50. @PreAuthorize("@ss.hasPermi('app:pigpen:export')")
  51. @Log(title = "待宰圈", businessType = BusinessType.EXPORT)
  52. @PostMapping("/export")
  53. public void export(HttpServletResponse response, Pigpen pigpen)
  54. {
  55. List<Pigpen> list = pigpenService.selectPigpenList(pigpen);
  56. ExcelUtil<Pigpen> util = new ExcelUtil<Pigpen>(Pigpen.class);
  57. util.exportExcel(response, list, "待宰圈数据");
  58. }
  59. /**
  60. * 获取待宰圈详细信息
  61. */
  62. @PreAuthorize("@ss.hasPermi('app:pigpen:query')")
  63. @GetMapping(value = "/{id}")
  64. public AjaxResult getInfo(@PathVariable("id") Long id)
  65. {
  66. return success(pigpenService.selectPigpenById(id));
  67. }
  68. /**
  69. * 新增待宰圈
  70. */
  71. @PreAuthorize("@ss.hasPermi('app:pigpen:add')")
  72. @Log(title = "待宰圈", businessType = BusinessType.INSERT)
  73. @PostMapping
  74. public AjaxResult add(@Validated @RequestBody Pigpen pigpen)
  75. {
  76. if (!pigpenService.checkPigpenNameUnique(pigpen))
  77. {
  78. return error("新增待宰圈'" + pigpen.getPigpenName() + "'失败,列表中存在重复的待宰圈号");
  79. }
  80. pigpen.setCreateBy(getUsername());
  81. return toAjax(pigpenService.insertPigpen(pigpen));
  82. }
  83. /**
  84. * 修改待宰圈
  85. */
  86. @PreAuthorize("@ss.hasPermi('app:pigpen:edit')")
  87. @Log(title = "待宰圈", businessType = BusinessType.UPDATE)
  88. @PutMapping
  89. public AjaxResult edit(@Validated @RequestBody Pigpen pigpen)
  90. {
  91. if (!pigpenService.checkPigpenNameUnique(pigpen))
  92. {
  93. return error("修改待宰圈'" + pigpen.getPigpenName() + "'失败,列表中存在重复的待宰圈号");
  94. }
  95. pigpen.setUpdateBy(getUsername());
  96. return toAjax(pigpenService.updatePigpen(pigpen));
  97. }
  98. /**
  99. * 删除待宰圈
  100. */
  101. @PreAuthorize("@ss.hasPermi('app:pigpen:remove')")
  102. @Log(title = "待宰圈", businessType = BusinessType.DELETE)
  103. @DeleteMapping("/{ids}")
  104. public AjaxResult remove(@PathVariable Long[] ids)
  105. {
  106. return toAjax(pigpenService.deletePigpenByIds(ids));
  107. }
  108. /**
  109. * 获取待宰圈选择框列表
  110. */
  111. @GetMapping("/optionselect")
  112. public AjaxResult optionselect()
  113. {
  114. Pigpen pigpen = new Pigpen();
  115. List<Pigpen> list = pigpenService.selectPigpenList(pigpen);
  116. return success(list);
  117. }
  118. }