ProBasicSquareController.java 3.4 KB

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