From 04b2dab7ecdc9aefde84db18f3cf0029b1db7eb2 Mon Sep 17 00:00:00 2001 From: gaoaoy <1042166043@qq.com> Date: 星期二, 05 三月 2024 17:59:16 +0800 Subject: [PATCH] 6 设备工具明细BUG修改 --- cnas-server/src/main/java/com/yuanchu/mom/controller/DeviceController.java | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 55 insertions(+), 0 deletions(-) diff --git a/cnas-server/src/main/java/com/yuanchu/mom/controller/DeviceController.java b/cnas-server/src/main/java/com/yuanchu/mom/controller/DeviceController.java index 0757f5c..c5f3e08 100644 --- a/cnas-server/src/main/java/com/yuanchu/mom/controller/DeviceController.java +++ b/cnas-server/src/main/java/com/yuanchu/mom/controller/DeviceController.java @@ -1,6 +1,7 @@ package com.yuanchu.mom.controller; +import cn.hutool.core.lang.UUID; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yuanchu.mom.annotation.ValueAuth; import com.yuanchu.mom.pojo.Device; @@ -11,7 +12,12 @@ import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; 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; /** @@ -58,5 +64,54 @@ return Result.success(deviceService.selectEquipmentOverview()); } + @ApiOperation(value = "鑾峰彇琚巿鏉冧汉") + @GetMapping("/authorizedPerson") + @ValueAuth + public Result authorizedPerson() { + return Result.success(deviceService.authorizedPerson()); + } + + @ApiOperation(value = "鎼滅储") + @GetMapping("/search") + @ValueAuth + public Result search(Integer status, String deviceName, String specificationModel, String largeCategory) { + return Result.success(deviceService.search(status, deviceName, specificationModel, largeCategory)); + } + + //鍥剧墖涓婁紶 + @ApiOperation(value = "鍥剧墖涓婁紶") + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) + public Result uploadFile(MultipartFile file, HttpServletRequest request) throws IOException { + //鑾峰彇鏂囦欢鍚嶇О + HashMap<String, String> list = new HashMap<>(); + 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(); + } + 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 = "鑾峰彇璁惧璐熻矗浜�") + @GetMapping("/selectDevicePrincipal") + @ValueAuth + public Result selectDevicePrincipal() { + return Result.success(deviceService.selectDevicePrincipal()); + } } -- Gitblit v1.9.3