src/main/java/com/whyc/controller/CircleInfController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/mapper/SubInfMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/SubInf.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/SubInfService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/CircleInfController.java
@@ -32,10 +32,10 @@ private SubInfService subService; @PostMapping("add") @PostMapping("addCinf") @ApiOperation(value = "添加动环") @Transactional public Response add(@RequestBody CircleInf circleInf){ public Response addCinf(@RequestBody CircleInf circleInf){ int userId = ActionUtil.getUser().getUId().intValue(); Response res = new Response(); //校验机房站点是否存在,存在则不需要新建StationId @@ -91,16 +91,17 @@ return res; } @PostMapping("update") @PostMapping("updateCinf") @ApiOperation(value = "更新电源") public Response updateByDeviceId(@RequestBody CircleInf circleInf){ public Response updateCinf(@RequestBody CircleInf circleInf){ service.updateByDeviceId(circleInf); return new Response().set(1,true,"更新成功"); } @PostMapping("delete") @GetMapping("deleteCinf") @ApiOperation(value = "删除电源") public Response deleteByDeviceId(@RequestParam Integer deviceId){ public Response deleteCinf(@RequestParam Integer deviceId){ service.deleteByDeviceId(deviceId); return new Response().set(1,true,"删除成功"); } @@ -111,5 +112,30 @@ return service.getCinf(cinf,pageCurr,pageSize); } @PostMapping("getSub") @ApiOperation(value = "获取子件信息") public Response getSub(@RequestBody SubInf sub,@RequestParam int pageCurr,@RequestParam int pageSize){ return subService.getSub(sub,pageCurr,pageSize); } @PostMapping("updateSub") @ApiOperation(value = "更新子件") public Response updateSub(@RequestBody SubInf sub){ subService.updateSub(sub); return new Response().set(1,true,"更新成功"); } @GetMapping("deleteSub") @ApiOperation(value = "删除子件") public Response deleteSub(@RequestParam Integer subId){ subService.deleteSub(subId); return new Response().set(1,true,"删除成功"); } @PostMapping("addSub") @ApiOperation(value = "添加子件") public Response addSub(@RequestBody SubInf sub){ subService.addSub(sub); return new Response().set(1,true,"添加成功"); } } src/main/java/com/whyc/mapper/SubInfMapper.java
@@ -1,6 +1,9 @@ package com.whyc.mapper; import com.whyc.pojo.SubInf; import org.apache.ibatis.annotations.Param; import java.util.List; public interface SubInfMapper extends CustomMapper<SubInf>{ } src/main/java/com/whyc/pojo/SubInf.java
@@ -1,6 +1,7 @@ package com.whyc.pojo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; @@ -56,5 +57,11 @@ private String subPropertyName; @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") private Date startTime; @TableField(exist = false) @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") private Date endTime; } src/main/java/com/whyc/service/SubInfService.java
@@ -1,6 +1,12 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.whyc.dto.Response; import com.whyc.mapper.SubInfMapper; import com.whyc.pojo.CircleInf; import com.whyc.pojo.SubInf; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -17,4 +23,40 @@ subList.stream().forEach(sinf->sinf.setDeviceId(devId)); mapper.insertBatchSomeColumn(subList); } //获取子件信息 public Response getSub(SubInf sub, int pageCurr, int pageSize) { PageHelper.startPage(pageCurr,pageSize); QueryWrapper wrapper=new QueryWrapper(); if(sub.getSubType()!=null){ wrapper.eq("sub_type",sub.getSubType()); } if(sub.getSubPropertyName()!=null){ wrapper.eq("sub_property_name",sub.getSubPropertyName()); } if(sub.getStartTime()!=null){ wrapper.ge("sub_inuse_date",sub.getStartTime()); } if(sub.getEndTime()!=null){ wrapper.le("sub_inuse_date",sub.getEndTime()); } List<SubInf> list=mapper.selectList(wrapper); PageInfo pageInfo=new PageInfo(list); return new Response().setII(1,list!=null,pageInfo,"获取子件信息"); } //添加动环 public void addSub(SubInf sub) { mapper.insert(sub); } //更新电源 public void updateSub(SubInf sub) { UpdateWrapper<SubInf> wrapper = new UpdateWrapper<SubInf>().eq("sub_id",sub.getSubId()); mapper.update(sub,wrapper); } //删除电源 public void deleteSub(Integer subId) { QueryWrapper<SubInf> wrapper = new QueryWrapper<SubInf>().eq("sub_id",subId); mapper.delete(wrapper); } }