src/main/java/com/whyc/controller/DeviceManageController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/Response.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/mapper/DeviceManageMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/DeviceManage.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/DeviceManageService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/config/application.yml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/DeviceManageController.java
New file @@ -0,0 +1,40 @@ package com.whyc.controller; import com.whyc.dto.Response; import com.whyc.pojo.DeviceManage; import com.whyc.service.DeviceManageService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * 设备管理 */ @RestController @RequestMapping("deviceManage") @Api(tags = "设备管理") public class DeviceManageController { @Autowired private DeviceManageService service; @PostMapping @ApiOperation(value="添加-入库") public Response add(@RequestBody DeviceManage deviceManage){ return service.add(deviceManage); } @PutMapping @ApiOperation(value="报废-出库") public Response delete(@RequestParam Integer deviceId){ return service.delete(deviceId); } @PutMapping @ApiOperation(value = "编辑") public Response update(@RequestBody DeviceManage deviceManage){ return service.update(deviceManage); } } src/main/java/com/whyc/dto/Response.java
@@ -46,6 +46,12 @@ return this; } public Response<T> setMsg(Integer code,String msg) { this.code = code; this.msg = msg; return this; } public Integer getCode() { return code; } src/main/java/com/whyc/mapper/DeviceManageMapper.java
New file @@ -0,0 +1,6 @@ package com.whyc.mapper; import com.whyc.pojo.DeviceManage; public interface DeviceManageMapper extends CustomMapper<DeviceManage>{ } src/main/java/com/whyc/pojo/DeviceManage.java
@@ -1,5 +1,6 @@ package com.whyc.pojo; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import org.apache.ibatis.type.Alias; @@ -10,6 +11,7 @@ @TableName(schema = "db_experiment",value = "tb_device_manage") public class DeviceManage { @TableId private Integer num; private Integer deviceId; private Integer deviceName; src/main/java/com/whyc/service/DeviceManageService.java
New file @@ -0,0 +1,37 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.whyc.dto.Response; import com.whyc.mapper.DeviceManageMapper; import com.whyc.pojo.DeviceManage; import org.springframework.stereotype.Service; import javax.annotation.Resource; @Service public class DeviceManageService { @Resource private DeviceManageMapper mapper; public Response add(DeviceManage deviceManage) { //新增入库 deviceManage.setStatus((byte) 1); mapper.insert(deviceManage); return new Response().setMsg(1,"添加成功"); } public Response delete(Integer deviceId) { //逻辑删除,更改状态为0 UpdateWrapper<DeviceManage> wrapper = Wrappers.update(); wrapper.apply("update set status = 0 where deviceId=?",deviceId); int update = mapper.update(null, wrapper); return new Response().setMsg(1,"出库报废成功"); } public Response update(DeviceManage deviceManage) { mapper.updateById(deviceManage); return new Response().setMsg(1,"修改成功"); } } src/main/resources/config/application.yml
@@ -9,11 +9,11 @@ datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3360/db_3.5mw_web?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true # url: jdbc:mysql://192.168.10.221:3360/db_3.5mw_web?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true # url: jdbc:mysql://localhost:3360/db_experiment?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true url: jdbc:mysql://192.168.10.221:3360/db_experiment?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true # url: jdbc:mysql://192.168.10.221:3360?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true # url: jdbc:mysql://192.168.10.222:3360/db_user?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true # url: jdbc:mysql://118.89.139.230:3360/db_user?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true # url: jdbc:mysql://192.168.10.222:3360/db_experiment?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true # url: jdbc:mysql://118.89.139.230:3360/db_experiment?characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowMultiQueries=true username: root password: lmx8688139 maxIdel: 60