TRX преди 1 година
родител
ревизия
8ed53b0eb3

+ 38 - 0
src/main/java/com/zswl/dataservice/controller/free/GateWayFreeController.java

@@ -0,0 +1,38 @@
+package com.zswl.dataservice.controller.free;
+
+import com.zswl.dataservice.model.mqtt.GateWayBindDeviceParam;
+import com.zswl.dataservice.service.mqtt.GateWayInfoService;
+import com.zswl.dataservice.utils.result.ResultContent;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.Assert;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 网关管理 服务
+ *
+ * @author TRX
+ * @date 2024/3/21
+ */
+@RequestMapping("/gateWayInfo/free")
+@RestController
+@Validated
+@Tag(name = "网关开发接口")
+public class GateWayFreeController {
+
+    @Autowired
+    GateWayInfoService gateWayInfoService;
+
+    @Operation(summary = "网关绑定设备、连接账号")
+    @RequestMapping(value = "gateWayBindDevice", method = {RequestMethod.POST})
+    public ResultContent gateWayBindDevice(@RequestBody GateWayBindDeviceParam param) {
+        Assert.hasText(param.getGateWayId(), "网关ID不能为空");
+        Assert.hasText(param.getUserName(), "连接账号不能为空");
+        return gateWayInfoService.gateWayBindDevice(param);
+    }
+}

+ 3 - 0
src/main/java/com/zswl/dataservice/domain/mqtt/ProjectInfo.java

@@ -19,10 +19,13 @@ import org.springframework.data.mongodb.core.mapping.Document;
 @AllArgsConstructor
 @NoArgsConstructor
 public class ProjectInfo extends SuperEntity {
+
     @Schema(description = "名称")
     private String name;
+
     @Schema(description = "code")
     private String code;
+
     @Schema(description = "状态")
     private CommonState state;
 }

+ 1 - 0
src/main/java/com/zswl/dataservice/model/mqtt/DeviceInfoAddParam.java

@@ -38,6 +38,7 @@ public class DeviceInfoAddParam extends SuperParam {
     @Schema(description = "连接参数")
     private JSONObject connectParam;
 
+    @Schema(description = "是否开启日志上传")
     private Boolean isReportLogs = Boolean.TRUE;
 
     @Schema(description = "物联网模版信息")

+ 9 - 2
src/main/java/com/zswl/dataservice/model/mqtt/ProjectInfoAddParam.java

@@ -1,6 +1,8 @@
 package com.zswl.dataservice.model.mqtt;
 
 import com.zswl.dataservice.model.baseParam.SuperParam;
+import com.zswl.dataservice.type.DataState;
+import com.zswl.dataservice.utils.mqtt.type.CommonState;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -10,8 +12,13 @@ import lombok.Data;
  */
 @Data
 public class ProjectInfoAddParam extends SuperParam {
-    @Schema(description = "名称")
+    @Schema(description = "项目名称")
     private String name;
-    @Schema(description = "code")
+
+    @Schema(description = "code、项目ID")
     private String code;
+
+    @Schema(description = "状态")
+    private CommonState state = CommonState.Enable;
+
 }

+ 13 - 0
src/main/java/com/zswl/dataservice/model/mqtt/ProjectInfoModel.java

@@ -13,12 +13,25 @@ import lombok.Data;
 public class ProjectInfoModel extends SuperModel {
     @Schema(description = "名称")
     private String name;
+
     @Schema(description = "code")
     private String code;
+
     @Schema(description = "状态")
     private CommonState state;
+
+    private String stateStr;
+
+    public String getStateStr() {
+        if (state != null) {
+            return state.getRemark();
+        }
+        return "";
+    }
+
     @Schema(description = "设备数量")
     private Integer deviceNumber = 0;
+
     @Schema(description = "网关数量")
     private Integer gateWayNumber = 0;
 }