123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- package com.gyee.backconfig.controller;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.gyee.backconfig.config.R;
- import com.gyee.backconfig.model.auto.Line;
- import com.gyee.backconfig.service.BackConfigService;
- import com.gyee.backconfig.service.auto.ILineService;
- import com.gyee.backconfig.vo.Linevo;
- import com.gyee.common.model.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import java.util.Arrays;
- /**
- * <p>
- * 前端控制器
- * </p>
- *
- * @author wang
- * @since 2022-09-23
- */
- @RestController
- @RequestMapping("//line")
- public class LineController {
- @Resource
- private BackConfigService backConfigService;
- @Resource
- private ILineService lineService;
- @GetMapping("/listByPage")
- @ResponseBody
- @CrossOrigin(origins = "*", maxAge = 3600)
- public R ListByPage(
- @RequestParam(value = "pagenum", required = true) Integer pageNum,
- @RequestParam(value = "pagesize", required = true) Integer pageSize,
- @RequestParam(value = "id", required = false) String id,
- @RequestParam(value = "code", required = false) String code,
- @RequestParam(value = "name", required = false) String name,
- @RequestParam(value = "aname", required = false) String aname,
- @RequestParam(value = "projectid", required = false) String projectid,
- @RequestParam(value = "capacity", required = false) Integer capacity,
- @RequestParam(value = "capacityunit", required = false) String capacityunit,
- @RequestParam(value = "quantity", required = false) Integer quantity,
- @RequestParam(value = "ordernum", required = false) Integer ordernum,
- @RequestParam(value = "version", required = false) Integer version) {
- Linevo vo = new Linevo();
- setVOTemplate(pageNum,pageSize,id,code,name,aname,projectid,capacity,capacityunit,quantity,ordernum,version,vo);
- Page<Line> LinePage = backConfigService.lineBypage(vo);
- if (StringUtils.isNotNull(LinePage)) {
- return R.ok().data(LinePage);
- } else {
- return R.error().message("访问失败");
- }
- }
- private void setVOTemplate(
- @RequestParam(value = "pagenum", required = true) Integer pageNum,
- @RequestParam(value = "pagesize", required = true) Integer pageSize,
- @RequestParam(value = "id", required = false) String id,
- @RequestParam(value = "code", required = false) String code,
- @RequestParam(value = "name", required = false) String name,
- @RequestParam(value = "aname", required = false) String aname,
- @RequestParam(value = "projectid", required = false) String projectid,
- @RequestParam(value = "capacity", required = false) Integer capacity,
- @RequestParam(value = "capacityunit", required = false) String capacityunit,
- @RequestParam(value = "quantity", required = false) Integer quantity,
- @RequestParam(value = "ordernum", required = false) Integer ordernum,
- @RequestParam(value = "version", required = false) Integer version,Linevo vo){
- vo.setAname(aname);
- vo.setCapacity(capacity);
- vo.setCode(code);
- vo.setPageSize(pageSize);
- vo.setCurrent(pageNum);
- vo.setId(id);
- vo.setName(name);
- vo.setProjectid(projectid);
- vo.setCapacity(capacity);
- vo.setCapacityunit(capacityunit);
- vo.setQuantity(quantity);
- vo.setOrdernum(ordernum);
- vo.setVersion(version);
- }
- //新增或者更新
- @PostMapping("/add-Line")
- @CrossOrigin(origins = "*", maxAge = 3600)
- public R addModifyProjectPlan(@RequestBody Line Line){
- boolean saveOrUpdate = backConfigService.saveOrUpdate(Line);
- if (saveOrUpdate) {
- return R.ok().data("保存或更新成功");
- }else{
- return R.error().message("保存失败");
- }
- }
- /**
- * 批量删除
- * @param ids
- * @return
- */
- // @DeleteMapping(value = "/{remove-ids}")
- // public R deleteAll(@PathVariable("ids") String ids){
- // boolean b = lineService.removeByIds(ids);
- // if (b){
- // return R.ok().data(b);
- // }else {
- // return R.error().data("删除失败!");
- // }
- // }
- @DeleteMapping(value = "/remove-lines/{ids}")
- public R deleteAll(@PathVariable("ids") String ids) {
- String[] strings = ids.split(",");
- boolean b = lineService.removeByIds(Arrays.asList(strings));
- if (b) {
- return R.ok().data(b);
- } else {
- return R.error().data("删除失败!");
- }
- }
- }
|