From 599b942446bb8bfc1f6d12c1fcb22a5e95398b37 Mon Sep 17 00:00:00 2001
From: 李林 <z1292839451@163.com>
Date: 星期三, 13 三月 2024 16:12:39 +0800
Subject: [PATCH] 功能调整
---
cnas-server/src/main/java/com/yuanchu/mom/controller/DeviceController.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 58 insertions(+), 2 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..fee39a8 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;
@@ -9,21 +10,29 @@
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import lombok.AllArgsConstructor;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import javax.annotation.Resource;
+import java.io.File;
+import java.util.HashMap;
import java.util.Map;
/**
* 璁惧(DeviceController)琛ㄦ帶鍒跺眰
*/
@Api(tags = "璁惧")
-@AllArgsConstructor
@RestController
@RequestMapping("/deviceScope")
public class DeviceController {
+
+ @Resource
private DeviceService deviceService;
+
+ @Value("${file.path}")
+ private String filePath;
@ApiOperation(value = "鏌ヨ璁惧璇︽儏鍒楄〃")
@PostMapping("/selectDeviceParameter")
@@ -58,5 +67,52 @@
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) {
+ String urlString;
+ String pathName;
+ String filename = file.getOriginalFilename();
+ try {
+ String path = filePath;
+ File realpath = new File(path);
+ if (!realpath.exists()) {
+ realpath.mkdirs();
+ }
+ pathName = UUID.randomUUID() + "_" + file.getOriginalFilename();
+ urlString = realpath + "/" + pathName;
+ file.transferTo(new File(urlString));
+ 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