StandardpointController.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. package com.gyee.backconfig.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.gyee.backconfig.config.R;
  4. import com.gyee.backconfig.model.auto.Standardpoint;
  5. import com.gyee.backconfig.service.auto.IStandardpointService;
  6. import com.gyee.common.model.StringUtils;
  7. import org.springframework.web.bind.annotation.*;
  8. import javax.annotation.Resource;
  9. import java.util.List;
  10. /**
  11. * <p>
  12. * 前端控制器
  13. * </p>
  14. *
  15. * @author wang
  16. * @since 2022-10-24
  17. */
  18. @RestController
  19. @RequestMapping("//standardpoint")
  20. public class StandardpointController {
  21. @Resource
  22. private IStandardpointService standardpointService;
  23. /**
  24. * 查询
  25. * @param id
  26. * @param uniformcode
  27. * @param name
  28. * @param type
  29. * @param pageNum
  30. * @param pageSize
  31. * @return
  32. */
  33. @GetMapping(value = "/list")
  34. public R findList(@RequestParam(value = "id", required = false) String id,
  35. @RequestParam(value = "uniformcode", required = false) String uniformcode,
  36. @RequestParam(value = "name", required = false) String name,
  37. @RequestParam(value = "type", required = false) String type,
  38. @RequestParam(value = "pageNum", required = true) String pageNum,
  39. @RequestParam(value = "pageSize", required = true) String pageSize) {
  40. IPage<Standardpoint> list = standardpointService.list(id, uniformcode, name, type, pageNum, pageSize);
  41. if (null != list) {
  42. return R.ok().data(list);
  43. } else {
  44. return R.error().data("查询失败!");
  45. }
  46. }
  47. /**
  48. * 根据id查询
  49. *
  50. * @param id
  51. * @return
  52. */
  53. @GetMapping(value = "/{id}")
  54. public R findOne(@PathVariable("id") String id) {
  55. Standardpoint standardpoint = standardpointService.getOne(id);
  56. if (StringUtils.isNotNull(standardpoint)) {
  57. return R.ok().data(standardpoint);
  58. } else {
  59. return R.error().data("查询失败!");
  60. }
  61. }
  62. /**
  63. * 插入(批量)
  64. *
  65. * @param standardpoint
  66. * @return
  67. */
  68. @PostMapping(value = "/add")
  69. public R addAll(@RequestBody Standardpoint standardpoint) {
  70. boolean b = standardpointService.addOrUpdate(standardpoint);
  71. if (b) {
  72. return R.ok().data(b);
  73. } else {
  74. return R.error().data("保存失败!");
  75. }
  76. }
  77. /**
  78. * 批量删除
  79. *
  80. * @param ids
  81. * @return
  82. */
  83. @DeleteMapping(value = "/{ids}")
  84. public R deleteAll(@PathVariable("ids") String ids) {
  85. boolean b = standardpointService.removeByIds(ids);
  86. if (b) {
  87. return R.ok().data(b);
  88. } else {
  89. return R.error().data("删除失败!");
  90. }
  91. }
  92. /**
  93. * 批量修改
  94. *
  95. * @param list
  96. * @return
  97. */
  98. @PutMapping(value = "/editStandardpoint")
  99. public R update(@RequestBody List<Standardpoint> list) {
  100. boolean b = standardpointService.updateBatchById(list);
  101. if (b) {
  102. return R.ok().data(b);
  103. } else {
  104. return R.error().data("更新失败!");
  105. }
  106. }
  107. /**
  108. * 查询
  109. *
  110. * @param type
  111. * @return
  112. */
  113. @GetMapping(value = "/pointcode")
  114. public R findList(
  115. @RequestParam(value = "type", required = false) String type) {
  116. String code = standardpointService.getPointCode(type);
  117. if (null != code) {
  118. return R.ok().data(code);
  119. } else {
  120. return R.error().data("查询失败!");
  121. }
  122. }
  123. }