WindturbineController.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.Windturbine;
  5. import com.gyee.backconfig.service.auto.IWindturbineService;
  6. import com.gyee.common.model.StringUtils;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.*;
  9. import java.util.List;
  10. /**
  11. * <p>
  12. * 前端控制器
  13. * </p>
  14. *
  15. * @author wang
  16. * @since 2022-09-29
  17. */
  18. @RestController
  19. @RequestMapping("//windturbine")
  20. public class WindturbineController {
  21. @Autowired
  22. private IWindturbineService windturbineService;
  23. /**
  24. * 查询
  25. *
  26. * @param id
  27. * @param code
  28. * @param windpowerstationid
  29. * @param projectid
  30. * @param lineid
  31. * @param pageNum
  32. * @param pageSize
  33. * @return
  34. */
  35. @GetMapping(value = "/companys")
  36. public R findList(@RequestParam(value = "id", required = false) String id,
  37. @RequestParam(value = "code", required = false) String code,
  38. @RequestParam(value = "windpowerstationid", required = false) String windpowerstationid,
  39. @RequestParam(value = "projectid", required = false) String projectid,
  40. @RequestParam(value = "lineid", required = false) String lineid,
  41. @RequestParam(value = "name", required = false) String name,
  42. @RequestParam(value = "pageNum", required = true) String pageNum,
  43. @RequestParam(value = "pageSize", required = true) String pageSize) {
  44. IPage<Windturbine> list = windturbineService.list(id, code, windpowerstationid, name, projectid, lineid, 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. public R findOne(@PathVariable("id") String id) {
  59. Windturbine windturbine = windturbineService.getOne(id);
  60. if (StringUtils.isNotNull(windturbine)) {
  61. return R.ok().data(windturbine);
  62. } else {
  63. return R.error().data("查询失败!");
  64. }
  65. }
  66. /**
  67. * 插入(批量)
  68. *
  69. * @param windturbine
  70. * @return
  71. */
  72. @PostMapping(value = "/add")
  73. public R addAll(@RequestBody Windturbine windturbine) {
  74. boolean b = windturbineService.addOrUpdate(windturbine);
  75. if (b) {
  76. return R.ok().data(b);
  77. } else {
  78. return R.error().data("保存失败!");
  79. }
  80. }
  81. /**
  82. * 批量删除
  83. *
  84. * @param ids
  85. * @return
  86. */
  87. @DeleteMapping(value = "/{ids}")
  88. public R deleteAll(@PathVariable("ids") String ids) {
  89. boolean b = windturbineService.removeByIds(ids);
  90. if (b) {
  91. return R.ok().data(b);
  92. } else {
  93. return R.error().data("删除失败!");
  94. }
  95. }
  96. /**
  97. * 批量修改
  98. *
  99. * @param list
  100. * @return
  101. */
  102. @PutMapping(value = "/editRegions")
  103. public R update(@RequestBody List<Windturbine> list) {
  104. boolean b = windturbineService.updateBatchById(list);
  105. if (b) {
  106. return R.ok().data(b);
  107. } else {
  108. return R.error().data("更新失败!");
  109. }
  110. }
  111. }