cnas-server/src/main/java/com/yuanchu/mom/controller/DeviceController.java
@@ -14,9 +14,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -28,6 +26,7 @@ @RestController @RequestMapping("/deviceScope") public class DeviceController { private DeviceService deviceService; @@ -80,31 +79,32 @@ //图片上传 @ApiOperation(value = "图片上传") @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) public Result uploadFile(MultipartFile file, HttpServletRequest request) throws IOException { //获取文件名称 HashMap<String, String> list = new HashMap<>(); @PostMapping("/uploadFile") public Result uploadFile(MultipartFile file) { System.out.println(file.getOriginalFilename()); String urlString = null; String pathName = null; String filename = file.getOriginalFilename(); String s = filename.substring(filename.lastIndexOf("."), filename.length()); System.out.println(filename); //获取真实路径 String realPath = request.getServletContext().getRealPath("/Users/gaoaoy/webapp/images"); //创建文件 File file1 = new File(realPath); if (!file1.exists()) { file1.mkdirs(); try { String path = "/Users/gaoaoy/webapp/images"; File realpath = new File(path); if (!realpath.exists()) { realpath.mkdirs(); } pathName = UUID.randomUUID() + "_" + file.getOriginalFilename(); urlString = realpath + "/" + pathName; file.transferTo(new File(urlString)); System.out.println(pathName); HashMap<String, String> map = new HashMap<>(); map.put("name", filename); map.put("url", pathName); return Result.success(map); } catch (Exception e) { e.printStackTrace(); System.err.println("图片上传错误"); return null; } file.transferTo(new File(file1 + "/" + filename)); String ss= filename; UUID uuid = UUID.randomUUID(); ss = uuid.toString() + s; String ful = "/Users/gaoaoy/webapp/images" + ss; System.out.println(file1); list.put("url", ful); list.put("name", filename); return Result.success(list); } @ApiOperation(value = "获取设备负责人") cnas-server/src/main/java/com/yuanchu/mom/mapper/DeviceMapper.java
@@ -22,6 +22,7 @@ List<Device> authorizedPerson(); //查询 List<Device> search(@Param(value = "status") Integer status, @Param(value = "deviceName") String deviceName, @Param(value = "specificationModel") String specificationModel, @Param(value = "largeCategory") String largeCategory); cnas-server/src/main/java/com/yuanchu/mom/pojo/Device.java
@@ -138,11 +138,11 @@ @ValueTableShow(28) @ApiModelProperty(value = "图片上传") private Integer imageUpload; private String imageUpload; @ValueTableShow(29) @ApiModelProperty(value = "图片备注") private Integer imageName; private String imageName; @ApiModelProperty(value = "创建人id") @TableField(fill = FieldFill.INSERT) cnas-server/src/main/java/com/yuanchu/mom/service/DeviceService.java
@@ -1,5 +1,6 @@ package com.yuanchu.mom.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.yuanchu.mom.pojo.Device; @@ -11,7 +12,7 @@ */ public interface DeviceService extends IService<Device> { Map<String, Object> selectDeviceParameter(com.baomidou.mybatisplus.extension.plugins.pagination.Page page, Device itemParameter); Map<String, Object> selectDeviceParameter(Page page, Device itemParameter); int addDeviceParameter(Device itemParameter); cnas-server/src/main/java/com/yuanchu/mom/service/impl/DeviceServiceImpl.java
@@ -1,5 +1,6 @@ package com.yuanchu.mom.service.impl; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.yuanchu.mom.common.GetLook; import com.yuanchu.mom.common.PrintChina; @@ -31,7 +32,6 @@ map.put("head", PrintChina.printChina(Device.class)); Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectDeviceParameter"); if (map1.get("look") == 1) itemParameter.setCreateUser(map1.get("userId")); // deviceMapper.selectPage(page, QueryWrappers.queryWrappers(itemParameter)); map.put("body", deviceMapper.selectPage(page, QueryWrappers.queryWrappers(itemParameter))); return map; } @@ -53,7 +53,7 @@ @Override public List<Device> selectEquipmentOverview() { return deviceMapper.selectEquipmentOverview(new com.baomidou.mybatisplus.extension.plugins.pagination.Page(1, 10), QueryWrappers.queryWrappers(new Device())); return deviceMapper.selectEquipmentOverview(new Page(1, 10), QueryWrappers.queryWrappers(new Device())); } @Override cnas-server/src/main/resources/mapper/DeviceMapper.xml
@@ -59,11 +59,10 @@ </if> </select> <select id="authorizedPerson" resultType="com.yuanchu.mom.pojo.Device"> select * from (select id, authorized_person, status from device) a select id, authorized_person, status from device </select> <select id="search" resultType="com.yuanchu.mom.pojo.Device"> select *