TRX 1 жил өмнө
parent
commit
05f1b45488

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

@@ -4,6 +4,7 @@ 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.card.client.model.base.IDParam;
+import com.zhongshu.card.client.model.base.IDsParam;
 import com.zhongshu.iot.client.model.mqtt.*;
 import com.zhongshu.iot.server.core.service.device.GateWayUserInfoService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -102,4 +103,11 @@ public class GateWayUserInfoController {
         return gateWayUserInfoService.getUserByUserName(param.getUserName());
     }
 
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "更新账号权限")
+    @RequestMapping(value = "updateUserSecurity", method = {RequestMethod.POST})
+    public ResultContent updateUserSecurity(@RequestBody IDsParam param) {
+        return gateWayUserInfoService.updateUserSecurity(param.getIds());
+    }
 }

+ 4 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/GateWayUserInfoDao.java

@@ -3,6 +3,8 @@ package com.zhongshu.iot.server.core.dao.mqtt;
 import com.zhongshu.iot.server.core.dao.mqtt.extend.GateWayUserInfoDaoExtend;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayUserInfo;
 
+import java.util.List;
+
 /**
  * @author TRX
  * @date 2024/3/21
@@ -12,4 +14,6 @@ public interface GateWayUserInfoDao extends GateWayUserInfoDaoExtend, org.spring
     GateWayUserInfo findTopById(String id);
 
     GateWayUserInfo findTopByUserName(String userName);
+
+    List<GateWayUserInfo> findByIdIn(List<String> ids);
 }

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

@@ -20,6 +20,7 @@ import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 账号管理
@@ -136,6 +137,20 @@ public class GateWayUserInfoService {
         return gateWayUserInfo;
     }
 
+    /**
+     * 更新账号权限
+     *
+     * @param ids
+     * @return
+     */
+    public ResultContent updateUserSecurity(List<String> ids) {
+        if (ObjectUtils.isNotEmpty(ids)) {
+            List<GateWayUserInfo> list = gateWayUserInfoDao.findByIdIn(ids);
+            jmxSyncService.syncUserToMQTTService(list);
+        }
+        return ResultContent.buildSuccess();
+    }
+
     /**
      * 添加 连接账号
      *