瀏覽代碼

更新!

TRX 1 年之前
父節點
當前提交
15d503fe23

+ 11 - 10
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/controller/user/ProjectInfoController.java

@@ -1,8 +1,8 @@
 package com.zhongshu.iot.server.core.controller.user;
 
+import com.github.microservice.busInfoModel.device.ProjectInfoModel;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.iot.client.model.mqtt.ProjectInfoAddParam;
-import com.github.microservice.busInfoModel.device.ProjectInfoModel;
 import com.zhongshu.iot.client.model.mqtt.ProjectInfoSearchParam;
 import com.zhongshu.iot.server.core.service.device.ProjectInfoService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
 import java.util.List;
 
 /**
- * 项目 服务
+ * 分组 服务
  *
  * @author TRX
  * @date 2024/3/21
@@ -26,40 +26,41 @@ import java.util.List;
 @RequestMapping("/project")
 @RestController
 @Validated
-@Tag(name = "项目管理")
+@Tag(name = "分组管理")
 public class ProjectInfoController {
 
     @Autowired
-    ProjectInfoService projectInfoService;
+    private ProjectInfoService projectInfoService;
 
-    @Operation(summary = "添加-编辑项目")
+    @Operation(summary = "添加-编辑分组")
     @RequestMapping(value = "addProjectInfo", method = {RequestMethod.POST})
     public ResultContent addProjectInfo(@RequestBody ProjectInfoAddParam param) {
         return projectInfoService.addProjectInfo(param);
     }
 
-    @Operation(summary = "项目列表-分页查询")
+    @Operation(summary = "分组列表-分页查询")
     @RequestMapping(value = {"pageProject"}, method = {RequestMethod.POST})
     public ResultContent<Page<ProjectInfoModel>> pageProject(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, ProjectInfoSearchParam param) {
         return projectInfoService.page(pageable, param);
     }
 
-    @Operation(summary = "删除项目")
+    @Operation(summary = "删除分组")
     @RequestMapping(value = "deleteProjectInfo", method = {RequestMethod.GET})
     public ResultContent deleteProjectInfo(@Parameter(name = "id") @RequestParam("id") String id) {
         return projectInfoService.deleteProjectInfo(id);
     }
 
-    @Operation(summary = "查询项目详情")
+    @Operation(summary = "查询分组详情")
     @RequestMapping(value = "getProjectInfo", method = {RequestMethod.GET})
     @Parameter(name = "id", description = "数据ID")
     public ResultContent<ProjectInfoModel> getProjectInfo(String id) {
         return projectInfoService.getProjectInfo(id);
     }
 
-    @Operation(summary = "查询所有可用的项目列表")
+    @Operation(summary = "查询所有可用的分组列表")
     @RequestMapping(value = "getAllProject", method = {RequestMethod.GET})
-    public ResultContent<List<ProjectInfoModel>> getAllProject() {
+    public ResultContent getAllProject() {
         return projectInfoService.getAllProject();
     }
+
 }

+ 5 - 5
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/ProjectInfoService.java

@@ -1,11 +1,11 @@
 package com.zhongshu.iot.server.core.service.device;
 
+import com.github.microservice.busInfoModel.device.ProjectInfoModel;
+import com.github.microservice.busInfoModel.device.ProjectInfoSimpleModel;
 import com.github.microservice.net.ResultContent;
 import com.github.microservice.types.common.CommonState;
 import com.zhongshu.iot.client.model.mqtt.ProjectInfoAddParam;
-import com.github.microservice.busInfoModel.device.ProjectInfoModel;
 import com.zhongshu.iot.client.model.mqtt.ProjectInfoSearchParam;
-import com.github.microservice.busInfoModel.device.ProjectInfoSimpleModel;
 import com.zhongshu.iot.server.core.dao.mqtt.ProjectInfoDao;
 import com.zhongshu.iot.server.core.domain.iot.device.ProjectInfo;
 import com.zhongshu.iot.server.core.service.base.SuperService;
@@ -73,11 +73,11 @@ public class ProjectInfoService extends SuperService {
      *
      * @return
      */
-    public ResultContent<List<ProjectInfoModel>> getAllProject() {
-        List<ProjectInfoModel> models = new ArrayList<>();
+    public ResultContent<List<ProjectInfoSimpleModel>> getAllProject() {
+        List<ProjectInfoSimpleModel> models = new ArrayList<>();
         List<ProjectInfo> list = projectInfoDao.findByStateOrderByCreateTimeDesc(CommonState.Enable);
         if (ObjectUtils.isNotEmpty(list)) {
-            models = list.stream().map(this::toModel).collect(Collectors.toList());
+            models = list.stream().map(this::toSimpleModel).collect(Collectors.toList());
         }
         return ResultContent.buildSuccess(models);
     }

+ 17 - 16
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotServiceImpl.java

@@ -96,22 +96,6 @@ public class IotServiceImpl extends SuperService {
     public ResultContent addIotTemplate(IotTemplateParam param) {
         IotTemplate template = null;
         initDefaultUser(param);
-        if (StringUtils.isEmpty(param.getName())) {
-            return ResultContent.buildFail("name is empty");
-        }
-        if (param.getDeviceCategory() == null) {
-            return ResultContent.buildFail("deviceCategory is empty");
-        }
-        if (param.getDeviceCategory() == DeviceCategory.DE) {
-            if (param.getDeviceType() == null) {
-                return ResultContent.buildFail("deviceType is empty");
-            }
-        }
-
-        // 适用设备型号
-        if (param.getSpecType() == null) {
-            param.setSpecType(DeviceSpecType.Common);
-        }
 
         IotTemplate temp = iotTemplateDao.findTopByNameAndIotDataType(param.getName(), IotDataType.IotTemplate);
         if (StringUtils.isNotEmpty(param.getId())) {
@@ -126,6 +110,23 @@ public class IotServiceImpl extends SuperService {
             template.setName(param.getName());
             template.setRemark(param.getRemark());
         } else {
+            if (StringUtils.isEmpty(param.getName())) {
+                return ResultContent.buildFail("name is empty");
+            }
+            if (param.getDeviceCategory() == null) {
+                return ResultContent.buildFail("deviceCategory is empty");
+            }
+            if (param.getDeviceCategory() == DeviceCategory.DE) {
+                if (param.getDeviceType() == null) {
+                    return ResultContent.buildFail("deviceType is empty");
+                }
+            }
+
+            // 适用设备型号
+            if (param.getSpecType() == null) {
+                param.setSpecType(DeviceSpecType.Common);
+            }
+
             // 新增加
             template = new IotTemplate();
             if (ObjectUtils.isNotEmpty(temp)) {