Commit 8b7f329183e21b365222401c8a2c7d32108f0ee5
1 parent
fae17e91
【代码优化】IOT: ThingModel
Showing
24 changed files
with
254 additions
and
261 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelAccessModeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelAccessModeEnum.java
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelParamDirectionEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelParamDirectionEnum.java
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelServiceCallTypeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelServiceCallTypeEnum.java
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelServiceEventTypeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelServiceEventTypeEnum.java
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelTypeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotThingModelTypeEnum.java
| ... | ... | @@ -13,13 +13,13 @@ import java.util.Arrays; |
| 13 | 13 | */ |
| 14 | 14 | @AllArgsConstructor |
| 15 | 15 | @Getter |
| 16 | -public enum IotProductThingModelTypeEnum implements IntArrayValuable { | |
| 16 | +public enum IotThingModelTypeEnum implements IntArrayValuable { | |
| 17 | 17 | |
| 18 | 18 | PROPERTY(1, "属性"), |
| 19 | 19 | SERVICE(2, "服务"), |
| 20 | 20 | EVENT(3, "事件"); |
| 21 | 21 | |
| 22 | - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductThingModelTypeEnum::getType).toArray(); | |
| 22 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotThingModelTypeEnum::getType).toArray(); | |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * 类型 |
| ... | ... | @@ -30,8 +30,8 @@ public enum IotProductThingModelTypeEnum implements IntArrayValuable { |
| 30 | 30 | */ |
| 31 | 31 | private final String description; |
| 32 | 32 | |
| 33 | - public static IotProductThingModelTypeEnum valueOfType(Integer type) { | |
| 34 | - for (IotProductThingModelTypeEnum value : values()) { | |
| 33 | + public static IotThingModelTypeEnum valueOfType(Integer type) { | |
| 34 | + for (IotThingModelTypeEnum value : values()) { | |
| 35 | 35 | if (value.getType().equals(type)) { |
| 36 | 36 | return value; |
| 37 | 37 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/IotProductThingModelController.http renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/IotThingModelController.http
| ... | ... | @@ -25,8 +25,7 @@ Authorization: Bearer {{token}} |
| 25 | 25 | "defaultValue": "30", |
| 26 | 26 | "unit": "%", |
| 27 | 27 | "unitName": "百分比" |
| 28 | - }, | |
| 29 | - "description": "当前温度值" | |
| 28 | + } | |
| 30 | 29 | } |
| 31 | 30 | } |
| 32 | 31 | |
| ... | ... | @@ -46,7 +45,6 @@ Authorization: Bearer {{token}} |
| 46 | 45 | "property": { |
| 47 | 46 | "identifier": "switch", |
| 48 | 47 | "name": "开关", |
| 49 | - "description": "温度计开关", | |
| 50 | 48 | "accessMode": "rw", |
| 51 | 49 | "required": true, |
| 52 | 50 | "dataType": "bool", |
| ... | ... | @@ -81,7 +79,6 @@ Authorization: Bearer {{token}} |
| 81 | 79 | "property": { |
| 82 | 80 | "identifier": "argb", |
| 83 | 81 | "name": "温度计 argb 颜色", |
| 84 | - "description": "温度计 argb 颜色", | |
| 85 | 82 | "accessMode": "rw", |
| 86 | 83 | "required": true, |
| 87 | 84 | "dataType": "array", |
| ... | ... | @@ -93,7 +90,6 @@ Authorization: Bearer {{token}} |
| 93 | 90 | { |
| 94 | 91 | "identifier": "switch", |
| 95 | 92 | "name": "开关", |
| 96 | - "description": "温度计开关", | |
| 97 | 93 | "accessMode": "rw", |
| 98 | 94 | "required": true, |
| 99 | 95 | "dataType": "struct", |
| ... | ... | @@ -126,8 +122,7 @@ Authorization: Bearer {{token}} |
| 126 | 122 | "defaultValue": "30", |
| 127 | 123 | "unit": "%", |
| 128 | 124 | "unitName": "百分比" |
| 129 | - }, | |
| 130 | - "description": "当前温度值" | |
| 125 | + } | |
| 131 | 126 | } |
| 132 | 127 | ] |
| 133 | 128 | } |
| ... | ... | @@ -151,7 +146,6 @@ Authorization: Bearer {{token}} |
| 151 | 146 | "property": { |
| 152 | 147 | "identifier": "switch", |
| 153 | 148 | "name": "开关", |
| 154 | - "description": "温度计开关", | |
| 155 | 149 | "accessMode": "r", |
| 156 | 150 | "required": true, |
| 157 | 151 | "dataType": "bool", | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/IotProductThingModelController.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/IotThingModelController.java
| ... | ... | @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.controller.admin.thingmodel; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelRespVO; | |
| 8 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelSaveReqVO; | |
| 9 | -import cn.iocoder.yudao.module.iot.convert.thingmodel.IotProductThingModelConvert; | |
| 10 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO; | |
| 11 | -import cn.iocoder.yudao.module.iot.service.thingmodel.IotProductThingModelService; | |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelRespVO; | |
| 8 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelSaveReqVO; | |
| 9 | +import cn.iocoder.yudao.module.iot.convert.thingmodel.IotThingModelConvert; | |
| 10 | +import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | |
| 11 | +import cn.iocoder.yudao.module.iot.service.thingmodel.IotThingModelService; | |
| 12 | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -24,61 +24,61 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 24 | 24 | |
| 25 | 25 | @Tag(name = "管理后台 - IoT 产品物模型") |
| 26 | 26 | @RestController |
| 27 | -@RequestMapping("/iot/product-thing-model") | |
| 27 | +@RequestMapping("/iot/thing-model") | |
| 28 | 28 | @Validated |
| 29 | -public class IotProductThingModelController { | |
| 29 | +public class IotThingModelController { | |
| 30 | 30 | |
| 31 | 31 | @Resource |
| 32 | - private IotProductThingModelService thingModelService; | |
| 32 | + private IotThingModelService thingModelService; | |
| 33 | 33 | |
| 34 | 34 | @PostMapping("/create") |
| 35 | 35 | @Operation(summary = "创建产品物模型") |
| 36 | - @PreAuthorize("@ss.hasPermission('iot:product-thing-model:create')") | |
| 37 | - public CommonResult<Long> createProductThingModel(@Valid @RequestBody IotProductThingModelSaveReqVO createReqVO) { | |
| 38 | - return success(thingModelService.createProductThingModel(createReqVO)); | |
| 36 | + @PreAuthorize("@ss.hasPermission('iot:thing-model:create')") | |
| 37 | + public CommonResult<Long> createThingModel(@Valid @RequestBody IotThingModelSaveReqVO createReqVO) { | |
| 38 | + return success(thingModelService.createThingModel(createReqVO)); | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | @PutMapping("/update") |
| 42 | 42 | @Operation(summary = "更新产品物模型") |
| 43 | - @PreAuthorize("@ss.hasPermission('iot:product-thing-model:update')") | |
| 44 | - public CommonResult<Boolean> updateProductThingModel(@Valid @RequestBody IotProductThingModelSaveReqVO updateReqVO) { | |
| 45 | - thingModelService.updateProductThingModel(updateReqVO); | |
| 43 | + @PreAuthorize("@ss.hasPermission('iot:thing-model:update')") | |
| 44 | + public CommonResult<Boolean> updateThingModel(@Valid @RequestBody IotThingModelSaveReqVO updateReqVO) { | |
| 45 | + thingModelService.updateThingModel(updateReqVO); | |
| 46 | 46 | return success(true); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | @DeleteMapping("/delete") |
| 50 | 50 | @Operation(summary = "删除产品物模型") |
| 51 | 51 | @Parameter(name = "id", description = "编号", required = true) |
| 52 | - @PreAuthorize("@ss.hasPermission('iot:product-thing-model:delete')") | |
| 53 | - public CommonResult<Boolean> deleteProductThingModel(@RequestParam("id") Long id) { | |
| 54 | - thingModelService.deleteProductThingModel(id); | |
| 52 | + @PreAuthorize("@ss.hasPermission('iot:thing-model:delete')") | |
| 53 | + public CommonResult<Boolean> deleteThingModel(@RequestParam("id") Long id) { | |
| 54 | + thingModelService.deleteThingModel(id); | |
| 55 | 55 | return success(true); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | @GetMapping("/get") |
| 59 | 59 | @Operation(summary = "获得产品物模型") |
| 60 | 60 | @Parameter(name = "id", description = "编号", required = true) |
| 61 | - @PreAuthorize("@ss.hasPermission('iot:product-thing-model:query')") | |
| 62 | - public CommonResult<IotProductThingModelRespVO> getProductThingModel(@RequestParam("id") Long id) { | |
| 63 | - IotProductThingModelDO thingModel = thingModelService.getProductThingModel(id); | |
| 64 | - return success(IotProductThingModelConvert.INSTANCE.convert(thingModel)); | |
| 61 | + @PreAuthorize("@ss.hasPermission('iot:thing-model:query')") | |
| 62 | + public CommonResult<IotThingModelRespVO> getThingModel(@RequestParam("id") Long id) { | |
| 63 | + IotThingModelDO thingModel = thingModelService.getThingModel(id); | |
| 64 | + return success(IotThingModelConvert.INSTANCE.convert(thingModel)); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | @GetMapping("/list-by-product-id") |
| 68 | 68 | @Operation(summary = "获得产品物模型") |
| 69 | 69 | @Parameter(name = "productId", description = "产品ID", required = true, example = "1024") |
| 70 | - @PreAuthorize("@ss.hasPermission('iot:product-thing-model:query')") | |
| 71 | - public CommonResult<List<IotProductThingModelRespVO>> getProductThingModelListByProductId(@RequestParam("productId") Long productId) { | |
| 72 | - List<IotProductThingModelDO> list = thingModelService.getProductThingModelListByProductId(productId); | |
| 73 | - return success(IotProductThingModelConvert.INSTANCE.convertList(list)); | |
| 70 | + @PreAuthorize("@ss.hasPermission('iot:thing-model:query')") | |
| 71 | + public CommonResult<List<IotThingModelRespVO>> getThingModelListByProductId(@RequestParam("productId") Long productId) { | |
| 72 | + List<IotThingModelDO> list = thingModelService.getThingModelListByProductId(productId); | |
| 73 | + return success(IotThingModelConvert.INSTANCE.convertList(list)); | |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | @GetMapping("/page") |
| 77 | 77 | @Operation(summary = "获得产品物模型分页") |
| 78 | - @PreAuthorize("@ss.hasPermission('iot:product-thing-model:query')") | |
| 79 | - public CommonResult<PageResult<IotProductThingModelRespVO>> getProductThingModelPage(@Valid IotProductThingModelPageReqVO pageReqVO) { | |
| 80 | - PageResult<IotProductThingModelDO> pageResult = thingModelService.getProductThingModelPage(pageReqVO); | |
| 81 | - return success(BeanUtils.toBean(pageResult, IotProductThingModelRespVO.class)); | |
| 78 | + @PreAuthorize("@ss.hasPermission('iot:thing-model:query')") | |
| 79 | + public CommonResult<PageResult<IotThingModelRespVO>> getThingModelPage(@Valid IotThingModelPageReqVO pageReqVO) { | |
| 80 | + PageResult<IotThingModelDO> pageResult = thingModelService.getProductThingModelPage(pageReqVO); | |
| 81 | + return success(BeanUtils.toBean(pageResult, IotThingModelRespVO.class)); | |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelEvent.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelServiceEventTypeEnum; | |
| 3 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelServiceEventTypeEnum; | |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | 6 | import java.util.List; |
| ... | ... | @@ -31,7 +31,7 @@ public class ThingModelEvent { |
| 31 | 31 | /** |
| 32 | 32 | * 事件类型 |
| 33 | 33 | * |
| 34 | - * 关联枚举 {@link IotProductThingModelServiceEventTypeEnum} | |
| 34 | + * 关联枚举 {@link IotThingModelServiceEventTypeEnum} | |
| 35 | 35 | */ |
| 36 | 36 | private String type; |
| 37 | 37 | /** |
| ... | ... | @@ -39,7 +39,7 @@ public class ThingModelEvent { |
| 39 | 39 | * |
| 40 | 40 | * 输出参数定义事件调用后返回的结果或反馈信息,用于确认操作结果或提供额外的信息。 |
| 41 | 41 | */ |
| 42 | - private List<ThingModelInputOutputParam> outputParams; | |
| 42 | + private List<ThingModelParam> outputParams; | |
| 43 | 43 | /** |
| 44 | 44 | * 标识设备需要执行的具体操作 |
| 45 | 45 | */ | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelInputOutputParam.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelParam.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType.ThingModelDataSpecs; |
| 4 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelParamDirectionEnum; | |
| 4 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelParamDirectionEnum; | |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | |
| 7 | 7 | import java.util.List; |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | - * IOT 产品物模型中的参数 // TODO @puhui999 考虑要不改成 ThingModelParam ? | |
| 10 | + * IOT 产品物模型中的参数 | |
| 11 | 11 | * |
| 12 | 12 | * @author HUIHUI |
| 13 | 13 | */ |
| 14 | 14 | @Data |
| 15 | -public class ThingModelInputOutputParam { | |
| 15 | +public class ThingModelParam { | |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * 参数标识符 |
| ... | ... | @@ -25,7 +25,7 @@ public class ThingModelInputOutputParam { |
| 25 | 25 | /** |
| 26 | 26 | * 用于区分输入或输出参数 |
| 27 | 27 | * |
| 28 | - * 关联枚举 {@link IotProductThingModelParamDirectionEnum} | |
| 28 | + * 关联枚举 {@link IotThingModelParamDirectionEnum} | |
| 29 | 29 | */ |
| 30 | 30 | private String direction; |
| 31 | 31 | /** | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelProperty.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType.ThingModelDataSpecs; |
| 4 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelAccessModeEnum; | |
| 4 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelAccessModeEnum; | |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | |
| 7 | 7 | import java.util.List; |
| ... | ... | @@ -27,7 +27,7 @@ public class ThingModelProperty { |
| 27 | 27 | /** |
| 28 | 28 | * 云端可以对该属性进行的操作类型 |
| 29 | 29 | * |
| 30 | - * 枚举 {@link IotProductThingModelAccessModeEnum} | |
| 30 | + * 枚举 {@link IotThingModelAccessModeEnum} | |
| 31 | 31 | */ |
| 32 | 32 | private String accessMode; |
| 33 | 33 | /** | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelService.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelServiceCallTypeEnum; | |
| 3 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelServiceCallTypeEnum; | |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | 6 | import java.util.List; |
| ... | ... | @@ -31,7 +31,7 @@ public class ThingModelService { |
| 31 | 31 | /** |
| 32 | 32 | * 调用类型 |
| 33 | 33 | * |
| 34 | - * 关联枚举 {@link IotProductThingModelServiceCallTypeEnum} | |
| 34 | + * 关联枚举 {@link IotThingModelServiceCallTypeEnum} | |
| 35 | 35 | */ |
| 36 | 36 | private String callType; |
| 37 | 37 | /** |
| ... | ... | @@ -39,13 +39,13 @@ public class ThingModelService { |
| 39 | 39 | * |
| 40 | 40 | * 输入参数定义服务调用时所需提供的信息,用于控制设备行为或执行特定任务 |
| 41 | 41 | */ |
| 42 | - private List<ThingModelInputOutputParam> inputParams; | |
| 42 | + private List<ThingModelParam> inputParams; | |
| 43 | 43 | /** |
| 44 | 44 | * 服务的输出参数 |
| 45 | 45 | * |
| 46 | 46 | * 输出参数定义服务调用后返回的结果或反馈信息,用于确认操作结果或提供额外的信息。 |
| 47 | 47 | */ |
| 48 | - private List<ThingModelInputOutputParam> outputParams; | |
| 48 | + private List<ThingModelParam> outputParams; | |
| 49 | 49 | /** |
| 50 | 50 | * 标识设备需要执行的具体操作 |
| 51 | 51 | */ | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/dataType/ThingModelStructDataSpecs.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelAccessModeEnum; | |
| 3 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelAccessModeEnum; | |
| 4 | 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | import lombok.EqualsAndHashCode; |
| ... | ... | @@ -27,7 +27,7 @@ public class ThingModelStructDataSpecs extends ThingModelDataSpecs { |
| 27 | 27 | private String name; |
| 28 | 28 | /** |
| 29 | 29 | * 云端可以对该属性进行的操作类型 |
| 30 | - * 关联枚举 {@link IotProductThingModelAccessModeEnum} | |
| 30 | + * 关联枚举 {@link IotThingModelAccessModeEnum} | |
| 31 | 31 | */ |
| 32 | 32 | private String accessMode; |
| 33 | 33 | /** | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/vo/IotProductThingModelPageReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/vo/IotThingModelPageReqVO.java
| ... | ... | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 5 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 5 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; | |
| 6 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 7 | 7 | import jakarta.validation.constraints.NotNull; |
| 8 | 8 | import lombok.Data; |
| ... | ... | @@ -13,7 +13,7 @@ import lombok.ToString; |
| 13 | 13 | @Data |
| 14 | 14 | @EqualsAndHashCode(callSuper = true) |
| 15 | 15 | @ToString(callSuper = true) |
| 16 | -public class IotProductThingModelPageReqVO extends PageParam { | |
| 16 | +public class IotThingModelPageReqVO extends PageParam { | |
| 17 | 17 | |
| 18 | 18 | @Schema(description = "功能标识") |
| 19 | 19 | private String identifier; |
| ... | ... | @@ -22,7 +22,7 @@ public class IotProductThingModelPageReqVO extends PageParam { |
| 22 | 22 | private String name; |
| 23 | 23 | |
| 24 | 24 | @Schema(description = "功能类型", example = "1") |
| 25 | - @InEnum(IotProductThingModelTypeEnum.class) | |
| 25 | + @InEnum(IotThingModelTypeEnum.class) | |
| 26 | 26 | private Integer type; |
| 27 | 27 | |
| 28 | 28 | @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED) | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/vo/IotProductThingModelRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/vo/IotThingModelRespVO.java
| ... | ... | @@ -13,7 +13,7 @@ import java.time.LocalDateTime; |
| 13 | 13 | @Schema(description = "管理后台 - IoT 产品物模型 Response VO") |
| 14 | 14 | @Data |
| 15 | 15 | @ExcelIgnoreUnannotated |
| 16 | -public class IotProductThingModelRespVO { | |
| 16 | +public class IotThingModelRespVO { | |
| 17 | 17 | |
| 18 | 18 | @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21816") |
| 19 | 19 | @ExcelProperty("产品ID") | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/vo/IotProductThingModelSaveReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/vo/IotThingModelSaveReqVO.java
| ... | ... | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 4 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelEvent; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelProperty; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelService; |
| 7 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 7 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; | |
| 8 | 8 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | 9 | import jakarta.validation.constraints.NotEmpty; |
| 10 | 10 | import jakarta.validation.constraints.NotNull; |
| ... | ... | @@ -12,7 +12,7 @@ import lombok.Data; |
| 12 | 12 | |
| 13 | 13 | @Schema(description = "管理后台 - IoT 产品物模型新增/修改 Request VO") |
| 14 | 14 | @Data |
| 15 | -public class IotProductThingModelSaveReqVO { | |
| 15 | +public class IotThingModelSaveReqVO { | |
| 16 | 16 | |
| 17 | 17 | @Schema(description = "编号", example = "1") |
| 18 | 18 | private Long id; |
| ... | ... | @@ -38,7 +38,7 @@ public class IotProductThingModelSaveReqVO { |
| 38 | 38 | |
| 39 | 39 | @Schema(description = "功能类型", requiredMode = Schema.RequiredMode.REQUIRED) |
| 40 | 40 | @NotNull(message = "功能类型不能为空") |
| 41 | - @InEnum(IotProductThingModelTypeEnum.class) | |
| 41 | + @InEnum(IotThingModelTypeEnum.class) | |
| 42 | 42 | private Integer type; |
| 43 | 43 | |
| 44 | 44 | @Schema(description = "属性", requiredMode = Schema.RequiredMode.REQUIRED) | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/thingmodel/IotProductThingModelConvert.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/thingmodel/IotThingModelConvert.java
| ... | ... | @@ -3,10 +3,10 @@ package cn.iocoder.yudao.module.iot.convert.thingmodel; |
| 3 | 3 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelEvent; |
| 4 | 4 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelProperty; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelService; |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelRespVO; | |
| 7 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelSaveReqVO; | |
| 8 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO; | |
| 9 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelRespVO; | |
| 7 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelSaveReqVO; | |
| 8 | +import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | |
| 9 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; | |
| 10 | 10 | import org.mapstruct.Mapper; |
| 11 | 11 | import org.mapstruct.Mapping; |
| 12 | 12 | import org.mapstruct.Named; |
| ... | ... | @@ -16,44 +16,44 @@ import java.util.List; |
| 16 | 16 | import java.util.Objects; |
| 17 | 17 | |
| 18 | 18 | @Mapper |
| 19 | -public interface IotProductThingModelConvert { | |
| 19 | +public interface IotThingModelConvert { | |
| 20 | 20 | |
| 21 | - IotProductThingModelConvert INSTANCE = Mappers.getMapper(IotProductThingModelConvert.class); | |
| 21 | + IotThingModelConvert INSTANCE = Mappers.getMapper(IotThingModelConvert.class); | |
| 22 | 22 | |
| 23 | 23 | // 将 SaveReqVO 转换为 DO |
| 24 | 24 | @Mapping(target = "property", expression = "java(convertToProperty(bean))") |
| 25 | 25 | @Mapping(target = "event", expression = "java(convertToEvent(bean))") |
| 26 | 26 | @Mapping(target = "service", expression = "java(convertToService(bean))") |
| 27 | - IotProductThingModelDO convert(IotProductThingModelSaveReqVO bean); | |
| 27 | + IotThingModelDO convert(IotThingModelSaveReqVO bean); | |
| 28 | 28 | |
| 29 | 29 | // 将 DO 转换为 RespVO |
| 30 | 30 | @Mapping(target = "property", source = "property") |
| 31 | 31 | @Mapping(target = "event", source = "event") |
| 32 | 32 | @Mapping(target = "service", source = "service") |
| 33 | - IotProductThingModelRespVO convert(IotProductThingModelDO bean); | |
| 33 | + IotThingModelRespVO convert(IotThingModelDO bean); | |
| 34 | 34 | |
| 35 | 35 | // 批量转换 |
| 36 | - List<IotProductThingModelRespVO> convertList(List<IotProductThingModelDO> list); | |
| 36 | + List<IotThingModelRespVO> convertList(List<IotThingModelDO> list); | |
| 37 | 37 | |
| 38 | 38 | @Named("convertToProperty") |
| 39 | - default ThingModelProperty convertToProperty(IotProductThingModelSaveReqVO bean) { | |
| 40 | - if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { | |
| 39 | + default ThingModelProperty convertToProperty(IotThingModelSaveReqVO bean) { | |
| 40 | + if (Objects.equals(bean.getType(), IotThingModelTypeEnum.PROPERTY.getType())) { | |
| 41 | 41 | return bean.getProperty(); |
| 42 | 42 | } |
| 43 | 43 | return null; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | @Named("convertToEvent") |
| 47 | - default ThingModelEvent convertToEvent(IotProductThingModelSaveReqVO bean) { | |
| 48 | - if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.EVENT.getType())) { | |
| 47 | + default ThingModelEvent convertToEvent(IotThingModelSaveReqVO bean) { | |
| 48 | + if (Objects.equals(bean.getType(), IotThingModelTypeEnum.EVENT.getType())) { | |
| 49 | 49 | return bean.getEvent(); |
| 50 | 50 | } |
| 51 | 51 | return null; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | @Named("convertToService") |
| 55 | - default ThingModelService convertToService(IotProductThingModelSaveReqVO bean) { | |
| 56 | - if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.SERVICE.getType())) { | |
| 55 | + default ThingModelService convertToService(IotThingModelSaveReqVO bean) { | |
| 56 | + if (Objects.equals(bean.getType(), IotThingModelTypeEnum.SERVICE.getType())) { | |
| 57 | 57 | return bean.getService(); |
| 58 | 58 | } |
| 59 | 59 | return null; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/device/IotDeviceDataDO.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.dal.dataobject.device; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 4 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO; | |
| 4 | +import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | |
| 5 | 5 | import lombok.AllArgsConstructor; |
| 6 | 6 | import lombok.Builder; |
| 7 | 7 | import lombok.Data; |
| ... | ... | @@ -30,7 +30,7 @@ public class IotDeviceDataDO { |
| 30 | 30 | /** |
| 31 | 31 | * 物模型编号 |
| 32 | 32 | * <p> |
| 33 | - * 关联 {@link IotProductThingModelDO#getId()} | |
| 33 | + * 关联 {@link IotThingModelDO#getId()} | |
| 34 | 34 | */ |
| 35 | 35 | private Long thingModelId; |
| 36 | 36 | |
| ... | ... | @@ -51,21 +51,21 @@ public class IotDeviceDataDO { |
| 51 | 51 | /** |
| 52 | 52 | * 属性标识符 |
| 53 | 53 | * <p> |
| 54 | - * 关联 {@link IotProductThingModelDO#getIdentifier()} | |
| 54 | + * 关联 {@link IotThingModelDO#getIdentifier()} | |
| 55 | 55 | */ |
| 56 | 56 | private String identifier; |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * 属性名称 |
| 60 | 60 | * <p> |
| 61 | - * 关联 {@link IotProductThingModelDO#getName()} | |
| 61 | + * 关联 {@link IotThingModelDO#getName()} | |
| 62 | 62 | */ |
| 63 | 63 | private String name; |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * 数据类型 |
| 67 | 67 | * <p> |
| 68 | - * 关联 {@link IotProductThingModelDO#getProperty()#getDataType()} | |
| 68 | + * 关联 {@link IotThingModelDO#getProperty()#getDataType()} | |
| 69 | 69 | */ |
| 70 | 70 | private String dataType; |
| 71 | 71 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/thingmodel/IotProductThingModelDO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/thingmodel/IotThingModelDO.java
| ... | ... | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelE |
| 5 | 5 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelProperty; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelService; |
| 7 | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 8 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 8 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; | |
| 9 | 9 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 10 | 10 | import com.baomidou.mybatisplus.annotation.TableField; |
| 11 | 11 | import com.baomidou.mybatisplus.annotation.TableId; |
| ... | ... | @@ -16,21 +16,20 @@ import lombok.Builder; |
| 16 | 16 | import lombok.Data; |
| 17 | 17 | import lombok.NoArgsConstructor; |
| 18 | 18 | |
| 19 | -// TODO @huihui:IotProductThingModelDO => IotThingModelDO | |
| 20 | 19 | /** |
| 21 | 20 | * IoT 产品物模型功能 DO |
| 22 | 21 | * <p> |
| 23 | - * 每个 {@link IotProductDO} 和 {@link IotProductThingModelDO} 是“一对多”的关系,它的每个属性、事件、服务都对应一条记录 | |
| 22 | + * 每个 {@link IotProductDO} 和 {@link IotThingModelDO} 是“一对多”的关系,它的每个属性、事件、服务都对应一条记录 | |
| 24 | 23 | * |
| 25 | 24 | * @author 芋道源码 |
| 26 | 25 | */ |
| 27 | -@TableName(value = "iot_product_thing_model", autoResultMap = true) | |
| 28 | -@KeySequence("iot_product_thing_model_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 26 | +@TableName(value = "iot_thing_model", autoResultMap = true) | |
| 27 | +@KeySequence("iot_thing_model_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 29 | 28 | @Data |
| 30 | 29 | @Builder |
| 31 | 30 | @NoArgsConstructor |
| 32 | 31 | @AllArgsConstructor |
| 33 | -public class IotProductThingModelDO extends BaseDO { | |
| 32 | +public class IotThingModelDO extends BaseDO { | |
| 34 | 33 | |
| 35 | 34 | /** |
| 36 | 35 | * 物模型功能编号 |
| ... | ... | @@ -67,7 +66,7 @@ public class IotProductThingModelDO extends BaseDO { |
| 67 | 66 | /** |
| 68 | 67 | * 功能类型 |
| 69 | 68 | * <p> |
| 70 | - * 枚举 {@link IotProductThingModelTypeEnum} | |
| 69 | + * 枚举 {@link IotThingModelTypeEnum} | |
| 71 | 70 | */ |
| 72 | 71 | private Integer type; |
| 73 | 72 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/thingmodel/IotProductThingModelMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.dal.mysql.thingmodel; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelPageReqVO; | |
| 7 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO; | |
| 8 | -import org.apache.ibatis.annotations.Mapper; | |
| 9 | - | |
| 10 | -import java.util.List; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * IoT 产品物模型 Mapper | |
| 14 | - * | |
| 15 | - * @author 芋道源码 | |
| 16 | - */ | |
| 17 | -@Mapper | |
| 18 | -public interface IotProductThingModelMapper extends BaseMapperX<IotProductThingModelDO> { | |
| 19 | - | |
| 20 | - default PageResult<IotProductThingModelDO> selectPage(IotProductThingModelPageReqVO reqVO) { | |
| 21 | - return selectPage(reqVO, new LambdaQueryWrapperX<IotProductThingModelDO>() | |
| 22 | - .eqIfPresent(IotProductThingModelDO::getIdentifier, reqVO.getIdentifier()) | |
| 23 | - .likeIfPresent(IotProductThingModelDO::getName, reqVO.getName()) | |
| 24 | - .eqIfPresent(IotProductThingModelDO::getType, reqVO.getType()) | |
| 25 | - .eqIfPresent(IotProductThingModelDO::getProductId, reqVO.getProductId()) | |
| 26 | - .notIn(IotProductThingModelDO::getIdentifier, "get", "set", "post") | |
| 27 | - .orderByDesc(IotProductThingModelDO::getId)); | |
| 28 | - } | |
| 29 | - | |
| 30 | - default IotProductThingModelDO selectByProductIdAndIdentifier(Long productId, String identifier) { | |
| 31 | - return selectOne(IotProductThingModelDO::getProductId, productId, | |
| 32 | - IotProductThingModelDO::getIdentifier, identifier); | |
| 33 | - } | |
| 34 | - | |
| 35 | - default List<IotProductThingModelDO> selectListByProductId(Long productId) { | |
| 36 | - return selectList(IotProductThingModelDO::getProductId, productId); | |
| 37 | - } | |
| 38 | - | |
| 39 | - default List<IotProductThingModelDO> selectListByProductIdAndType(Long productId, Integer type) { | |
| 40 | - return selectList(IotProductThingModelDO::getProductId, productId, | |
| 41 | - IotProductThingModelDO::getType, type); | |
| 42 | - } | |
| 43 | - | |
| 44 | - default List<IotProductThingModelDO> selectListByProductIdAndIdentifiersAndTypes(Long productId, | |
| 45 | - List<String> identifiers, | |
| 46 | - List<Integer> types) { | |
| 47 | - return selectList(new LambdaQueryWrapperX<IotProductThingModelDO>() | |
| 48 | - .eq(IotProductThingModelDO::getProductId, productId) | |
| 49 | - .in(IotProductThingModelDO::getIdentifier, identifiers) | |
| 50 | - .in(IotProductThingModelDO::getType, types)); | |
| 51 | - } | |
| 52 | - | |
| 53 | - default IotProductThingModelDO selectByProductIdAndName(Long productId, String name) { | |
| 54 | - return selectOne(IotProductThingModelDO::getProductId, productId, | |
| 55 | - IotProductThingModelDO::getName, name); | |
| 56 | - } | |
| 57 | - | |
| 58 | - default List<IotProductThingModelDO> selectListByProductKey(String productKey) { | |
| 59 | - return selectList(IotProductThingModelDO::getProductKey, productKey); | |
| 60 | - } | |
| 61 | - | |
| 62 | -} | |
| 63 | 0 | \ No newline at end of file |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/thingmodel/IotThingModelMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.dal.mysql.thingmodel; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * IoT 产品物模型 Mapper | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface IotThingModelMapper extends BaseMapperX<IotThingModelDO> { | |
| 19 | + | |
| 20 | + default PageResult<IotThingModelDO> selectPage(IotThingModelPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<IotThingModelDO>() | |
| 22 | + .eqIfPresent(IotThingModelDO::getIdentifier, reqVO.getIdentifier()) | |
| 23 | + .likeIfPresent(IotThingModelDO::getName, reqVO.getName()) | |
| 24 | + .eqIfPresent(IotThingModelDO::getType, reqVO.getType()) | |
| 25 | + .eqIfPresent(IotThingModelDO::getProductId, reqVO.getProductId()) | |
| 26 | + .notIn(IotThingModelDO::getIdentifier, "get", "set", "post") | |
| 27 | + .orderByDesc(IotThingModelDO::getId)); | |
| 28 | + } | |
| 29 | + | |
| 30 | + default IotThingModelDO selectByProductIdAndIdentifier(Long productId, String identifier) { | |
| 31 | + return selectOne(IotThingModelDO::getProductId, productId, | |
| 32 | + IotThingModelDO::getIdentifier, identifier); | |
| 33 | + } | |
| 34 | + | |
| 35 | + default List<IotThingModelDO> selectListByProductId(Long productId) { | |
| 36 | + return selectList(IotThingModelDO::getProductId, productId); | |
| 37 | + } | |
| 38 | + | |
| 39 | + default List<IotThingModelDO> selectListByProductIdAndType(Long productId, Integer type) { | |
| 40 | + return selectList(IotThingModelDO::getProductId, productId, | |
| 41 | + IotThingModelDO::getType, type); | |
| 42 | + } | |
| 43 | + | |
| 44 | + default List<IotThingModelDO> selectListByProductIdAndIdentifiersAndTypes(Long productId, | |
| 45 | + List<String> identifiers, | |
| 46 | + List<Integer> types) { | |
| 47 | + return selectList(new LambdaQueryWrapperX<IotThingModelDO>() | |
| 48 | + .eq(IotThingModelDO::getProductId, productId) | |
| 49 | + .in(IotThingModelDO::getIdentifier, identifiers) | |
| 50 | + .in(IotThingModelDO::getType, types)); | |
| 51 | + } | |
| 52 | + | |
| 53 | + default IotThingModelDO selectByProductIdAndName(Long productId, String name) { | |
| 54 | + return selectOne(IotThingModelDO::getProductId, productId, | |
| 55 | + IotThingModelDO::getName, name); | |
| 56 | + } | |
| 57 | + | |
| 58 | + default List<IotThingModelDO> selectListByProductKey(String productKey) { | |
| 59 | + return selectList(IotThingModelDO::getProductKey, productKey); | |
| 60 | + } | |
| 61 | + | |
| 62 | +} | |
| 0 | 63 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDevicePropertyDataServiceImpl.java
| ... | ... | @@ -13,17 +13,17 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO; |
| 13 | 13 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 14 | 14 | import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.SelectVisualDO; |
| 15 | 15 | import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage; |
| 16 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO; | |
| 16 | +import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | |
| 17 | 17 | import cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyDataMapper; |
| 18 | 18 | import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; |
| 19 | 19 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; |
| 20 | 20 | import cn.iocoder.yudao.module.iot.enums.IotConstants; |
| 21 | 21 | import cn.iocoder.yudao.module.iot.enums.thingmodel.IotDataSpecsDataTypeEnum; |
| 22 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 22 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; | |
| 23 | 23 | import cn.iocoder.yudao.module.iot.framework.tdengine.core.TDengineTableField; |
| 24 | 24 | import cn.iocoder.yudao.module.iot.service.product.IotProductService; |
| 25 | 25 | import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService; |
| 26 | -import cn.iocoder.yudao.module.iot.service.thingmodel.IotProductThingModelService; | |
| 26 | +import cn.iocoder.yudao.module.iot.service.thingmodel.IotThingModelService; | |
| 27 | 27 | import jakarta.annotation.Resource; |
| 28 | 28 | import jakarta.validation.Valid; |
| 29 | 29 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -71,7 +71,7 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe |
| 71 | 71 | @Resource |
| 72 | 72 | private IotThingModelMessageService thingModelMessageService; |
| 73 | 73 | @Resource |
| 74 | - private IotProductThingModelService thingModelService; | |
| 74 | + private IotThingModelService thingModelService; | |
| 75 | 75 | @Resource |
| 76 | 76 | private IotProductService productService; |
| 77 | 77 | |
| ... | ... | @@ -88,8 +88,8 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe |
| 88 | 88 | public void defineDevicePropertyData(Long productId) { |
| 89 | 89 | // 1.1 查询产品和物模型 |
| 90 | 90 | IotProductDO product = productService.validateProductExists(productId); |
| 91 | - List<IotProductThingModelDO> thingModels = filterList(thingModelService.getProductThingModelListByProductId(productId), | |
| 92 | - thingModel -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(thingModel.getType())); | |
| 91 | + List<IotThingModelDO> thingModels = filterList(thingModelService.getThingModelListByProductId(productId), | |
| 92 | + thingModel -> IotThingModelTypeEnum.PROPERTY.getType().equals(thingModel.getType())); | |
| 93 | 93 | // 1.2 解析 DB 里的字段 |
| 94 | 94 | List<TDengineTableField> oldFields = new ArrayList<>(); |
| 95 | 95 | try { |
| ... | ... | @@ -115,7 +115,7 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe |
| 115 | 115 | devicePropertyDataMapper.alterProductPropertySTable(product.getProductKey(), oldFields, newFields); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - private List<TDengineTableField> buildTableFieldList(List<IotProductThingModelDO> thingModels) { | |
| 118 | + private List<TDengineTableField> buildTableFieldList(List<IotThingModelDO> thingModels) { | |
| 119 | 119 | return convertList(thingModels, thingModel -> { |
| 120 | 120 | TDengineTableField field = new TDengineTableField( |
| 121 | 121 | StrUtil.toUnderlineCase(thingModel.getIdentifier()), // TDengine 字段默认都是小写 |
| ... | ... | @@ -153,8 +153,8 @@ public class IotDevicePropertyDataServiceImpl implements IotDevicePropertyDataSe |
| 153 | 153 | // 1. 获取设备信息 |
| 154 | 154 | IotDeviceDO device = deviceService.getDevice(deviceDataReqVO.getDeviceId()); |
| 155 | 155 | // 2. 获取设备属性最新数据 |
| 156 | - List<IotProductThingModelDO> thingModelList = thingModelService.getProductThingModelListByProductKey(device.getProductKey()); | |
| 157 | - thingModelList = filterList(thingModelList, thingModel -> IotProductThingModelTypeEnum.PROPERTY.getType() | |
| 156 | + List<IotThingModelDO> thingModelList = thingModelService.getProductThingModelListByProductKey(device.getProductKey()); | |
| 157 | + thingModelList = filterList(thingModelList, thingModel -> IotThingModelTypeEnum.PROPERTY.getType() | |
| 158 | 158 | .equals(thingModel.getType())); |
| 159 | 159 | |
| 160 | 160 | // 3. 过滤标识符和属性名称 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageServiceImpl.java
| ... | ... | @@ -11,16 +11,16 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser; |
| 11 | 11 | import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO; |
| 12 | 12 | import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO; |
| 13 | 13 | import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage; |
| 14 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO; | |
| 14 | +import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | |
| 15 | 15 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 16 | 16 | import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; |
| 17 | 17 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper; |
| 18 | 18 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; |
| 19 | 19 | import cn.iocoder.yudao.module.iot.enums.IotConstants; |
| 20 | 20 | import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStatusEnum; |
| 21 | -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 21 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotThingModelTypeEnum; | |
| 22 | 22 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; |
| 23 | -import cn.iocoder.yudao.module.iot.service.thingmodel.IotProductThingModelService; | |
| 23 | +import cn.iocoder.yudao.module.iot.service.thingmodel.IotThingModelService; | |
| 24 | 24 | import cn.iocoder.yudao.module.iot.service.product.IotProductService; |
| 25 | 25 | import cn.iocoder.yudao.module.iot.util.IotTdDatabaseUtils; |
| 26 | 26 | import jakarta.annotation.Resource; |
| ... | ... | @@ -52,7 +52,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ |
| 52 | 52 | private String url; |
| 53 | 53 | |
| 54 | 54 | @Resource |
| 55 | - private IotProductThingModelService iotProductThingModelService; | |
| 55 | + private IotThingModelService iotThingModelService; | |
| 56 | 56 | @Resource |
| 57 | 57 | private IotDeviceService iotDeviceService; |
| 58 | 58 | @Resource |
| ... | ... | @@ -83,7 +83,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ |
| 83 | 83 | |
| 84 | 84 | // 2. 获取设备属性并进行物模型校验,过滤非物模型属性 |
| 85 | 85 | Map<String, Object> params = thingModelMessage.dataToMap(); |
| 86 | - List<IotProductThingModelDO> thingModelList = getValidThingModelList(thingModelMessage.getProductKey()); | |
| 86 | + List<IotThingModelDO> thingModelList = getValidThingModelList(thingModelMessage.getProductKey()); | |
| 87 | 87 | if (thingModelList.isEmpty()) { |
| 88 | 88 | return; |
| 89 | 89 | } |
| ... | ... | @@ -102,9 +102,9 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ |
| 102 | 102 | .build()); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - private List<IotProductThingModelDO> getValidThingModelList(String productKey) { | |
| 106 | - return filterList(iotProductThingModelService.getProductThingModelListByProductKey(productKey), | |
| 107 | - thingModel -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(thingModel.getType())); | |
| 105 | + private List<IotThingModelDO> getValidThingModelList(String productKey) { | |
| 106 | + return filterList(iotThingModelService.getProductThingModelListByProductKey(productKey), | |
| 107 | + thingModel -> IotThingModelTypeEnum.PROPERTY.getType().equals(thingModel.getType())); | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | @Override |
| ... | ... | @@ -134,17 +134,17 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ |
| 134 | 134 | tdEngineDDLMapper.createSuperTable(new TdTableDO(databaseName, superTableName, schemaFields, tagsFields)); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - private List<IotProductThingModelDO> getValidFunctionList(String productKey) { | |
| 138 | - return filterList(iotProductThingModelService.getProductThingModelListByProductKey(productKey), | |
| 139 | - thingModel -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(thingModel.getType())); | |
| 137 | + private List<IotThingModelDO> getValidFunctionList(String productKey) { | |
| 138 | + return filterList(iotThingModelService.getProductThingModelListByProductKey(productKey), | |
| 139 | + thingModel -> IotThingModelTypeEnum.PROPERTY.getType().equals(thingModel.getType())); | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - private List<TdFieldDO> filterAndCollectValidFields(Map<String, Object> params, List<IotProductThingModelDO> thingModelList, IotDeviceDO device, Long time) { | |
| 142 | + private List<TdFieldDO> filterAndCollectValidFields(Map<String, Object> params, List<IotThingModelDO> thingModelList, IotDeviceDO device, Long time) { | |
| 143 | 143 | // 1. 获取属性标识符集合 |
| 144 | - Set<String> propertyIdentifiers = convertSet(thingModelList, IotProductThingModelDO::getIdentifier); | |
| 144 | + Set<String> propertyIdentifiers = convertSet(thingModelList, IotThingModelDO::getIdentifier); | |
| 145 | 145 | |
| 146 | 146 | // 2. 构建属性标识符和属性的映射 |
| 147 | - Map<String, IotProductThingModelDO> thingModelMap = convertMap(thingModelList, IotProductThingModelDO::getIdentifier); | |
| 147 | + Map<String, IotThingModelDO> thingModelMap = convertMap(thingModelList, IotThingModelDO::getIdentifier); | |
| 148 | 148 | |
| 149 | 149 | // 3. 过滤并收集有效的属性字段 |
| 150 | 150 | List<TdFieldDO> schemaFieldValues = new ArrayList<>(); |
| ... | ... | @@ -164,21 +164,21 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ |
| 164 | 164 | * 缓存设备属性 |
| 165 | 165 | * |
| 166 | 166 | * @param device 设备信息 |
| 167 | - * @param iotProductThingModelDO 物模型属性 | |
| 167 | + * @param iotThingModelDO 物模型属性 | |
| 168 | 168 | * @param val 属性值 |
| 169 | 169 | * @param time 时间 |
| 170 | 170 | */ |
| 171 | - private void setDeviceDataCache(IotDeviceDO device, IotProductThingModelDO iotProductThingModelDO, Object val, Long time) { | |
| 171 | + private void setDeviceDataCache(IotDeviceDO device, IotThingModelDO iotThingModelDO, Object val, Long time) { | |
| 172 | 172 | IotDeviceDataDO deviceData = IotDeviceDataDO.builder() |
| 173 | 173 | .productKey(device.getProductKey()) |
| 174 | 174 | .deviceName(device.getDeviceName()) |
| 175 | - .identifier(iotProductThingModelDO.getIdentifier()) | |
| 175 | + .identifier(iotThingModelDO.getIdentifier()) | |
| 176 | 176 | .value(val != null ? val.toString() : null) |
| 177 | 177 | .updateTime(DateUtil.toLocalDateTime(new Date(time))) |
| 178 | 178 | .deviceId(device.getId()) |
| 179 | - .thingModelId(iotProductThingModelDO.getId()) | |
| 180 | - .name(iotProductThingModelDO.getName()) | |
| 181 | - .dataType(iotProductThingModelDO.getProperty().getDataType()) | |
| 179 | + .thingModelId(iotThingModelDO.getId()) | |
| 180 | + .name(iotThingModelDO.getName()) | |
| 181 | + .dataType(iotThingModelDO.getProperty().getDataType()) | |
| 182 | 182 | .build(); |
| 183 | 183 | deviceDataRedisDAO.set(deviceData); |
| 184 | 184 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thingmodel/IotProductThingModelService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thingmodel/IotThingModelService.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.thingmodel; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelPageReqVO; | |
| 5 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelSaveReqVO; | |
| 6 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO; | |
| 4 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | |
| 7 | 7 | import jakarta.validation.Valid; |
| 8 | 8 | |
| 9 | 9 | import java.util.List; |
| ... | ... | @@ -13,7 +13,7 @@ import java.util.List; |
| 13 | 13 | * |
| 14 | 14 | * @author 芋道源码 |
| 15 | 15 | */ |
| 16 | -public interface IotProductThingModelService { | |
| 16 | +public interface IotThingModelService { | |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * 创建产品物模型 |
| ... | ... | @@ -21,21 +21,21 @@ public interface IotProductThingModelService { |
| 21 | 21 | * @param createReqVO 创建信息 |
| 22 | 22 | * @return 编号 |
| 23 | 23 | */ |
| 24 | - Long createProductThingModel(@Valid IotProductThingModelSaveReqVO createReqVO); | |
| 24 | + Long createThingModel(@Valid IotThingModelSaveReqVO createReqVO); | |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * 更新产品物模型 |
| 28 | 28 | * |
| 29 | 29 | * @param updateReqVO 更新信息 |
| 30 | 30 | */ |
| 31 | - void updateProductThingModel(@Valid IotProductThingModelSaveReqVO updateReqVO); | |
| 31 | + void updateThingModel(@Valid IotThingModelSaveReqVO updateReqVO); | |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * 删除产品物模型 |
| 35 | 35 | * |
| 36 | 36 | * @param id 编号 |
| 37 | 37 | */ |
| 38 | - void deleteProductThingModel(Long id); | |
| 38 | + void deleteThingModel(Long id); | |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * 获得产品物模型 |
| ... | ... | @@ -43,7 +43,7 @@ public interface IotProductThingModelService { |
| 43 | 43 | * @param id 编号 |
| 44 | 44 | * @return 产品物模型 |
| 45 | 45 | */ |
| 46 | - IotProductThingModelDO getProductThingModel(Long id); | |
| 46 | + IotThingModelDO getThingModel(Long id); | |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * 获得产品物模型列表 |
| ... | ... | @@ -51,7 +51,7 @@ public interface IotProductThingModelService { |
| 51 | 51 | * @param productId 产品编号 |
| 52 | 52 | * @return 产品物模型列表 |
| 53 | 53 | */ |
| 54 | - List<IotProductThingModelDO> getProductThingModelListByProductId(Long productId); | |
| 54 | + List<IotThingModelDO> getThingModelListByProductId(Long productId); | |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * 获得产品物模型分页 |
| ... | ... | @@ -59,7 +59,7 @@ public interface IotProductThingModelService { |
| 59 | 59 | * @param pageReqVO 分页查询 |
| 60 | 60 | * @return 产品物模型分页 |
| 61 | 61 | */ |
| 62 | - PageResult<IotProductThingModelDO> getProductThingModelPage(IotProductThingModelPageReqVO pageReqVO); | |
| 62 | + PageResult<IotThingModelDO> getProductThingModelPage(IotThingModelPageReqVO pageReqVO); | |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * 获得产品物模型列表 |
| ... | ... | @@ -67,6 +67,6 @@ public interface IotProductThingModelService { |
| 67 | 67 | * @param productKey 产品 Key |
| 68 | 68 | * @return 产品物模型列表 |
| 69 | 69 | */ |
| 70 | - List<IotProductThingModelDO> getProductThingModelListByProductKey(String productKey); | |
| 70 | + List<IotThingModelDO> getProductThingModelListByProductKey(String productKey); | |
| 71 | 71 | |
| 72 | 72 | } |
| 73 | 73 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thingmodel/IotProductThingModelServiceImpl.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thingmodel/IotThingModelServiceImpl.java
| ... | ... | @@ -5,14 +5,14 @@ import cn.hutool.core.util.ObjectUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | 7 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelEvent; |
| 8 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelInputOutputParam; | |
| 8 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelParam; | |
| 9 | 9 | import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelService; |
| 10 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelPageReqVO; | |
| 11 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelSaveReqVO; | |
| 12 | -import cn.iocoder.yudao.module.iot.convert.thingmodel.IotProductThingModelConvert; | |
| 10 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelPageReqVO; | |
| 11 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelSaveReqVO; | |
| 12 | +import cn.iocoder.yudao.module.iot.convert.thingmodel.IotThingModelConvert; | |
| 13 | 13 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 14 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO; | |
| 15 | -import cn.iocoder.yudao.module.iot.dal.mysql.thingmodel.IotProductThingModelMapper; | |
| 14 | +import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO; | |
| 15 | +import cn.iocoder.yudao.module.iot.dal.mysql.thingmodel.IotThingModelMapper; | |
| 16 | 16 | import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum; |
| 17 | 17 | import cn.iocoder.yudao.module.iot.enums.thingmodel.*; |
| 18 | 18 | import cn.iocoder.yudao.module.iot.service.product.IotProductService; |
| ... | ... | @@ -36,17 +36,17 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*; |
| 36 | 36 | @Service |
| 37 | 37 | @Validated |
| 38 | 38 | @Slf4j |
| 39 | -public class IotProductThingModelServiceImpl implements IotProductThingModelService { | |
| 39 | +public class IotThingModelServiceImpl implements IotThingModelService { | |
| 40 | 40 | |
| 41 | 41 | @Resource |
| 42 | - private IotProductThingModelMapper productThingModelMapper; | |
| 42 | + private IotThingModelMapper thingModelMapper; | |
| 43 | 43 | |
| 44 | 44 | @Resource |
| 45 | 45 | private IotProductService productService; |
| 46 | 46 | |
| 47 | 47 | @Override |
| 48 | 48 | @Transactional(rollbackFor = Exception.class) |
| 49 | - public Long createProductThingModel(IotProductThingModelSaveReqVO createReqVO) { | |
| 49 | + public Long createThingModel(IotThingModelSaveReqVO createReqVO) { | |
| 50 | 50 | // 1. 校验功能标识符在同一产品下是否唯一 |
| 51 | 51 | validateIdentifierUnique(createReqVO.getProductId(), createReqVO.getIdentifier()); |
| 52 | 52 | |
| ... | ... | @@ -60,11 +60,11 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 60 | 60 | validateProductStatus(createReqVO.getProductId()); |
| 61 | 61 | |
| 62 | 62 | // 5. 插入数据库 |
| 63 | - IotProductThingModelDO thingModel = IotProductThingModelConvert.INSTANCE.convert(createReqVO); | |
| 64 | - productThingModelMapper.insert(thingModel); | |
| 63 | + IotThingModelDO thingModel = IotThingModelConvert.INSTANCE.convert(createReqVO); | |
| 64 | + thingModelMapper.insert(thingModel); | |
| 65 | 65 | |
| 66 | 66 | // 6. 如果创建的是属性,需要更新默认的事件和服务 |
| 67 | - if (Objects.equals(createReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { | |
| 67 | + if (Objects.equals(createReqVO.getType(), IotThingModelTypeEnum.PROPERTY.getType())) { | |
| 68 | 68 | createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey()); |
| 69 | 69 | } |
| 70 | 70 | // TODO @puhui999: 服务和事件的情况 method 怎么设置?在前端设置还是后端设置? |
| ... | ... | @@ -73,7 +73,7 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 73 | 73 | |
| 74 | 74 | @Override |
| 75 | 75 | @Transactional(rollbackFor = Exception.class) |
| 76 | - public void updateProductThingModel(IotProductThingModelSaveReqVO updateReqVO) { | |
| 76 | + public void updateThingModel(IotThingModelSaveReqVO updateReqVO) { | |
| 77 | 77 | // 1. 校验功能是否存在 |
| 78 | 78 | validateProductThingModelMapperExists(updateReqVO.getId()); |
| 79 | 79 | |
| ... | ... | @@ -84,20 +84,20 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 84 | 84 | validateProductStatus(updateReqVO.getProductId()); |
| 85 | 85 | |
| 86 | 86 | // 4. 更新数据库 |
| 87 | - IotProductThingModelDO thingModel = IotProductThingModelConvert.INSTANCE.convert(updateReqVO); | |
| 88 | - productThingModelMapper.updateById(thingModel); | |
| 87 | + IotThingModelDO thingModel = IotThingModelConvert.INSTANCE.convert(updateReqVO); | |
| 88 | + thingModelMapper.updateById(thingModel); | |
| 89 | 89 | |
| 90 | 90 | // 5. 如果更新的是属性,需要更新默认的事件和服务 |
| 91 | - if (Objects.equals(updateReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { | |
| 91 | + if (Objects.equals(updateReqVO.getType(), IotThingModelTypeEnum.PROPERTY.getType())) { | |
| 92 | 92 | createDefaultEventsAndServices(updateReqVO.getProductId(), updateReqVO.getProductKey()); |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | @Override |
| 97 | 97 | @Transactional(rollbackFor = Exception.class) |
| 98 | - public void deleteProductThingModel(Long id) { | |
| 98 | + public void deleteThingModel(Long id) { | |
| 99 | 99 | // 1. 校验功能是否存在 |
| 100 | - IotProductThingModelDO thingModel = productThingModelMapper.selectById(id); | |
| 100 | + IotThingModelDO thingModel = thingModelMapper.selectById(id); | |
| 101 | 101 | if (thingModel == null) { |
| 102 | 102 | throw exception(THING_MODEL_NOT_EXISTS); |
| 103 | 103 | } |
| ... | ... | @@ -106,32 +106,32 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 106 | 106 | validateProductStatus(thingModel.getProductId()); |
| 107 | 107 | |
| 108 | 108 | // 2. 删除功能 |
| 109 | - productThingModelMapper.deleteById(id); | |
| 109 | + thingModelMapper.deleteById(id); | |
| 110 | 110 | |
| 111 | 111 | // 3. 如果删除的是属性,需要更新默认的事件和服务 |
| 112 | - if (Objects.equals(thingModel.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { | |
| 112 | + if (Objects.equals(thingModel.getType(), IotThingModelTypeEnum.PROPERTY.getType())) { | |
| 113 | 113 | createDefaultEventsAndServices(thingModel.getProductId(), thingModel.getProductKey()); |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | @Override |
| 118 | - public IotProductThingModelDO getProductThingModel(Long id) { | |
| 119 | - return productThingModelMapper.selectById(id); | |
| 118 | + public IotThingModelDO getThingModel(Long id) { | |
| 119 | + return thingModelMapper.selectById(id); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | @Override |
| 123 | - public List<IotProductThingModelDO> getProductThingModelListByProductId(Long productId) { | |
| 124 | - return productThingModelMapper.selectListByProductId(productId); | |
| 123 | + public List<IotThingModelDO> getThingModelListByProductId(Long productId) { | |
| 124 | + return thingModelMapper.selectListByProductId(productId); | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | @Override |
| 128 | - public PageResult<IotProductThingModelDO> getProductThingModelPage(IotProductThingModelPageReqVO pageReqVO) { | |
| 129 | - return productThingModelMapper.selectPage(pageReqVO); | |
| 128 | + public PageResult<IotThingModelDO> getProductThingModelPage(IotThingModelPageReqVO pageReqVO) { | |
| 129 | + return thingModelMapper.selectPage(pageReqVO); | |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | @Override |
| 133 | - public List<IotProductThingModelDO> getProductThingModelListByProductKey(String productKey) { | |
| 134 | - return productThingModelMapper.selectListByProductKey(productKey); | |
| 133 | + public List<IotThingModelDO> getProductThingModelListByProductKey(String productKey) { | |
| 134 | + return thingModelMapper.selectListByProductKey(productKey); | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
| ... | ... | @@ -140,13 +140,13 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 140 | 140 | * @param id 功能编号 |
| 141 | 141 | */ |
| 142 | 142 | private void validateProductThingModelMapperExists(Long id) { |
| 143 | - if (productThingModelMapper.selectById(id) == null) { | |
| 143 | + if (thingModelMapper.selectById(id) == null) { | |
| 144 | 144 | throw exception(THING_MODEL_NOT_EXISTS); |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | private void validateIdentifierUniqueForUpdate(Long id, Long productId, String identifier) { |
| 149 | - IotProductThingModelDO thingModel = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier); | |
| 149 | + IotThingModelDO thingModel = thingModelMapper.selectByProductIdAndIdentifier(productId, identifier); | |
| 150 | 150 | if (thingModel != null && ObjectUtil.notEqual(thingModel.getId(), id)) { |
| 151 | 151 | throw exception(THING_MODEL_IDENTIFIER_EXISTS); |
| 152 | 152 | } |
| ... | ... | @@ -167,14 +167,14 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | private void validateNameUnique(Long productId, String name) { |
| 170 | - IotProductThingModelDO thingModel = productThingModelMapper.selectByProductIdAndName(productId, name); | |
| 170 | + IotThingModelDO thingModel = thingModelMapper.selectByProductIdAndName(productId, name); | |
| 171 | 171 | if (thingModel != null) { |
| 172 | 172 | throw exception(THING_MODEL_NAME_EXISTS); |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | private void validateIdentifierUnique(Long productId, String identifier) { |
| 177 | - IotProductThingModelDO thingModel = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier); | |
| 177 | + IotThingModelDO thingModel = thingModelMapper.selectByProductIdAndIdentifier(productId, identifier); | |
| 178 | 178 | if (thingModel != null) { |
| 179 | 179 | throw exception(THING_MODEL_IDENTIFIER_EXISTS); |
| 180 | 180 | } |
| ... | ... | @@ -185,11 +185,11 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 185 | 185 | */ |
| 186 | 186 | public void createDefaultEventsAndServices(Long productId, String productKey) { |
| 187 | 187 | // 1. 获取当前属性列表 |
| 188 | - List<IotProductThingModelDO> propertyList = productThingModelMapper | |
| 189 | - .selectListByProductIdAndType(productId, IotProductThingModelTypeEnum.PROPERTY.getType()); | |
| 188 | + List<IotThingModelDO> propertyList = thingModelMapper | |
| 189 | + .selectListByProductIdAndType(productId, IotThingModelTypeEnum.PROPERTY.getType()); | |
| 190 | 190 | |
| 191 | 191 | // 2. 生成新的事件和服务列表 |
| 192 | - List<IotProductThingModelDO> newThingModelList = new ArrayList<>(); | |
| 192 | + List<IotThingModelDO> newThingModelList = new ArrayList<>(); | |
| 193 | 193 | // 2.1 生成属性上报事件 |
| 194 | 194 | ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList); |
| 195 | 195 | if (propertyPostEvent != null) { |
| ... | ... | @@ -207,10 +207,10 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // 3.1 获取数据库中的默认的旧事件和服务列表 |
| 210 | - List<IotProductThingModelDO> oldThingModelList = productThingModelMapper.selectListByProductIdAndIdentifiersAndTypes( | |
| 210 | + List<IotThingModelDO> oldThingModelList = thingModelMapper.selectListByProductIdAndIdentifiersAndTypes( | |
| 211 | 211 | productId, |
| 212 | 212 | Arrays.asList("post", "set", "get"), |
| 213 | - Arrays.asList(IotProductThingModelTypeEnum.EVENT.getType(), IotProductThingModelTypeEnum.SERVICE.getType()) | |
| 213 | + Arrays.asList(IotThingModelTypeEnum.EVENT.getType(), IotThingModelTypeEnum.SERVICE.getType()) | |
| 214 | 214 | ); |
| 215 | 215 | // 3.2 创建默认的事件和服务 |
| 216 | 216 | createDefaultEventsAndServices(oldThingModelList, newThingModelList); |
| ... | ... | @@ -219,9 +219,9 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 219 | 219 | /** |
| 220 | 220 | * 创建默认的事件和服务 |
| 221 | 221 | */ |
| 222 | - private void createDefaultEventsAndServices(List<IotProductThingModelDO> oldThingModelList, List<IotProductThingModelDO> newThingModelList) { | |
| 222 | + private void createDefaultEventsAndServices(List<IotThingModelDO> oldThingModelList, List<IotThingModelDO> newThingModelList) { | |
| 223 | 223 | // 1.1 使用 diffList 方法比较新旧列表 |
| 224 | - List<List<IotProductThingModelDO>> diffResult = diffList(oldThingModelList, newThingModelList, | |
| 224 | + List<List<IotThingModelDO>> diffResult = diffList(oldThingModelList, newThingModelList, | |
| 225 | 225 | (oldVal, newVal) -> { |
| 226 | 226 | // 继续使用 identifier 和 type 进行比较:这样可以准确地匹配对应的功能对象。 |
| 227 | 227 | boolean same = Objects.equals(oldVal.getIdentifier(), newVal.getIdentifier()) |
| ... | ... | @@ -233,40 +233,40 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 233 | 233 | }); |
| 234 | 234 | // 1.2 批量添加、修改、删除 |
| 235 | 235 | if (CollUtil.isNotEmpty(diffResult.get(0))) { |
| 236 | - productThingModelMapper.insertBatch(diffResult.get(0)); | |
| 236 | + thingModelMapper.insertBatch(diffResult.get(0)); | |
| 237 | 237 | } |
| 238 | 238 | if (CollUtil.isNotEmpty(diffResult.get(1))) { |
| 239 | - productThingModelMapper.updateBatch(diffResult.get(1)); | |
| 239 | + thingModelMapper.updateBatch(diffResult.get(1)); | |
| 240 | 240 | } |
| 241 | 241 | if (CollUtil.isNotEmpty(diffResult.get(2))) { |
| 242 | - productThingModelMapper.deleteByIds(convertSet(diffResult.get(2), IotProductThingModelDO::getId)); | |
| 242 | + thingModelMapper.deleteByIds(convertSet(diffResult.get(2), IotThingModelDO::getId)); | |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
| 247 | 247 | * 构建事件功能对象 |
| 248 | 248 | */ |
| 249 | - private IotProductThingModelDO buildEventThingModelDO(Long productId, String productKey, ThingModelEvent event, | |
| 250 | - String description) { | |
| 251 | - return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey) | |
| 249 | + private IotThingModelDO buildEventThingModelDO(Long productId, String productKey, ThingModelEvent event, | |
| 250 | + String description) { | |
| 251 | + return new IotThingModelDO().setProductId(productId).setProductKey(productKey) | |
| 252 | 252 | .setIdentifier(event.getIdentifier()).setName(event.getName()).setDescription(description) |
| 253 | - .setType(IotProductThingModelTypeEnum.EVENT.getType()).setEvent(event); | |
| 253 | + .setType(IotThingModelTypeEnum.EVENT.getType()).setEvent(event); | |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
| 257 | 257 | * 构建服务功能对象 |
| 258 | 258 | */ |
| 259 | - private IotProductThingModelDO buildServiceThingModelDO(Long productId, String productKey, ThingModelService service, | |
| 260 | - String description) { | |
| 261 | - return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey) | |
| 259 | + private IotThingModelDO buildServiceThingModelDO(Long productId, String productKey, ThingModelService service, | |
| 260 | + String description) { | |
| 261 | + return new IotThingModelDO().setProductId(productId).setProductKey(productKey) | |
| 262 | 262 | .setIdentifier(service.getIdentifier()).setName(service.getName()).setDescription(description) |
| 263 | - .setType(IotProductThingModelTypeEnum.SERVICE.getType()).setService(service); | |
| 263 | + .setType(IotThingModelTypeEnum.SERVICE.getType()).setService(service); | |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
| 267 | 267 | * 生成属性上报事件 |
| 268 | 268 | */ |
| 269 | - private ThingModelEvent generatePropertyPostEvent(List<IotProductThingModelDO> thingModelList) { | |
| 269 | + private ThingModelEvent generatePropertyPostEvent(List<IotThingModelDO> thingModelList) { | |
| 270 | 270 | // 1.1 没有属性则不生成 |
| 271 | 271 | if (CollUtil.isEmpty(thingModelList)) { |
| 272 | 272 | return null; |
| ... | ... | @@ -274,17 +274,17 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 274 | 274 | |
| 275 | 275 | // 1.2 生成属性上报事件 |
| 276 | 276 | return new ThingModelEvent().setIdentifier("post").setName("属性上报").setMethod("thing.event.property.post") |
| 277 | - .setType(IotProductThingModelServiceEventTypeEnum.INFO.getType()) | |
| 278 | - .setOutputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.OUTPUT)); | |
| 277 | + .setType(IotThingModelServiceEventTypeEnum.INFO.getType()) | |
| 278 | + .setOutputParams(buildInputOutputParam(thingModelList, IotThingModelParamDirectionEnum.OUTPUT)); | |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * 生成属性设置服务 |
| 283 | 283 | */ |
| 284 | - private ThingModelService generatePropertySetService(List<IotProductThingModelDO> thingModelList) { | |
| 284 | + private ThingModelService generatePropertySetService(List<IotThingModelDO> thingModelList) { | |
| 285 | 285 | // 1.1 过滤出所有可写属性 |
| 286 | 286 | thingModelList = filterList(thingModelList, thingModel -> |
| 287 | - IotProductThingModelAccessModeEnum.READ_WRITE.getMode().equals(thingModel.getProperty().getAccessMode())); | |
| 287 | + IotThingModelAccessModeEnum.READ_WRITE.getMode().equals(thingModel.getProperty().getAccessMode())); | |
| 288 | 288 | // 1.2 没有可写属性则不生成 |
| 289 | 289 | if (CollUtil.isEmpty(thingModelList)) { |
| 290 | 290 | return null; |
| ... | ... | @@ -292,15 +292,15 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 292 | 292 | |
| 293 | 293 | // 2. 生成属性设置服务 |
| 294 | 294 | return new ThingModelService().setIdentifier("set").setName("属性设置").setMethod("thing.service.property.set") |
| 295 | - .setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType()) | |
| 296 | - .setInputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.INPUT)) | |
| 295 | + .setCallType(IotThingModelServiceCallTypeEnum.ASYNC.getType()) | |
| 296 | + .setInputParams(buildInputOutputParam(thingModelList, IotThingModelParamDirectionEnum.INPUT)) | |
| 297 | 297 | .setOutputParams(Collections.emptyList()); // 属性设置服务一般不需要输出参数 |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
| 301 | 301 | * 生成属性获取服务 |
| 302 | 302 | */ |
| 303 | - private ThingModelService generatePropertyGetService(List<IotProductThingModelDO> thingModelList) { | |
| 303 | + private ThingModelService generatePropertyGetService(List<IotThingModelDO> thingModelList) { | |
| 304 | 304 | // 1.1 没有属性则不生成 |
| 305 | 305 | if (CollUtil.isEmpty(thingModelList)) { |
| 306 | 306 | return null; |
| ... | ... | @@ -308,9 +308,9 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 308 | 308 | |
| 309 | 309 | // 1.2 生成属性获取服务 |
| 310 | 310 | return new ThingModelService().setIdentifier("get").setName("属性获取").setMethod("thing.service.property.get") |
| 311 | - .setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType()) | |
| 312 | - .setInputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.INPUT)) | |
| 313 | - .setOutputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.OUTPUT)); | |
| 311 | + .setCallType(IotThingModelServiceCallTypeEnum.ASYNC.getType()) | |
| 312 | + .setInputParams(buildInputOutputParam(thingModelList, IotThingModelParamDirectionEnum.INPUT)) | |
| 313 | + .setOutputParams(buildInputOutputParam(thingModelList, IotThingModelParamDirectionEnum.OUTPUT)); | |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
| ... | ... | @@ -319,10 +319,10 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ |
| 319 | 319 | * @param thingModelList 属性列表 |
| 320 | 320 | * @return 输入/输出参数列表 |
| 321 | 321 | */ |
| 322 | - private List<ThingModelInputOutputParam> buildInputOutputParam(List<IotProductThingModelDO> thingModelList, | |
| 323 | - IotProductThingModelParamDirectionEnum directionEnum) { | |
| 322 | + private List<ThingModelParam> buildInputOutputParam(List<IotThingModelDO> thingModelList, | |
| 323 | + IotThingModelParamDirectionEnum directionEnum) { | |
| 324 | 324 | return convertList(thingModelList, thingModel -> |
| 325 | - BeanUtils.toBean(thingModel.getProperty(), ThingModelInputOutputParam.class).setParaOrder(0) // TODO @puhui999: 先搞个默认值看看怎么个事 | |
| 325 | + BeanUtils.toBean(thingModel.getProperty(), ThingModelParam.class).setParaOrder(0) // TODO @puhui999: 先搞个默认值看看怎么个事 | |
| 326 | 326 | .setDirection(directionEnum.getDirection())); |
| 327 | 327 | } |
| 328 | 328 | ... | ... |