123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- package com.gyee.backconfig.controller;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.gyee.backconfig.config.R;
- import com.gyee.backconfig.model.auto.Project;
- import com.gyee.backconfig.service.BackConfigService;
- import com.gyee.backconfig.service.auto.IProjectService;
- import com.gyee.backconfig.vo.Projectvo;
- 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.Date;
- import java.util.List;
- /**
- * <p>
- * 前端控制器
- * </p>
- *
- * @author wang
- * @since 2022-09-22
- */
- @RestController
- @RequestMapping("//project")
- public class ProjectController {
- @Resource
- private BackConfigService backConfigService;
- @Autowired
- private IProjectService projectService;
- @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 = "windpowerstationid", required = false) String windpowerstationid,
- @RequestParam(value = "capacity", required = false) Integer capacity,
- @RequestParam(value = "capacityunit", required = false) String capacityunit,
- @RequestParam(value = "quantity", required = false) Integer quantity,
- @RequestParam(value = "model", required = false) String model,
- @RequestParam(value = "commissiondate", required = false) Date commissiondate,
- @RequestParam(value = "masterphone", required = false) String masterphone,
- @RequestParam(value = "shiftforeman", required = false) String shiftforeman,
- @RequestParam(value = "shiftforemanphone", required = false) String shiftforemanphone,
- @RequestParam(value = "ordernum", required = false) Integer ordernum,
- @RequestParam(value = "version", required = false) Integer version) {
- Projectvo vo = new Projectvo();
- setVOTemplate(pageNum, pageNum, id, code, name, aname, windpowerstationid, capacity, capacityunit, quantity, model, commissiondate, masterphone, shiftforeman, shiftforemanphone, ordernum, version, vo);
- Page<Project> ProjectPage = backConfigService.ProjectBypage(vo);
- if (StringUtils.isNotNull(ProjectPage)) {
- return R.ok().data(ProjectPage);
- } 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 = "windpowerstationid", required = false) String windpowerstationid,
- @RequestParam(value = "capacity", required = false) Integer capacity,
- @RequestParam(value = "capacityunit", required = false) String capacityunit,
- @RequestParam(value = "quantity", required = false) Integer quantity,
- @RequestParam(value = "model", required = false) String model,
- @RequestParam(value = "commissiondate", required = false) Date commissiondate,
- @RequestParam(value = "masterphone", required = false) String masterphone,
- @RequestParam(value = "shiftforeman", required = false) String shiftforeman,
- @RequestParam(value = "shiftforemanphone", required = false) String shiftforemanphone,
- @RequestParam(value = "ordernum", required = false) Integer ordernum,
- @RequestParam(value = "version", required = false) Integer version, Projectvo vo) {
- vo.setPageSize(pageSize);
- vo.setId(id);
- vo.setCurrent(pageNum);
- vo.setCode(code);
- vo.setName(name);
- vo.setAname(aname);
- vo.setWindpowerstationid(windpowerstationid);
- vo.setCapacity(capacity);
- vo.setCapacityunit(capacityunit);
- vo.setQuantity(quantity);
- vo.setMasterphone(masterphone);
- vo.setModel(model);
- vo.setCommissiondate(commissiondate);
- vo.setShiftforeman(shiftforeman);
- vo.setShiftforemanphone(shiftforemanphone);
- vo.setOrdernum(ordernum);
- vo.setVersion(version);
- }
- /**
- * 查询
- *
- * @param id
- * @param name
- * @param pageNum
- * @param pageSize
- * @return
- */
- @GetMapping(value = "/List")
- public R findList(@RequestParam(value = "id", required = false) String id,
- @RequestParam(value = "name", required = false) String name,
- @RequestParam(value = "code", required = false) String code,
- @RequestParam(value = "windpowerstationid", required = false) String windpowerstationid,
- @RequestParam(value = "pageNum", required = true) String pageNum,
- @RequestParam(value = "pageSize", required = true) String pageSize) {
- IPage<Project> list = projectService.getList(id, name, code, windpowerstationid, pageNum, pageSize);
- if (null != list) {
- return R.ok().data(list);
- } else {
- return R.error().data("查询失败!");
- }
- }
- /**
- * 根据id查询
- *
- * @param id
- * @return
- */
- @GetMapping(value = "/{id}")
- public R findOne(@PathVariable("id") String id) {
- Project project = projectService.getOne(id);
- if (StringUtils.isNotNull(project)) {
- return R.ok().data(project);
- } else {
- return R.error().data("查询失败!");
- }
- }
- /**
- * 插入(批量)
- *
- * @param project
- * @return
- */
- @PostMapping(value = "/add")
- public R addAll(@RequestBody Project project) {
- boolean b = projectService.addOrUpdate(project);
- if (b) {
- return R.ok().data(b);
- } else {
- return R.error().data("保存失败!");
- }
- }
- /**
- * 批量删除
- *
- * @param ids
- * @return
- */
- @DeleteMapping(value = "/{ids}")
- public R deleteAll(@PathVariable("ids") String ids) {
- boolean b = projectService.removeByIds(ids);
- if (b) {
- return R.ok().data(b);
- } else {
- return R.error().data("删除失败!");
- }
- }
- /**
- * 批量修改
- *
- * @param list
- * @return
- */
- @PutMapping(value = "/editRegions")
- public R update(@RequestBody List<Project> list) {
- boolean b = projectService.updateBatchById(list);
- if (b) {
- return R.ok().data(b);
- } else {
- return R.error().data("更新失败!");
- }
- }
- }
|