TRX 1 жил өмнө
parent
commit
eadc5f446e

+ 8 - 4
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/controller/hardware/GateWayUserInfoController.java

@@ -3,10 +3,7 @@ package com.zhongshu.iot.server.core.controller.hardware;
 import com.github.microservice.auth.security.annotations.ResourceAuth;
 import com.github.microservice.auth.security.type.AuthType;
 import com.github.microservice.net.ResultContent;
-import com.zhongshu.iot.client.model.mqtt.GateWayUserInfoModel;
-import com.zhongshu.iot.client.model.mqtt.GateWayUserInfoNameParam;
-import com.zhongshu.iot.client.model.mqtt.GateWayUserInfoParam;
-import com.zhongshu.iot.client.model.mqtt.GateWayUserInfoSearchParam;
+import com.zhongshu.iot.client.model.mqtt.*;
 import com.zhongshu.iot.server.core.service.device.GateWayUserInfoService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -44,6 +41,13 @@ public class GateWayUserInfoController {
         return gateWayUserInfoService.createUser(param);
     }
 
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "编辑连接用户信息")
+    @RequestMapping(value = "update", method = {RequestMethod.POST})
+    public ResultContent update(@RequestBody GateWayUserInfoUpdateParam param) {
+        return gateWayUserInfoService.update(param);
+    }
+
 //    @ResourceAuth(value = "user", type = AuthType.User)
 //    @Operation(summary = "添加连接用户")
 //    @RequestMapping(value = "addDeviceInfo", method = {RequestMethod.POST})

+ 18 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/GateWayUserInfoService.java

@@ -158,6 +158,23 @@ public class GateWayUserInfoService {
         return ResultContent.buildSuccess();
     }
 
+    /**
+     * 编辑用户信息
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent update(GateWayUserInfoUpdateParam param) {
+        GateWayUserInfo entity = gateWayUserInfoDao.findTopById(param.getId());
+        if (ObjectUtils.isEmpty(entity)) {
+            return ResultContent.buildFail("数据不存在");
+        }
+        BeanUtils.copyProperties(param, entity);
+        gateWayUserInfoDao.save(entity);
+
+        return ResultContent.buildSuccess();
+    }
+
     /**
      * 添加用户 (从网关注册开始)
      *
@@ -206,7 +223,7 @@ public class GateWayUserInfoService {
         gateWayUserInfoDao.save(entity);
 
         // 同步
-        if (param.getState() == MqttUserState.Disable) {
+        if (entity.getState() == MqttUserState.Disable) {
             // 不过不可用,则删除QMTT服务上的用户信息
             removeUserToMQTTService(entity);
         } else {