StandardpointController.java 4.2 KB

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