TRX 1 год назад
Родитель
Сommit
759e100de8

+ 40 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/IotTemplateDeviceBind.java

@@ -0,0 +1,40 @@
+package com.zhongshu.iot.server.core.domain.iot;
+
+import com.zhongshu.iot.client.type.DataState;
+import com.zhongshu.iot.server.core.domain.base.SuperEntity;
+import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * @author TRX
+ * @date 2025/2/10
+ */
+@Data
+@Document
+@NoArgsConstructor
+@AllArgsConstructor
+public class IotTemplateDeviceBind extends SuperEntity {
+
+    @Schema(description = "设备id")
+    private String deviceId;
+
+    @Schema(description = "设备信息")
+    @DBRef(lazy = true)
+    private DeviceInfo deviceInfo;
+
+    @Schema(description = "物模型id")
+    private String templateId;
+
+    @Schema(description = "物模型")
+    @DBRef(lazy = true)
+    private IotTemplate template;
+
+    @Schema(description = "设备状态")
+    private DataState state = DataState.Enable;
+
+}

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

@@ -3,10 +3,13 @@ package com.zhongshu.iot.server.core.service.device;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.model.base.IDParam;
 import com.zhongshu.iot.client.model.mqtt.*;
+import com.zhongshu.iot.client.type.type.LogsLevel;
 import com.zhongshu.iot.client.type.type.MqttUserState;
 import com.zhongshu.iot.server.core.dao.mqtt.*;
 import com.zhongshu.iot.server.core.dataConfig.MqttConfig;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.*;
+import com.zhongshu.iot.server.core.service.base.SuperService;
+import com.zhongshu.iot.server.core.service.user.OperationLogsService;
 import com.zhongshu.iot.server.core.util.CommonUtil;
 import com.zhongshu.iot.server.core.util.DateUtils;
 import com.zhongshu.iot.server.core.util.bean.BeanUtils;
@@ -30,7 +33,7 @@ import java.util.List;
  */
 @Slf4j
 @Service
-public class GateWayUserInfoService {
+public class GateWayUserInfoService extends SuperService {
 
     @Autowired
     private GateWayUserInfoDao gateWayUserInfoDao;
@@ -65,6 +68,9 @@ public class GateWayUserInfoService {
     @Autowired
     private GateWayUserInfoTempDao gateWayUserInfoTempDao;
 
+    @Autowired
+    private OperationLogsService operationLogsService;
+
     /**
      * 刷新系统所有的用户 和 用户权限数据
      */
@@ -265,6 +271,10 @@ public class GateWayUserInfoService {
 
         // 同步用户
         jmxSyncService.syncUserToMQTTService(entity);
+
+        // 添加日志
+        String userId = getCurrentUserId();
+        operationLogsService.addLogs(String.format("%s重置了 %s mqtt账号的密码", userId, entity.getUserName()), LogsLevel.High);
         return ResultContent.buildSuccess();
     }