diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index 07d144f537..bd0ad26bc4 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -622,7 +622,7 @@ ${xercesImpl.version} - + org.eclipse.paho org.eclipse.paho.client.mqttv3 diff --git a/yudao-module-iot/pom.xml b/yudao-module-iot/pom.xml index 96f8d181f4..069af1699b 100644 --- a/yudao-module-iot/pom.xml +++ b/yudao-module-iot/pom.xml @@ -19,6 +19,7 @@ ${project.artifactId} 物联网模块 + \ No newline at end of file diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/package-info.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/package-info.java index 65d0496363..7da0c665ba 100644 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/package-info.java +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/api/package-info.java @@ -1,4 +1,6 @@ /** - * iot API 包,定义暴露给其它模块的 API + * 占位 + * + * TODO 芋艿:后续删除 */ package cn.iocoder.yudao.module.iot.api; diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java index 4b0f15e058..8a1afa0709 100644 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java @@ -8,7 +8,9 @@ import java.util.Arrays; /** * 产品数据格式枚举类 - * 数据格式, 0: 标准数据格式(JSON), 1: 透传/自定义 + * + * @author ahh + * @see 阿里云 - 什么是消息解析 */ @AllArgsConstructor @Getter @@ -17,18 +19,17 @@ public enum IotDataFormatEnum implements IntArrayValuable { JSON(0, "标准数据格式(JSON)"), CUSTOMIZE(1, "透传/自定义"); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotDataFormatEnum::getType).toArray(); + /** * 类型 */ private final Integer type; - /** * 描述 */ private final String description; - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotDataFormatEnum::getType).toArray(); - @Override public int[] array() { return ARRAYS; diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java index aef8999bef..718e86d131 100644 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java @@ -8,7 +8,8 @@ import java.util.Arrays; /** * IOT 联网方式枚举类 - * 联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他 + * + * @author ahh */ @AllArgsConstructor @Getter @@ -19,19 +20,17 @@ public enum IotNetTypeEnum implements IntArrayValuable { ETHERNET(2, "Ethernet"), OTHER(3, "其他"); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotNetTypeEnum::getType).toArray(); /** * 类型 */ private final Integer type; - /** * 描述 */ private final String description; - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotNetTypeEnum::getType).toArray(); - @Override public int[] array() { return ARRAYS; diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java index 37ce0b5ad1..99b75f3fbd 100644 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java @@ -7,8 +7,9 @@ import lombok.Getter; import java.util.Arrays; /** - * IOT 产品设备类型 - * 设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备 + * IOT 产品的设备类型 + * + * @author ahh */ @AllArgsConstructor @Getter diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java index b10cee46f9..e64a3d6789 100644 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java @@ -4,9 +4,12 @@ import cn.iocoder.yudao.framework.common.core.IntArrayValuable; import lombok.AllArgsConstructor; import lombok.Getter; +import java.util.Arrays; + /** - * IOT 产品状态枚举类 - * 产品状态, 0: 开发中, 1: 已发布 + * IOT 产品的状态枚举类 + * + * @author ahh */ @AllArgsConstructor @Getter @@ -15,20 +18,20 @@ public enum IotProductStatusEnum implements IntArrayValuable { UNPUBLISHED(0, "开发中"), PUBLISHED(1, "已发布"); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductStatusEnum::getType).toArray(); + /** * 类型 */ private final Integer type; - /** * 描述 */ private final String description; - public static final int[] ARRAYS = {1, 2}; - @Override public int[] array() { return ARRAYS; } + } diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java index 64644b213d..c36a377237 100644 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java @@ -8,7 +8,8 @@ import java.util.Arrays; /** * IOT 接入网关协议枚举类 - * 接入网关协议, 0: 自定义, 1: Modbus, 2: OPC UA, 3: ZigBee, 4: BLE + * + * @author ahh */ @AllArgsConstructor @Getter @@ -20,19 +21,17 @@ public enum IotProtocolTypeEnum implements IntArrayValuable { ZIGBEE(3, "ZigBee"), BLE(4, "BLE"); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProtocolTypeEnum::getType).toArray(); /** * 类型 */ private final Integer type; - /** * 描述 */ private final String description; - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProtocolTypeEnum::getType).toArray(); - @Override public int[] array() { return ARRAYS; diff --git a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java index 3b27b0d365..9a8092b7b6 100644 --- a/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java +++ b/yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java @@ -8,7 +8,8 @@ import java.util.Arrays; /** * IOT 数据校验级别枚举类 - * 数据校验级别, 0: 弱校验, 1: 免校验 + * + * @author ahh */ @AllArgsConstructor @Getter @@ -17,19 +18,17 @@ public enum IotValidateTypeEnum implements IntArrayValuable { WEAK(0, "弱校验"), NONE(1, "免校验"); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotValidateTypeEnum::getType).toArray(); /** * 类型 */ private final Integer type; - /** * 描述 */ private final String description; - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotValidateTypeEnum::getType).toArray(); - @Override public int[] array() { return ARRAYS; diff --git a/yudao-module-iot/yudao-module-iot-biz/pom.xml b/yudao-module-iot/yudao-module-iot-biz/pom.xml index 25a97a1b10..e3f93086ae 100644 --- a/yudao-module-iot/yudao-module-iot-biz/pom.xml +++ b/yudao-module-iot/yudao-module-iot-biz/pom.xml @@ -15,9 +15,10 @@ ${project.artifactId} 物联网 模块,主要实现 产品管理、设备管理、协议管理等功能。 + - + cn.iocoder.boot yudao-module-iot-api @@ -53,7 +54,7 @@ yudao-spring-boot-starter-excel - + org.eclipse.paho org.eclipse.paho.client.mqttv3 diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/ProductController.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/ProductController.java index f6d7e494d0..7e68d2c20e 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/ProductController.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/ProductController.java @@ -27,6 +27,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +// TODO @haohao:Iot 前缀要加,不然很容易重复哈 @Tag(name = "管理后台 - IOT 产品") @RestController @RequestMapping("/iot/product") diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductPageReqVO.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductPageReqVO.java index 4479d5218b..dc0ae9d657 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductPageReqVO.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductPageReqVO.java @@ -1,14 +1,18 @@ package cn.iocoder.yudao.module.iot.controller.admin.product.vo; -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import org.springframework.format.annotation.DateTimeFormat; + import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; +// TODO @haohao:涉及到 iot 的拼写,要不都用 IoT,貌似更规范 +// TODO 芋艿:需要清理掉一些无用字段 @Schema(description = "管理后台 - iot 产品分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @@ -25,6 +29,9 @@ public class ProductPageReqVO extends PageParam { @Schema(description = "产品标识") private String productKey; + @Schema(description = "接入网关协议", example = "2") + private Integer protocolType; + @Schema(description = "协议编号(脚本解析 id)", example = "13177") private Long protocolId; @@ -34,22 +41,19 @@ public class ProductPageReqVO extends PageParam { @Schema(description = "产品描述", example = "你猜") private String description; - @Schema(description = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验", example = "1") + @Schema(description = "数据校验级别", example = "1") private Integer validateType; - @Schema(description = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS", example = "1") + @Schema(description = "产品状态", example = "1") private Integer status; - @Schema(description = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备", example = "2") + @Schema(description = "设备类型", example = "2") private Integer deviceType; - @Schema(description = "联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他", example = "2") + @Schema(description = "联网方式", example = "2") private Integer netType; - @Schema(description = "接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee", example = "2") - private Integer protocolType; - - @Schema(description = "数据格式, 0: 透传模式, 1: Alink JSON") + @Schema(description = "数据格式", example = "0") private Integer dataFormat; } \ No newline at end of file diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductRespVO.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductRespVO.java index 64aeeac13f..1a60f02902 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductRespVO.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductRespVO.java @@ -1,17 +1,21 @@ package cn.iocoder.yudao.module.iot.controller.admin.product.vo; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; +import lombok.Data; + import java.time.LocalDateTime; -import com.alibaba.excel.annotation.*; @Schema(description = "管理后台 - iot 产品 Response VO") @Data @ExcelIgnoreUnannotated public class ProductRespVO { + @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26087") + @ExcelProperty("产品ID") + private Long id; + @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") @ExcelProperty("产品名称") private String name; @@ -20,14 +24,14 @@ public class ProductRespVO { @ExcelProperty("创建时间") private LocalDateTime createTime; - @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26087") - @ExcelProperty("产品ID") - private Long id; - @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("产品标识") private String productKey; + @Schema(description = "接入网关协议", example = "2") + @ExcelProperty("接入网关协议") + private Integer protocolType; + @Schema(description = "协议编号(脚本解析 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13177") @ExcelProperty("协议编号(脚本解析 id)") private Long protocolId; @@ -40,28 +44,24 @@ public class ProductRespVO { @ExcelProperty("产品描述") private String description; - @Schema(description = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验") + @Schema(description = "数据校验级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty("数据校验级别") private Integer validateType; - @Schema(description = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS") + @Schema(description = "产品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty("产品状态") private Integer status; - @Schema(description = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @ExcelProperty("设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备") + @Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty("设备类型") private Integer deviceType; - @Schema(description = "联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他", example = "2") - @ExcelProperty("联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他") + @Schema(description = "联网方式", example = "2") + @ExcelProperty("联网方式") private Integer netType; - @Schema(description = "接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee", example = "2") - @ExcelProperty("接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee") - private Integer protocolType; - - @Schema(description = "数据格式, 0: 透传模式, 1: Alink JSON") - @ExcelProperty("数据格式, 0: 透传模式, 1: Alink JSON") + @Schema(description = "数据格式") + @ExcelProperty("数据格式") private Integer dataFormat; } \ No newline at end of file diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/product/ProductDO.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/product/ProductDO.java index d6a79d8c57..37c1eb513f 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/product/ProductDO.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/product/ProductDO.java @@ -1,16 +1,15 @@ package cn.iocoder.yudao.module.iot.dal.dataobject.product; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; /** * iot 产品 DO * - * @author 芋道源码 + * @author ahh */ @TableName("iot_product") @KeySequence("iot_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @@ -22,54 +21,73 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; @AllArgsConstructor public class ProductDO extends BaseDO { - /** - * 产品名称 - */ - private String name; /** * 产品ID */ @TableId private Long id; + /** + * 产品名称 + */ + private String name; + // TODO @haohao:这个字段,要不改成 identifier,和阿里云更统一些 /** * 产品标识 */ private String productKey; /** - * 协议编号(脚本解析 id) - */ - private Long protocolId; - /** - * 产品所属品类标识符 + * 产品所属品类编号 + * + * TODO 外键:后续加 */ private Long categoryId; /** * 产品描述 */ private String description; + /** - * 数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验 - */ - private Integer validateType; - /** - * 产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS + * 产品状态 + * + * 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum} */ private Integer status; /** - * 设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备 + * 设备类型 + * + * 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotProductDeviceTypeEnum} */ private Integer deviceType; /** - * 联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他 + * 联网方式 + * + * 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotNetTypeEnum} */ private Integer netType; + /** - * 接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee + * 接入网关协议 + * + * 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotProtocolTypeEnum} */ private Integer protocolType; /** - * 数据格式, 0: 透传模式, 1: Alink JSON + * 协议编号 + * + * TODO 外键:后续加 + */ + private Long protocolId; + /** + * 数据格式 + * + * 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotDataFormatEnum} */ private Integer dataFormat; + /** + * 数据校验级别 + * + * 枚举 {@link cn.iocoder.yudao.module.iot.enums.product.IotValidateTypeEnum} + */ + private Integer validateType; } \ No newline at end of file diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java index b8e80b7a33..d9af9b4b92 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java @@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper; /** * iot 产品 Mapper * - * @author 芋道源码 + * @author ahh */ @Mapper public interface ProductMapper extends BaseMapperX { diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/callback/EmqxCallback.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/callback/EmqxCallback.java index a34863a170..b466113f70 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/callback/EmqxCallback.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/callback/EmqxCallback.java @@ -10,6 +10,7 @@ import org.eclipse.paho.client.mqttv3.MqttMessage; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; +// TODO @芋艿:详细再瞅瞅 /** * 用于处理MQTT连接的回调,如连接断开、消息到达、消息发布完成、连接完成等事件。 * diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/config/MqttConfig.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/config/MqttConfig.java index ae1557c23b..9d128903c4 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/config/MqttConfig.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/config/MqttConfig.java @@ -4,6 +4,8 @@ import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +// TODO @芋艿:详细再瞅瞅 + /** * 配置类,用于读取MQTT连接的配置信息,如用户名、密码、连接地址等 * diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxService.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxService.java index 1658dc3769..0d564c39fd 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxService.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxService.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.iot.emq.service; import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttMessage; +// TODO @芋艿:在瞅瞅 /** * 用于处理MQTT消息的具体业务逻辑,如订阅回调 * diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxServiceImpl.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxServiceImpl.java index a18bb73e10..0f1a53cd09 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxServiceImpl.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/service/EmqxServiceImpl.java @@ -5,6 +5,8 @@ import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttMessage; import org.springframework.stereotype.Service; +// TODO @芋艿:在瞅瞅 + /** * 用于处理MQTT消息的具体业务逻辑,如订阅回调 * diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/start/EmqxStart.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/start/EmqxStart.java index f954cb5884..0c316b66c9 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/start/EmqxStart.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/emq/start/EmqxStart.java @@ -6,6 +6,8 @@ import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; +// TODO @芋艿:在瞅瞅 + /** * 用于在应用启动时自动连接MQTT服务器 * diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/package-info.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/package-info.java index 9d8ffe73d1..234cad870c 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/package-info.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/package-info.java @@ -1,6 +1,6 @@ /** * 属于 iot 模块的 framework 封装 * - * @author 芋道源码 + * @author ahh */ package cn.iocoder.yudao.module.iot.framework; diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/web/config/IotWebConfiguration.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/web/config/IotWebConfiguration.java index 890e60c7cf..6b3cc6ae5b 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/web/config/IotWebConfiguration.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/framework/web/config/IotWebConfiguration.java @@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration; /** * iot 模块的 web 组件的 Configuration * - * @author 芋道源码 + * @author ahh */ @Configuration(proxyBeanMethods = false) public class IotWebConfiguration { diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductService.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductService.java index cc1ffce811..8d4fdf8017 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductService.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductService.java @@ -9,7 +9,7 @@ import jakarta.validation.Valid; /** * IOT 产品 Service 接口 * - * @author 芋道源码 + * @author ahh */ public interface ProductService { diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductServiceImpl.java b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductServiceImpl.java index b692faa714..e5e3bc4213 100644 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductServiceImpl.java +++ b/yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductServiceImpl.java @@ -21,7 +21,7 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PRODUCT_STATU /** * IOT 产品 Service 实现类 * - * @author 芋道源码 + * @author ahh */ @Service @Validated @@ -37,7 +37,6 @@ public class ProductServiceImpl implements ProductService { // 插入 ProductDO product = BeanUtils.toBean(createReqVO, ProductDO.class); productMapper.insert(product); - // 返回 return product.getId(); } @@ -47,6 +46,7 @@ public class ProductServiceImpl implements ProductService { * @param createReqVO 创建信息 */ private void createProductKey(ProductSaveReqVO createReqVO) { + // TODO @haohao:应该前端没传递的时候,才生成哇?ps:需要校验下唯一性,万一有重复; // 生成随机的 11 位字符串 String productKey = UUID.randomUUID().toString().replace("-", "").substring(0, 11); createReqVO.setProductKey(productKey); @@ -54,8 +54,10 @@ public class ProductServiceImpl implements ProductService { @Override public void updateProduct(ProductSaveReqVO updateReqVO) { + updateReqVO.setProductKey(null); // 不更新产品标识 // 校验存在 validateProductExists(updateReqVO.getId()); + // TODO @haohao:如果已经发布,允许编辑么? // 更新 ProductDO updateObj = BeanUtils.toBean(updateReqVO, ProductDO.class); productMapper.updateById(updateObj); @@ -63,11 +65,12 @@ public class ProductServiceImpl implements ProductService { @Override public void deleteProduct(Long id) { - // 校验存在 + // TODO @haohao:这里最好只查询一次哈 + // 1.1 校验存在 validateProductExists(id); - // 发布状态不可删除 + // 1.2 发布状态不可删除 validateProductStatus(id); - // 删除 + // 2. 删除 productMapper.deleteById(id); } diff --git a/yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/product/ProductMapper.xml b/yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/product/ProductMapper.xml deleted file mode 100644 index 69352f8eaa..0000000000 --- a/yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/product/ProductMapper.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/product/ProductServiceImplTest.java b/yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/product/ProductServiceImplTest.java deleted file mode 100644 index 244cda6077..0000000000 --- a/yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/product/ProductServiceImplTest.java +++ /dev/null @@ -1,174 +0,0 @@ -package cn.iocoder.yudao.module.iot.service.product; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import jakarta.annotation.Resource; - -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.iot.controller.admin.product.vo.*; -import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO; -import cn.iocoder.yudao.module.iot.dal.mysql.product.ProductMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import jakarta.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; - -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; - -/** - * {@link ProductServiceImpl} 的单元测试类 - * - * @author 芋道源码 - */ -@Import(ProductServiceImpl.class) -public class ProductServiceImplTest extends BaseDbUnitTest { - - @Resource - private ProductServiceImpl productService; - - @Resource - private ProductMapper productMapper; - - @Test - public void testCreateProduct_success() { - // 准备参数 - ProductSaveReqVO createReqVO = randomPojo(ProductSaveReqVO.class).setId(null); - - // 调用 - Long productId = productService.createProduct(createReqVO); - // 断言 - assertNotNull(productId); - // 校验记录的属性是否正确 - ProductDO product = productMapper.selectById(productId); - assertPojoEquals(createReqVO, product, "id"); - } - - @Test - public void testUpdateProduct_success() { - // mock 数据 - ProductDO dbProduct = randomPojo(ProductDO.class); - productMapper.insert(dbProduct);// @Sql: 先插入出一条存在的数据 - // 准备参数 - ProductSaveReqVO updateReqVO = randomPojo(ProductSaveReqVO.class, o -> { - o.setId(dbProduct.getId()); // 设置更新的 ID - }); - - // 调用 - productService.updateProduct(updateReqVO); - // 校验是否更新正确 - ProductDO product = productMapper.selectById(updateReqVO.getId()); // 获取最新的 - assertPojoEquals(updateReqVO, product); - } - - @Test - public void testUpdateProduct_notExists() { - // 准备参数 - ProductSaveReqVO updateReqVO = randomPojo(ProductSaveReqVO.class); - - // 调用, 并断言异常 - assertServiceException(() -> productService.updateProduct(updateReqVO), PRODUCT_NOT_EXISTS); - } - - @Test - public void testDeleteProduct_success() { - // mock 数据 - ProductDO dbProduct = randomPojo(ProductDO.class); - productMapper.insert(dbProduct);// @Sql: 先插入出一条存在的数据 - // 准备参数 - Long id = dbProduct.getId(); - - // 调用 - productService.deleteProduct(id); - // 校验数据不存在了 - assertNull(productMapper.selectById(id)); - } - - @Test - public void testDeleteProduct_notExists() { - // 准备参数 - Long id = randomLongId(); - - // 调用, 并断言异常 - assertServiceException(() -> productService.deleteProduct(id), PRODUCT_NOT_EXISTS); - } - - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetProductPage() { - // mock 数据 - ProductDO dbProduct = randomPojo(ProductDO.class, o -> { // 等会查询到 - o.setName(null); - o.setCreateTime(null); - o.setProductKey(null); - o.setProtocolId(null); - o.setCategoryId(null); - o.setDescription(null); - o.setValidateType(null); - o.setStatus(null); - o.setDeviceType(null); - o.setNetType(null); - o.setProtocolType(null); - o.setDataFormat(null); - }); - productMapper.insert(dbProduct); - // 测试 name 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setName(null))); - // 测试 createTime 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setCreateTime(null))); - // 测试 productKey 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProductKey(null))); - // 测试 protocolId 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProtocolId(null))); - // 测试 categoryId 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setCategoryId(null))); - // 测试 description 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDescription(null))); - // 测试 validateType 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setValidateType(null))); - // 测试 status 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setStatus(null))); - // 测试 deviceType 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDeviceType(null))); - // 测试 netType 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setNetType(null))); - // 测试 protocolType 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProtocolType(null))); - // 测试 dataFormat 不匹配 - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDataFormat(null))); - // 准备参数 - ProductPageReqVO reqVO = new ProductPageReqVO(); - reqVO.setName(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setProductKey(null); - reqVO.setProtocolId(null); - reqVO.setCategoryId(null); - reqVO.setDescription(null); - reqVO.setValidateType(null); - reqVO.setStatus(null); - reqVO.setDeviceType(null); - reqVO.setNetType(null); - reqVO.setProtocolType(null); - reqVO.setDataFormat(null); - - // 调用 - PageResult pageResult = productService.getProductPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbProduct, pageResult.getList().get(0)); - } - -} \ No newline at end of file diff --git a/yudao-server/src/main/resources/application-dev.yaml b/yudao-server/src/main/resources/application-dev.yaml index 3e7f4e76a2..27f12107d4 100644 --- a/yudao-server/src/main/resources/application-dev.yaml +++ b/yudao-server/src/main/resources/application-dev.yaml @@ -196,7 +196,7 @@ justauth: timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 ---- #################### iot相关配置 #################### +--- #################### iot相关配置 TODO 芋艿:再瞅瞅 #################### iot: emq: # 账号 diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 27588d0459..5cdc511a00 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -250,7 +250,7 @@ justauth: prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 ---- #################### iot相关配置 #################### +--- #################### iot相关配置 TODO 芋艿:再瞅瞅 #################### iot: emq: # 账号