Commit 037ab39ac74746e8cfc452b00cb593144bf4d6f5
1 parent
f7b62b4b
修改:新增产品枚举
Showing
10 changed files
with
179 additions
and
45 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductDeviceTypeConstants.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.enums; | ||
| 2 | - | ||
| 3 | -/** | ||
| 4 | - * 产品设备类型常量 | ||
| 5 | - */ | ||
| 6 | -public interface ProductDeviceTypeConstants { | ||
| 7 | - | ||
| 8 | - // ========== 产品设备类型 ============ | ||
| 9 | - String DEVICE = "device"; // 直连设备 | ||
| 10 | - String GATEWAY = "gateway"; // 网关设备 | ||
| 11 | - String GATEWAY_SUB = "gateway_sub"; // 网关子设备 | ||
| 12 | - | ||
| 13 | -} |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductProtocolTypeConstants.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.enums; | ||
| 2 | - | ||
| 3 | -/** | ||
| 4 | - * 产品传输协议类型常量 | ||
| 5 | - */ | ||
| 6 | -public interface ProductProtocolTypeConstants { | ||
| 7 | - | ||
| 8 | - // ========== 产品传输协议类型 ============ | ||
| 9 | - String MQTT = "mqtt"; // MQTT | ||
| 10 | - String COAP = "coap"; // COAP | ||
| 11 | - String HTTP = "http"; // HTTP | ||
| 12 | - String HTTPS = "https"; // HTTPS | ||
| 13 | -} |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductDataFormatEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotDataFormatEnum.java
| 1 | -package cn.iocoder.yudao.module.iot.enums; | 1 | +package cn.iocoder.yudao.module.iot.enums.product; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | 3 | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; |
| 4 | import lombok.AllArgsConstructor; | 4 | import lombok.AllArgsConstructor; |
| @@ -8,14 +8,14 @@ import java.util.Arrays; | @@ -8,14 +8,14 @@ import java.util.Arrays; | ||
| 8 | 8 | ||
| 9 | /** | 9 | /** |
| 10 | * 产品数据格式枚举类 | 10 | * 产品数据格式枚举类 |
| 11 | - * 1. 标准数据格式(JSON)2. 透传/自定义 | 11 | + * 数据格式, 0: 标准数据格式(JSON), 1: 透传/自定义 |
| 12 | */ | 12 | */ |
| 13 | @AllArgsConstructor | 13 | @AllArgsConstructor |
| 14 | @Getter | 14 | @Getter |
| 15 | -public enum ProductDataFormatEnum implements IntArrayValuable { | 15 | +public enum IotDataFormatEnum implements IntArrayValuable { |
| 16 | 16 | ||
| 17 | - JSON(1, "标准数据格式(JSON)"), | ||
| 18 | - SCRIPT(2, "透传/自定义"); | 17 | + JSON(0, "标准数据格式(JSON)"), |
| 18 | + CUSTOMIZE(1, "透传/自定义"); | ||
| 19 | 19 | ||
| 20 | /** | 20 | /** |
| 21 | * 类型 | 21 | * 类型 |
| @@ -27,7 +27,7 @@ public enum ProductDataFormatEnum implements IntArrayValuable { | @@ -27,7 +27,7 @@ public enum ProductDataFormatEnum implements IntArrayValuable { | ||
| 27 | */ | 27 | */ |
| 28 | private final String description; | 28 | private final String description; |
| 29 | 29 | ||
| 30 | - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductDataFormatEnum::getType).toArray(); | 30 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotDataFormatEnum::getType).toArray(); |
| 31 | 31 | ||
| 32 | @Override | 32 | @Override |
| 33 | public int[] array() { | 33 | public int[] array() { |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotNetTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.enums.product; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | +import lombok.AllArgsConstructor; | ||
| 5 | +import lombok.Getter; | ||
| 6 | + | ||
| 7 | +import java.util.Arrays; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * IOT 联网方式枚举类 | ||
| 11 | + * 联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他 | ||
| 12 | + */ | ||
| 13 | +@AllArgsConstructor | ||
| 14 | +@Getter | ||
| 15 | +public enum IotNetTypeEnum implements IntArrayValuable { | ||
| 16 | + | ||
| 17 | + WIFI(0, "Wi-Fi"), | ||
| 18 | + CELLULAR(1, "Cellular"), | ||
| 19 | + ETHERNET(2, "Ethernet"), | ||
| 20 | + OTHER(3, "其他"); | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 类型 | ||
| 25 | + */ | ||
| 26 | + private final Integer type; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 描述 | ||
| 30 | + */ | ||
| 31 | + private final String description; | ||
| 32 | + | ||
| 33 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotNetTypeEnum::getType).toArray(); | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public int[] array() { | ||
| 37 | + return ARRAYS; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | +} |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductDeviceTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.enums.product; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | +import lombok.AllArgsConstructor; | ||
| 5 | +import lombok.Getter; | ||
| 6 | + | ||
| 7 | +import java.util.Arrays; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * IOT 产品设备类型 | ||
| 11 | + * 设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备 | ||
| 12 | + */ | ||
| 13 | +@AllArgsConstructor | ||
| 14 | +@Getter | ||
| 15 | +public enum IotProductDeviceTypeEnum implements IntArrayValuable { | ||
| 16 | + | ||
| 17 | + DIRECT(0, "直连设备"), | ||
| 18 | + GATEWAY_CHILD(1, "网关子设备"), | ||
| 19 | + GATEWAY(2, "网关设备"); | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 类型 | ||
| 23 | + */ | ||
| 24 | + private final Integer type; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 描述 | ||
| 28 | + */ | ||
| 29 | + private final String description; | ||
| 30 | + | ||
| 31 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductDeviceTypeEnum::getType).toArray(); | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public int[] array() { | ||
| 35 | + return ARRAYS; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/ProductStatusEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductStatusEnum.java
| 1 | -package cn.iocoder.yudao.module.iot.enums; | 1 | +package cn.iocoder.yudao.module.iot.enums.product; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | 3 | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; |
| 4 | import lombok.AllArgsConstructor; | 4 | import lombok.AllArgsConstructor; |
| 5 | import lombok.Getter; | 5 | import lombok.Getter; |
| 6 | 6 | ||
| 7 | /** | 7 | /** |
| 8 | - * 产品状态枚举类 | ||
| 9 | - * 禁用 启用 | 8 | + * IOT 产品状态枚举类 |
| 9 | + * 产品状态, 0: 未发布, 1: 已发布 | ||
| 10 | */ | 10 | */ |
| 11 | @AllArgsConstructor | 11 | @AllArgsConstructor |
| 12 | @Getter | 12 | @Getter |
| 13 | -public enum ProductStatusEnum implements IntArrayValuable { | 13 | +public enum IotProductStatusEnum implements IntArrayValuable { |
| 14 | 14 | ||
| 15 | - DISABLE(0, "禁用"), | ||
| 16 | - ENABLE(1, "启用"); | 15 | + UNPUBLISHED(0, "未发布"), |
| 16 | + PUBLISHED(1, "已发布"); | ||
| 17 | 17 | ||
| 18 | /** | 18 | /** |
| 19 | * 类型 | 19 | * 类型 |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProtocolTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.enums.product; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | +import lombok.AllArgsConstructor; | ||
| 5 | +import lombok.Getter; | ||
| 6 | + | ||
| 7 | +import java.util.Arrays; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * IOT 接入网关协议枚举类 | ||
| 11 | + * 接入网关协议, 0: 自定义, 1: Modbus, 2: OPC UA, 3: ZigBee, 4: BLE | ||
| 12 | + */ | ||
| 13 | +@AllArgsConstructor | ||
| 14 | +@Getter | ||
| 15 | +public enum IotProtocolTypeEnum implements IntArrayValuable { | ||
| 16 | + | ||
| 17 | + CUSTOM(0, "自定义"), | ||
| 18 | + MODBUS(1, "Modbus"), | ||
| 19 | + OPC_UA(2, "OPC UA"), | ||
| 20 | + ZIGBEE(3, "ZigBee"), | ||
| 21 | + BLE(4, "BLE"); | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 类型 | ||
| 26 | + */ | ||
| 27 | + private final Integer type; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 描述 | ||
| 31 | + */ | ||
| 32 | + private final String description; | ||
| 33 | + | ||
| 34 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProtocolTypeEnum::getType).toArray(); | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public int[] array() { | ||
| 38 | + return ARRAYS; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | +} |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotValidateTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.enums.product; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | +import lombok.AllArgsConstructor; | ||
| 5 | +import lombok.Getter; | ||
| 6 | + | ||
| 7 | +import java.util.Arrays; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * IOT 数据校验级别枚举类 | ||
| 11 | + * 数据校验级别, 0: 弱校验, 1: 免校验 | ||
| 12 | + */ | ||
| 13 | +@AllArgsConstructor | ||
| 14 | +@Getter | ||
| 15 | +public enum IotValidateTypeEnum implements IntArrayValuable { | ||
| 16 | + | ||
| 17 | + WEAK(0, "弱校验"), | ||
| 18 | + NONE(1, "免校验"); | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 类型 | ||
| 23 | + */ | ||
| 24 | + private final Integer type; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 描述 | ||
| 28 | + */ | ||
| 29 | + private final String description; | ||
| 30 | + | ||
| 31 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotValidateTypeEnum::getType).toArray(); | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public int[] array() { | ||
| 35 | + return ARRAYS; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductSaveReqVO.java
| 1 | package cn.iocoder.yudao.module.iot.controller.admin.product.vo; | 1 | package cn.iocoder.yudao.module.iot.controller.admin.product.vo; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | +import cn.iocoder.yudao.module.iot.enums.product.*; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.*; | 6 | import lombok.*; |
| 5 | import java.util.*; | 7 | import java.util.*; |
| @@ -20,22 +22,25 @@ public class ProductSaveReqVO { | @@ -20,22 +22,25 @@ public class ProductSaveReqVO { | ||
| 20 | private String name; | 22 | private String name; |
| 21 | 23 | ||
| 22 | @Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | 24 | @Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") |
| 25 | + @InEnum(value = IotProductDeviceTypeEnum.class, message = "设备类型必须是 {value}") | ||
| 23 | @NotNull(message = "设备类型不能为空") | 26 | @NotNull(message = "设备类型不能为空") |
| 24 | private Integer deviceType; | 27 | private Integer deviceType; |
| 25 | 28 | ||
| 26 | @Schema(description = "联网方式", requiredMode = Schema.RequiredMode.REQUIRED,example = "0") | 29 | @Schema(description = "联网方式", requiredMode = Schema.RequiredMode.REQUIRED,example = "0") |
| 27 | - @NotNull(message = "联网方式不能为空") | 30 | + @InEnum(value = IotNetTypeEnum.class, message = "联网方式必须是 {value}") |
| 28 | private Integer netType; | 31 | private Integer netType; |
| 29 | 32 | ||
| 30 | @Schema(description = "接入网关协议", requiredMode = Schema.RequiredMode.REQUIRED,example = "0") | 33 | @Schema(description = "接入网关协议", requiredMode = Schema.RequiredMode.REQUIRED,example = "0") |
| 31 | - @NotNull(message = "接入网关协议不能为空") | 34 | + @InEnum(value = IotProtocolTypeEnum.class, message = "接入网关协议必须是 {value}") |
| 32 | private Integer protocolType; | 35 | private Integer protocolType; |
| 33 | 36 | ||
| 34 | @Schema(description = "数据格式",requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | 37 | @Schema(description = "数据格式",requiredMode = Schema.RequiredMode.REQUIRED, example = "0") |
| 38 | + @InEnum(value = IotDataFormatEnum.class, message = "数据格式必须是 {value}") | ||
| 35 | @NotNull(message = "数据格式不能为空") | 39 | @NotNull(message = "数据格式不能为空") |
| 36 | private Integer dataFormat; | 40 | private Integer dataFormat; |
| 37 | 41 | ||
| 38 | @Schema(description = "数据校验级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | 42 | @Schema(description = "数据校验级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") |
| 43 | + @InEnum(value = IotValidateTypeEnum.class, message = "数据校验级别必须是 {value}") | ||
| 39 | @NotNull(message = "数据校验级别不能为空") | 44 | @NotNull(message = "数据校验级别不能为空") |
| 40 | private Integer validateType; | 45 | private Integer validateType; |
| 41 | 46 |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java
| 1 | package cn.iocoder.yudao.module.iot.dal.mysql.product; | 1 | package cn.iocoder.yudao.module.iot.dal.mysql.product; |
| 2 | 2 | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 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.product.vo.ProductPageReqVO; | ||
| 8 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO; | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 10 | -import cn.iocoder.yudao.module.iot.controller.admin.product.vo.*; | ||
| 11 | 9 | ||
| 12 | /** | 10 | /** |
| 13 | * iot 产品 Mapper | 11 | * iot 产品 Mapper |
| @@ -21,7 +19,7 @@ public interface ProductMapper extends BaseMapperX<ProductDO> { | @@ -21,7 +19,7 @@ public interface ProductMapper extends BaseMapperX<ProductDO> { | ||
| 21 | return selectPage(reqVO, new LambdaQueryWrapperX<ProductDO>() | 19 | return selectPage(reqVO, new LambdaQueryWrapperX<ProductDO>() |
| 22 | .likeIfPresent(ProductDO::getName, reqVO.getName()) | 20 | .likeIfPresent(ProductDO::getName, reqVO.getName()) |
| 23 | .betweenIfPresent(ProductDO::getCreateTime, reqVO.getCreateTime()) | 21 | .betweenIfPresent(ProductDO::getCreateTime, reqVO.getCreateTime()) |
| 24 | - .eqIfPresent(ProductDO::getProductKey, reqVO.getProductKey()) | 22 | + .likeIfPresent(ProductDO::getProductKey, reqVO.getProductKey()) |
| 25 | .eqIfPresent(ProductDO::getProtocolId, reqVO.getProtocolId()) | 23 | .eqIfPresent(ProductDO::getProtocolId, reqVO.getProtocolId()) |
| 26 | .eqIfPresent(ProductDO::getCategoryId, reqVO.getCategoryId()) | 24 | .eqIfPresent(ProductDO::getCategoryId, reqVO.getCategoryId()) |
| 27 | .eqIfPresent(ProductDO::getDescription, reqVO.getDescription()) | 25 | .eqIfPresent(ProductDO::getDescription, reqVO.getDescription()) |