LineController.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package com.gyee.backconfig.controller;
  2. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  3. import com.gyee.backconfig.config.R;
  4. import com.gyee.backconfig.model.auto.Line;
  5. import com.gyee.backconfig.service.BackConfigService;
  6. import com.gyee.backconfig.service.auto.ILineService;
  7. import com.gyee.backconfig.vo.Linevo;
  8. import com.gyee.common.model.StringUtils;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.*;
  11. import javax.annotation.Resource;
  12. import java.util.Arrays;
  13. /**
  14. * <p>
  15. * 前端控制器
  16. * </p>
  17. *
  18. * @author wang
  19. * @since 2022-09-23
  20. */
  21. @RestController
  22. @RequestMapping("//line")
  23. public class LineController {
  24. @Resource
  25. private BackConfigService backConfigService;
  26. @Resource
  27. private ILineService lineService;
  28. @GetMapping("/listByPage")
  29. @ResponseBody
  30. @CrossOrigin(origins = "*", maxAge = 3600)
  31. public R ListByPage(
  32. @RequestParam(value = "pagenum", required = true) Integer pageNum,
  33. @RequestParam(value = "pagesize", required = true) Integer pageSize,
  34. @RequestParam(value = "id", required = false) String id,
  35. @RequestParam(value = "code", required = false) String code,
  36. @RequestParam(value = "name", required = false) String name,
  37. @RequestParam(value = "aname", required = false) String aname,
  38. @RequestParam(value = "projectid", required = false) String projectid,
  39. @RequestParam(value = "capacity", required = false) Integer capacity,
  40. @RequestParam(value = "capacityunit", required = false) String capacityunit,
  41. @RequestParam(value = "quantity", required = false) Integer quantity,
  42. @RequestParam(value = "ordernum", required = false) Integer ordernum,
  43. @RequestParam(value = "version", required = false) Integer version) {
  44. Linevo vo = new Linevo();
  45. setVOTemplate(pageNum,pageSize,id,code,name,aname,projectid,capacity,capacityunit,quantity,ordernum,version,vo);
  46. Page<Line> LinePage = backConfigService.lineBypage(vo);
  47. if (StringUtils.isNotNull(LinePage)) {
  48. return R.ok().data(LinePage);
  49. } else {
  50. return R.error().message("访问失败");
  51. }
  52. }
  53. private void setVOTemplate(
  54. @RequestParam(value = "pagenum", required = true) Integer pageNum,
  55. @RequestParam(value = "pagesize", required = true) Integer pageSize,
  56. @RequestParam(value = "id", required = false) String id,
  57. @RequestParam(value = "code", required = false) String code,
  58. @RequestParam(value = "name", required = false) String name,
  59. @RequestParam(value = "aname", required = false) String aname,
  60. @RequestParam(value = "projectid", required = false) String projectid,
  61. @RequestParam(value = "capacity", required = false) Integer capacity,
  62. @RequestParam(value = "capacityunit", required = false) String capacityunit,
  63. @RequestParam(value = "quantity", required = false) Integer quantity,
  64. @RequestParam(value = "ordernum", required = false) Integer ordernum,
  65. @RequestParam(value = "version", required = false) Integer version,Linevo vo){
  66. vo.setAname(aname);
  67. vo.setCapacity(capacity);
  68. vo.setCode(code);
  69. vo.setPageSize(pageSize);
  70. vo.setCurrent(pageNum);
  71. vo.setId(id);
  72. vo.setName(name);
  73. vo.setProjectid(projectid);
  74. vo.setCapacity(capacity);
  75. vo.setCapacityunit(capacityunit);
  76. vo.setQuantity(quantity);
  77. vo.setOrdernum(ordernum);
  78. vo.setVersion(version);
  79. }
  80. //新增或者更新
  81. @PostMapping("/add-Line")
  82. @CrossOrigin(origins = "*", maxAge = 3600)
  83. public R addModifyProjectPlan(@RequestBody Line Line){
  84. boolean saveOrUpdate = backConfigService.saveOrUpdate(Line);
  85. if (saveOrUpdate) {
  86. return R.ok().data("保存或更新成功");
  87. }else{
  88. return R.error().message("保存失败");
  89. }
  90. }
  91. /**
  92. * 批量删除
  93. * @param ids
  94. * @return
  95. */
  96. // @DeleteMapping(value = "/{remove-ids}")
  97. // public R deleteAll(@PathVariable("ids") String ids){
  98. // boolean b = lineService.removeByIds(ids);
  99. // if (b){
  100. // return R.ok().data(b);
  101. // }else {
  102. // return R.error().data("删除失败!");
  103. // }
  104. // }
  105. @DeleteMapping(value = "/remove-lines/{ids}")
  106. public R deleteAll(@PathVariable("ids") String ids) {
  107. String[] strings = ids.split(",");
  108. boolean b = lineService.removeByIds(Arrays.asList(strings));
  109. if (b) {
  110. return R.ok().data(b);
  111. } else {
  112. return R.error().data("删除失败!");
  113. }
  114. }
  115. }