From 90400afc2e72950229506fa76d474c25b6c8eed3 Mon Sep 17 00:00:00 2001 From: gaoaoy <1042166043@qq.com> Date: 星期三, 06 三月 2024 15:45:13 +0800 Subject: [PATCH] 6 设备工具明细 图片上传 --- 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..4536e8b 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,10 @@ import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import java.io.File; +import java.util.HashMap; import java.util.Map; /** @@ -22,6 +26,7 @@ @RestController @RequestMapping("/deviceScope") public class DeviceController { + private DeviceService deviceService; @@ -58,5 +63,55 @@ 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 = "鍥剧墖涓婁紶") + @PostMapping("/uploadFile") + public Result uploadFile(MultipartFile file) { + + System.out.println(file.getOriginalFilename()); + String urlString = null; + String pathName = null; + String filename = file.getOriginalFilename(); + 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; + } + } + + @ApiOperation(value = "鑾峰彇璁惧璐熻矗浜�") + @GetMapping("/selectDevicePrincipal") + @ValueAuth + public Result selectDevicePrincipal() { + return Result.success(deviceService.selectDevicePrincipal()); + } } -- Gitblit v1.9.3