From ad45ebdf25cae54a3950bba33aa767fc7a8a43d8 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 22 五月 2026 21:26:13 +0800
Subject: [PATCH] feat: 设备台账新增附件图片上传

---
 src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java |   54 ++++++++++++++++++++++++++----------------------------
 1 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java b/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
index 40c6dad..298980e 100644
--- a/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
+++ b/src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java
@@ -12,8 +12,7 @@
 import com.ruoyi.device.pojo.DeviceMaintenance;
 import com.ruoyi.device.service.IDeviceLedgerService;
 import com.ruoyi.framework.aspectj.lang.annotation.Anonymous;
-import com.ruoyi.framework.web.controller.BaseController;
-import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.framework.web.domain.AjaxResult;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.Operation;
 import jakarta.servlet.http.HttpServletResponse;
@@ -29,53 +28,52 @@
 @RequestMapping("/device/ledger")
 @RestController
 @AllArgsConstructor
-public class DeviceLedgerController extends BaseController {
+public class DeviceLedgerController {
 
     private IDeviceLedgerService deviceLedgerService;
     private DeviceLedgerMapper deviceLedgerMapper;
     private DeviceMaintenanceMapper deviceMaintenanceMapper;
 
 
-
     @Operation(summary = "璁惧鍙拌处鍒楄〃")
     @GetMapping("/page")
-    public R<?> page(Page page , DeviceLedgerDto deviceLedger) {
-        return R.ok(deviceLedgerService.queryPage(page,deviceLedger));
+    public AjaxResult page(Page page, DeviceLedgerDto deviceLedger) {
+        return AjaxResult.success(deviceLedgerService.queryPage(page, deviceLedger));
     }
 
     @PostMapping()
     @Operation(summary = "娣诲姞璁惧鍙拌处")
-    public R<?> add(@RequestBody DeviceLedger deviceLedger) {
-
-        return deviceLedgerService.saveDeviceLedger(deviceLedger);
+    public AjaxResult add(@RequestBody DeviceLedgerDto deviceLedgerDto) {
+        return deviceLedgerService.saveDeviceLedger(deviceLedgerDto);
     }
 
     @Operation(summary = "鏍规嵁id鏌ヨ璁惧鍙拌处")
     @GetMapping("/{id}")
-    public R<?> detail(@PathVariable Long id) {
-        return R.ok(deviceLedgerService.getById(id));
+    public AjaxResult detail(@PathVariable Long id) {
+        DeviceLedgerDto deviceLedgerDto = deviceLedgerService.getDeviceLedgerDetail(id);
+        return AjaxResult.success(deviceLedgerDto);
     }
 
-    @PutMapping ()
+    @PutMapping()
     @Operation(summary = "淇敼璁惧鍙拌处")
-    public R<?> update(@RequestBody DeviceLedger deviceLedger) {
-        return deviceLedgerService.updateDeviceLedger(deviceLedger);
+    public AjaxResult update(@RequestBody DeviceLedgerDto deviceLedgerDto) {
+        return deviceLedgerService.updateDeviceLedger(deviceLedgerDto);
     }
 
     @DeleteMapping("/{ids}")
     @Operation(summary = "鍒犻櫎璁惧鍙拌处")
-    public R<?> delete(@PathVariable("ids") ArrayList<Long> ids) {
+    public AjaxResult delete(@PathVariable("ids") ArrayList<Long> ids) {
         boolean b = deviceLedgerService.removeBatchByIds(ids);
         if (!b) {
-            return R.fail("鍒犻櫎澶辫触");
+            return AjaxResult.error("鍒犻櫎澶辫触");
         }
-        return R.ok();
+        return AjaxResult.success();
     }
 
     @PostMapping("export")
     @Operation(summary = "瀵煎嚭璁惧鍙拌处")
     public void export(HttpServletResponse response, Long[] ids) {
-         deviceLedgerService.export(response, ids);
+        deviceLedgerService.export(response, ids);
     }
 
     @Operation(summary = "涓嬭浇妯℃澘")
@@ -87,32 +85,32 @@
 
     @PostMapping("/import")
     @Operation(summary = "瀵煎叆璁惧鍙拌处")
-    public R<?> importData(MultipartFile file) throws IOException {
+    public AjaxResult importData(MultipartFile file) throws IOException {
         Boolean b = deviceLedgerService.importData(file);
         if (b) {
-            return R.ok(null, "瀵煎叆鎴愬姛");
+            return AjaxResult.success("瀵煎叆鎴愬姛");
         }
-        return R.fail("瀵煎叆澶辫触");
+        return AjaxResult.error("瀵煎叆澶辫触");
     }
 
 
     @GetMapping("getDeviceLedger")
     @Operation(summary = "鑾峰彇璁惧鍙拌处")
-    public R<?> getDeviceLedger( ) {
-        return R.ok(deviceLedgerService.list(new QueryWrapper<DeviceLedger>().lambda()
-                .select(DeviceLedger::getId, DeviceLedger::getDeviceName,DeviceLedger::getDeviceModel)));
+    public AjaxResult getDeviceLedger() {
+        return AjaxResult.success(deviceLedgerService.list(new QueryWrapper<DeviceLedger>().lambda()
+                .select(DeviceLedger::getId, DeviceLedger::getDeviceName, DeviceLedger::getDeviceModel)));
     }
 
     @GetMapping("scanDevice")
     @Operation(summary = "鑾峰彇璁惧鍙拌处")
     @Anonymous
-    public R<?> scanDevice(Long id) {
+    public AjaxResult scanDevice(Long id) {
         List<DeviceMaintenance> list = deviceMaintenanceMapper.list1(id);
         DeviceLedger deviceLedger = deviceLedgerMapper.selectById1(id);
-        if (list.size()>0){
-            deviceLedger.setUpdateTime(list.get(0).getMaintenanceActuallyTime());//鏈�鍚庣淮鎶ゆ椂闂�
+        if (!list.isEmpty()) {
+            deviceLedger.setUpdateTime(list.getFirst().getMaintenanceActuallyTime());//鏈�鍚庣淮鎶ゆ椂闂�
         }
         deviceLedger.setCreateTime(deviceLedger.getUpdateTime().plusMonths(1));//涓嬫缁存姢鏃堕棿
-        return R.ok(deviceLedger);
+        return AjaxResult.success(deviceLedger);
     }
 }

--
Gitblit v1.9.3