HookRegisterController.java 4.3 KB

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