JunctionboxController.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.Inverter;
  5. import com.gyee.backconfig.model.auto.Junctionbox;
  6. import com.gyee.backconfig.service.auto.IJunctionboxService;
  7. import org.springframework.web.bind.annotation.*;
  8. import javax.annotation.Resource;
  9. import java.util.Arrays;
  10. /**
  11. * <p>
  12. * 前端控制器
  13. * </p>
  14. *
  15. * @author wang
  16. * @since 2022-10-17
  17. */
  18. @RestController
  19. @RequestMapping("//junctionbox")
  20. public class JunctionboxController {
  21. @Resource
  22. private IJunctionboxService junctionboxService;
  23. /**
  24. * 查询
  25. * @param id
  26. * @param code
  27. * @param windpowerstationid
  28. * @param inverterid
  29. * @param pageNum
  30. * @param pageSize
  31. * @return
  32. */
  33. @GetMapping(value = "/listByPage")
  34. public R findList(@RequestParam(value = "id", required = false) String id,
  35. @RequestParam(value = "code", required = false) String code,
  36. @RequestParam(value = "windpowerstationid", required = false) String windpowerstationid,
  37. @RequestParam(value = "inverterid", required = false) String inverterid,
  38. @RequestParam(value = "pageNum", required = true) String pageNum,
  39. @RequestParam(value = "pageSize", required = true) String pageSize) {
  40. IPage<Junctionbox> list = junctionboxService.list(id, code, windpowerstationid, inverterid, pageNum, pageSize);
  41. if (null != list) {
  42. return R.ok().data(list);
  43. } else {
  44. return R.error().data("查询失败!");
  45. }
  46. }
  47. /**
  48. * 插入
  49. *
  50. * @param junctionbox
  51. * @return
  52. */
  53. @PostMapping(value = "/save")
  54. public R addAll(@RequestBody Junctionbox junctionbox) {
  55. boolean b = junctionboxService.saveOrUpdate(junctionbox);
  56. if (b) {
  57. return R.ok().data(b);
  58. } else {
  59. return R.error().data("保存失败!");
  60. }
  61. }
  62. /**
  63. * 删除
  64. *
  65. * @param ids
  66. * @return
  67. */
  68. @DeleteMapping(value = "/remove-junctionbox/{ids}")
  69. public R deleteAll(@PathVariable("ids") String ids) {
  70. String[] strings = ids.split(",");
  71. boolean b = junctionboxService.removeByIds(Arrays.asList(strings));
  72. if (b) {
  73. return R.ok().data(b);
  74. } else {
  75. return R.error().data("删除失败!");
  76. }
  77. }
  78. }