From 849c3bfad21a3821f303413f82cda2d8d4d27733 Mon Sep 17 00:00:00 2001
From: dongyukun <1208714201@qq.com>
Date: 星期二, 05 十一月 2024 18:41:31 +0800
Subject: [PATCH] tag查当前值

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java |   85 ++++++++++++++++++++++++------------------
 1 files changed, 49 insertions(+), 36 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java
index d70b262..f11d797 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/modbus/controller/admin/ChannelModbusDeviceController.java
@@ -1,14 +1,22 @@
 package com.iailab.module.data.channel.modbus.controller.admin;
 
-import com.iailab.module.data.common.utils.PageUtils;
-import com.iailab.module.data.common.utils.R;
+import com.iailab.framework.common.pojo.CommonResult;
+import com.iailab.framework.common.pojo.PageResult;
+import com.iailab.framework.common.util.object.BeanUtils;
+import com.iailab.module.data.channel.modbus.vo.ModBusDevicePageReqVO;
 import com.iailab.module.data.channel.modbus.entity.ChannelModBusDeviceEntity;
 import com.iailab.module.data.channel.modbus.service.ChannelModbusDeviceService;
+
 import javax.annotation.Resource;
+
+import com.iailab.module.data.channel.modbus.vo.ModBusDeviceRespVO;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Map;
 import java.util.UUID;
+
+import static com.iailab.framework.common.pojo.CommonResult.success;
 
 /**
  * 操作modbus配置
@@ -25,59 +33,64 @@
     /**
      * 分页查询设备
      *
-     * @param params
+     * @param reqVO
      */
-    @GetMapping("/list")
-    public R list(@RequestParam Map<String, Object> params){
-        PageUtils page = channelModbusDeviceService.queryPage(params);
+    @PreAuthorize("@ss.hasPermission('data:channel-modbus:query')")
+    @GetMapping("/page")
+    public CommonResult<PageResult<ModBusDeviceRespVO>> list(@Validated ModBusDevicePageReqVO reqVO) {
+        PageResult<ChannelModBusDeviceEntity> page = channelModbusDeviceService.queryPage(reqVO);
 
-        return R.ok().put("page", page);
+        return success(BeanUtils.toBean(page, ModBusDeviceRespVO.class));
     }
+
     /**
      * 根据id查询设备详情
      *
      * @param id
      */
+    @PreAuthorize("@ss.hasPermission('data:channel-modbus:query')")
     @GetMapping("/info/{id}")
-    public R info(@PathVariable("id") String id){
-        ChannelModBusDeviceEntity info= channelModbusDeviceService.info(id);
-        return R.ok().put("data", info);
-    }
-    /**
-    * 添加设备
-    *
-    * @param channelModBusDeviceEntity
-    */
-    @PostMapping("/add")
-    public R add(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity){
-        String id = UUID.randomUUID().toString();
-        channelModBusDeviceEntity.setId(id);
-        channelModbusDeviceService.add(channelModBusDeviceEntity);
-        return R.ok();
+    public CommonResult<ChannelModBusDeviceEntity> info(@PathVariable("id") String id) {
+        ChannelModBusDeviceEntity info = channelModbusDeviceService.info(id);
+        return success(info);
     }
 
     /**
-    * 修改设备
-    *
-    * @param channelModBusDeviceEntity
-    */
-    @PostMapping("/update")
-    public R update(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) {
+     * 添加设备
+     *
+     * @param channelModBusDeviceEntity
+     */
+    @PreAuthorize("@ss.hasPermission('data:channel-modbus:create')")
+    @PostMapping("/create")
+    public CommonResult<Boolean> create(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) {
+        String id = UUID.randomUUID().toString();
+        channelModBusDeviceEntity.setId(id);
+        channelModbusDeviceService.add(channelModBusDeviceEntity);
+        return success(true);
+    }
+
+    /**
+     * 修改设备
+     *
+     * @param channelModBusDeviceEntity
+     */
+    @PreAuthorize("@ss.hasPermission('data:channel-modbus:update')")
+    @PutMapping("/update")
+    public CommonResult<Boolean> update(@RequestBody ChannelModBusDeviceEntity channelModBusDeviceEntity) {
         channelModbusDeviceService.update(channelModBusDeviceEntity);
-        return R.ok();
+        return success(true);
     }
 
     /**
      * 删除设备
      *
-     * @param params
-     *
+     * @param id
      */
-    @PostMapping("/delete")
-    public R delete(@RequestBody Map<String, Object> params) {
-        String id = (String)params.get("id");
+    @PreAuthorize("@ss.hasPermission('data:channel-modbus:delete')")
+    @DeleteMapping("/delete")
+    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
         channelModbusDeviceService.delete(id);
-        return R.ok();
+        return success(true);
     }
 
 

--
Gitblit v1.9.3