From 1db111fdf6c65fa1debadf648e4c22bd466744f8 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 18 六月 2026 16:59:29 +0800
Subject: [PATCH] feat: 设备台账上传图片

---
 src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java |   42 +++++++++++++++++++++++++++++++-----------
 1 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java b/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
index f1e88ff..746135c 100644
--- a/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
+++ b/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
@@ -11,8 +11,8 @@
 import com.ruoyi.device.service.IDeviceLedgerService;
 import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
 import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.sales.pojo.CommonFile;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -39,35 +39,35 @@
 
 
 
-    @ApiModelProperty("璁惧鍙拌处鍒楄〃")
+    @ApiOperation("璁惧鍙拌处鍒楄〃")
     @GetMapping("/page")
     public AjaxResult page(Page page , DeviceLedgerDto deviceLedger) {
         return AjaxResult.success(deviceLedgerService.queryPage(page,deviceLedger));
     }
 
     @PostMapping()
-    @ApiModelProperty("娣诲姞璁惧鍙拌处")
+    @ApiOperation("娣诲姞璁惧鍙拌处")
     public AjaxResult add(@RequestBody DeviceLedger deviceLedger) {
 
         return deviceLedgerService.saveDeviceLedger(deviceLedger);
     }
 
-    @ApiModelProperty("鏍规嵁id鏌ヨ璁惧鍙拌处")
+    @ApiOperation("鏍规嵁id鏌ヨ璁惧鍙拌处")
     @GetMapping("/{id}")
     public AjaxResult detail(@PathVariable Long id) {
-        return AjaxResult.success(deviceLedgerService.getById(id));
+        return AjaxResult.success(deviceLedgerService.getDetailById(id));
     }
 
     @PutMapping ()
-    @ApiModelProperty("淇敼璁惧鍙拌处")
+    @ApiOperation("淇敼璁惧鍙拌处")
     public AjaxResult update(@RequestBody DeviceLedger deviceLedger) {
         return deviceLedgerService.updateDeviceLedger(deviceLedger);
     }
 
     @DeleteMapping("/{ids}")
-    @ApiModelProperty("鍒犻櫎璁惧鍙拌处")
+    @ApiOperation("鍒犻櫎璁惧鍙拌处")
     public AjaxResult delete(@PathVariable("ids") ArrayList<Long> ids) {
-        boolean b = deviceLedgerService.removeBatchByIds(ids);
+        boolean b = deviceLedgerService.deleteLedgerAndFiles(ids);
         if (!b) {
             return AjaxResult.error("鍒犻櫎澶辫触");
         }
@@ -75,13 +75,13 @@
     }
 
     @PostMapping("export")
-    @ApiModelProperty("瀵煎嚭璁惧鍙拌处")
+    @ApiOperation("瀵煎嚭璁惧鍙拌处")
     public void export(HttpServletResponse response, Long[] ids) {
          deviceLedgerService.export(response, ids);
     }
 
     @PostMapping("import")
-    @ApiModelProperty("瀵煎叆璁惧鍙拌处")
+    @ApiOperation("瀵煎叆璁惧鍙拌处")
     public AjaxResult importData(MultipartFile file) throws IOException {
         Boolean b = deviceLedgerService.importData(file);
         if (b) {
@@ -92,7 +92,7 @@
 
 
     @GetMapping("getDeviceLedger")
-    @ApiModelProperty("鑾峰彇璁惧鍙拌处")
+    @ApiOperation("鑾峰彇璁惧鍙拌处")
     public AjaxResult getDeviceLedger( ) {
         return AjaxResult.success(deviceLedgerService.list(new QueryWrapper<DeviceLedger>().lambda()
                 .select(DeviceLedger::getId, DeviceLedger::getDeviceName,DeviceLedger::getDeviceModel)));
@@ -110,4 +110,24 @@
         deviceLedger.setCreateTime(deviceLedger.getUpdateTime().plusMonths(1));//涓嬫缁存姢鏃堕棿
         return AjaxResult.success(deviceLedger);
     }
+    @PostMapping("/uploadFile")
+    @ApiOperation("璁惧鍙拌处-闄勪欢涓婁紶")
+    public AjaxResult uploadFile(MultipartFile file, Long deviceLedgerId, Integer fileType) {
+        deviceLedgerService.uploadFile(file, deviceLedgerId, fileType);
+        return AjaxResult.success();
+    }
+
+    @GetMapping("/file/{deviceLedgerId}")
+    @ApiOperation("璁惧鍙拌处-鏂囦欢鍒楄〃")
+    public AjaxResult getFiles(@PathVariable("deviceLedgerId") Long deviceLedgerId) {
+        java.util.List<CommonFile> list = deviceLedgerService.getFiles(deviceLedgerId);
+        return AjaxResult.success(list);
+    }
+
+    @DeleteMapping("/file/{fileId}")
+    @ApiOperation("璁惧鍙拌处-鍒犻櫎鏂囦欢")
+    public AjaxResult deleteFile(@PathVariable("fileId") Long fileId) {
+        deviceLedgerService.deleteFile(fileId);
+        return AjaxResult.success();
+    }
 }

--
Gitblit v1.9.3