From 9a30a3a8d3862a9b2ce898535b7cb51c3ddac816 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期三, 20 五月 2026 16:01:11 +0800
Subject: [PATCH] refactor(controller): 将控制器响应结果统一为R类型并继承BaseController

---
 src/main/java/com/ruoyi/device/controller/DeviceLedgerController.java |   37 +++++++++++++++++++------------------
 1 files changed, 19 insertions(+), 18 deletions(-)

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

--
Gitblit v1.9.3