Commit 609cc719302c885dd8f1ab3d5146b6b16a27f281
1 parent
36a82886
修改:iot 产品 字段修改
Showing
9 changed files
with
172 additions
and
218 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/ProductController.java
| ... | ... | @@ -27,7 +27,7 @@ import java.util.List; |
| 27 | 27 | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| 28 | 28 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 29 | 29 | |
| 30 | -@Tag(name = "管理后台 - iot 产品") | |
| 30 | +@Tag(name = "管理后台 - IOT 产品") | |
| 31 | 31 | @RestController |
| 32 | 32 | @RequestMapping("/iot/product") |
| 33 | 33 | @Validated | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductPageReqVO.java
| ... | ... | @@ -18,41 +18,38 @@ public class ProductPageReqVO extends PageParam { |
| 18 | 18 | @Schema(description = "产品名称", example = "李四") |
| 19 | 19 | private String name; |
| 20 | 20 | |
| 21 | - @Schema(description = "产品标识") | |
| 22 | - private String identification; | |
| 23 | - | |
| 24 | - @Schema(description = "设备类型:device、gatway、gatway_sub", example = "1") | |
| 25 | - private String deviceType; | |
| 21 | + @Schema(description = "创建时间") | |
| 22 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 23 | + private LocalDateTime[] createTime; | |
| 26 | 24 | |
| 27 | - @Schema(description = "厂商名称", example = "李四") | |
| 28 | - private String manufacturerName; | |
| 25 | + @Schema(description = "产品标识") | |
| 26 | + private String productKey; | |
| 29 | 27 | |
| 30 | - @Schema(description = "产品型号") | |
| 31 | - private String model; | |
| 28 | + @Schema(description = "协议编号(脚本解析 id)", example = "13177") | |
| 29 | + private Long protocolId; | |
| 32 | 30 | |
| 33 | - @Schema(description = "数据格式:1. 标准数据格式(JSON)2. 透传/自定义,脚本解析") | |
| 34 | - private Integer dataFormat; | |
| 31 | + @Schema(description = "产品所属品类标识符", example = "14237") | |
| 32 | + private Long categoryId; | |
| 35 | 33 | |
| 36 | - @Schema(description = "设备接入平台的协议类型,默认为MQTT", example = "2") | |
| 37 | - private String protocolType; | |
| 38 | - | |
| 39 | - @Schema(description = "产品描述", example = "随便") | |
| 34 | + @Schema(description = "产品描述", example = "你猜") | |
| 40 | 35 | private String description; |
| 41 | 36 | |
| 42 | - @Schema(description = "产品状态 (0: 启用, 1: 停用)", example = "2") | |
| 37 | + @Schema(description = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验", example = "1") | |
| 38 | + private Integer validateType; | |
| 39 | + | |
| 40 | + @Schema(description = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS", example = "1") | |
| 43 | 41 | private Integer status; |
| 44 | 42 | |
| 45 | - @Schema(description = "物模型定义") | |
| 46 | - private String metadata; | |
| 43 | + @Schema(description = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备", example = "2") | |
| 44 | + private Integer deviceType; | |
| 47 | 45 | |
| 48 | - @Schema(description = "消息协议ID") | |
| 49 | - private Long messageProtocol; | |
| 46 | + @Schema(description = "联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他", example = "2") | |
| 47 | + private Integer netType; | |
| 50 | 48 | |
| 51 | - @Schema(description = "消息协议名称", example = "芋艿") | |
| 52 | - private String protocolName; | |
| 49 | + @Schema(description = "接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee", example = "2") | |
| 50 | + private Integer protocolType; | |
| 53 | 51 | |
| 54 | - @Schema(description = "创建时间") | |
| 55 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 56 | - private LocalDateTime[] createTime; | |
| 52 | + @Schema(description = "数据格式, 0: 透传模式, 1: Alink JSON") | |
| 53 | + private Integer dataFormat; | |
| 57 | 54 | |
| 58 | 55 | } |
| 59 | 56 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductRespVO.java
| ... | ... | @@ -12,60 +12,56 @@ import com.alibaba.excel.annotation.*; |
| 12 | 12 | @ExcelIgnoreUnannotated |
| 13 | 13 | public class ProductRespVO { |
| 14 | 14 | |
| 15 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "778") | |
| 16 | - @ExcelProperty("编号") | |
| 17 | - private Long id; | |
| 18 | - | |
| 19 | 15 | @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") |
| 20 | 16 | @ExcelProperty("产品名称") |
| 21 | 17 | private String name; |
| 22 | 18 | |
| 23 | - @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 24 | - @ExcelProperty("产品标识") | |
| 25 | - private String identification; | |
| 26 | - | |
| 27 | - @Schema(description = "设备类型:device、gatway、gatway_sub", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 28 | - @ExcelProperty("设备类型:device、gatway、gatway_sub") | |
| 29 | - private String deviceType; | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + @ExcelProperty("创建时间") | |
| 21 | + private LocalDateTime createTime; | |
| 30 | 22 | |
| 31 | - @Schema(description = "厂商名称", example = "李四") | |
| 32 | - @ExcelProperty("厂商名称") | |
| 33 | - private String manufacturerName; | |
| 23 | + @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26087") | |
| 24 | + @ExcelProperty("产品ID") | |
| 25 | + private Long id; | |
| 34 | 26 | |
| 35 | - @Schema(description = "产品型号") | |
| 36 | - @ExcelProperty("产品型号") | |
| 37 | - private String model; | |
| 27 | + @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 28 | + @ExcelProperty("产品标识") | |
| 29 | + private String productKey; | |
| 38 | 30 | |
| 39 | - @Schema(description = "数据格式:1. 标准数据格式(JSON)2. 透传/自定义,脚本解析") | |
| 40 | - @ExcelProperty("数据格式:1. 标准数据格式(JSON)2. 透传/自定义,脚本解析") | |
| 41 | - private Integer dataFormat; | |
| 31 | + @Schema(description = "协议编号(脚本解析 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13177") | |
| 32 | + @ExcelProperty("协议编号(脚本解析 id)") | |
| 33 | + private Long protocolId; | |
| 42 | 34 | |
| 43 | - @Schema(description = "设备接入平台的协议类型,默认为MQTT", example = "2") | |
| 44 | - @ExcelProperty("设备接入平台的协议类型,默认为MQTT") | |
| 45 | - private String protocolType; | |
| 35 | + @Schema(description = "产品所属品类标识符", example = "14237") | |
| 36 | + @ExcelProperty("产品所属品类标识符") | |
| 37 | + private Long categoryId; | |
| 46 | 38 | |
| 47 | - @Schema(description = "产品描述", example = "随便") | |
| 39 | + @Schema(description = "产品描述", example = "你猜") | |
| 48 | 40 | @ExcelProperty("产品描述") |
| 49 | 41 | private String description; |
| 50 | 42 | |
| 51 | - @Schema(description = "产品状态 (0: 启用, 1: 停用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 52 | - @ExcelProperty("产品状态 (0: 启用, 1: 停用)") | |
| 43 | + @Schema(description = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 44 | + @ExcelProperty("数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验") | |
| 45 | + private Integer validateType; | |
| 46 | + | |
| 47 | + @Schema(description = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 48 | + @ExcelProperty("产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS") | |
| 53 | 49 | private Integer status; |
| 54 | 50 | |
| 55 | - @Schema(description = "物模型定义", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 56 | - @ExcelProperty("物模型定义") | |
| 57 | - private String metadata; | |
| 51 | + @Schema(description = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 52 | + @ExcelProperty("设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备") | |
| 53 | + private Integer deviceType; | |
| 58 | 54 | |
| 59 | - @Schema(description = "消息协议ID", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 60 | - @ExcelProperty("消息协议ID") | |
| 61 | - private Long messageProtocol; | |
| 55 | + @Schema(description = "联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他", example = "2") | |
| 56 | + @ExcelProperty("联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他") | |
| 57 | + private Integer netType; | |
| 62 | 58 | |
| 63 | - @Schema(description = "消息协议名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | |
| 64 | - @ExcelProperty("消息协议名称") | |
| 65 | - private String protocolName; | |
| 59 | + @Schema(description = "接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee", example = "2") | |
| 60 | + @ExcelProperty("接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee") | |
| 61 | + private Integer protocolType; | |
| 66 | 62 | |
| 67 | - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 68 | - @ExcelProperty("创建时间") | |
| 69 | - private LocalDateTime createTime; | |
| 63 | + @Schema(description = "数据格式, 0: 透传模式, 1: Alink JSON") | |
| 64 | + @ExcelProperty("数据格式, 0: 透传模式, 1: Alink JSON") | |
| 65 | + private Integer dataFormat; | |
| 70 | 66 | |
| 71 | 67 | } |
| 72 | 68 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/product/vo/ProductSaveReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.product.vo; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import jakarta.validation.constraints.NotEmpty; | |
| 5 | -import lombok.Data; | |
| 4 | +import lombok.*; | |
| 5 | +import java.util.*; | |
| 6 | +import jakarta.validation.constraints.*; | |
| 6 | 7 | |
| 7 | 8 | @Schema(description = "管理后台 - iot 产品新增/修改 Request VO") |
| 8 | 9 | @Data |
| 9 | 10 | public class ProductSaveReqVO { |
| 10 | 11 | |
| 11 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "778") | |
| 12 | - private Long id; | |
| 13 | - | |
| 14 | - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "温湿度") | |
| 12 | + @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | |
| 15 | 13 | @NotEmpty(message = "产品名称不能为空") |
| 16 | 14 | private String name; |
| 17 | 15 | |
| 18 | - @Schema(description = "产品标识", example = "123456") | |
| 19 | - private String identification; | |
| 16 | + @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26087") | |
| 17 | + private Long id; | |
| 20 | 18 | |
| 21 | - @Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "device") | |
| 22 | - @NotEmpty(message = "设备类型不能为空") | |
| 23 | - private String deviceType; | |
| 19 | + @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + @NotEmpty(message = "产品标识不能为空") | |
| 21 | + private String productKey; | |
| 24 | 22 | |
| 25 | - @Schema(description = "数据格式:1. 标准数据格式(JSON)2. 透传/自定义", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 26 | - @NotEmpty(message = "数据格式不能为空") | |
| 27 | - private Integer dataFormat; | |
| 23 | + @Schema(description = "协议编号(脚本解析 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13177") | |
| 24 | + @NotNull(message = "协议编号(脚本解析 id)不能为空") | |
| 25 | + private Long protocolId; | |
| 26 | + | |
| 27 | + @Schema(description = "产品所属品类标识符", example = "14237") | |
| 28 | + private Long categoryId; | |
| 28 | 29 | |
| 29 | - @Schema(description = "设备接入平台的协议类型,默认为MQTT", requiredMode = Schema.RequiredMode.REQUIRED, example = "mqtt") | |
| 30 | - @NotEmpty(message = "设备接入平台的协议类型不能为空") | |
| 31 | - private String protocolType; | |
| 30 | + @Schema(description = "产品描述", example = "你猜") | |
| 31 | + private String description; | |
| 32 | 32 | |
| 33 | - @Schema(description = "厂商名称", example = "电信") | |
| 34 | - private String manufacturerName; | |
| 33 | + @Schema(description = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 34 | + @NotNull(message = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验不能为空") | |
| 35 | + private Integer validateType; | |
| 35 | 36 | |
| 36 | - @Schema(description = "产品型号", example = "wsd-01") | |
| 37 | - private String model; | |
| 37 | + @Schema(description = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 38 | + @NotNull(message = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS不能为空") | |
| 39 | + private Integer status; | |
| 38 | 40 | |
| 39 | - @Schema(description = "产品描述", example = "随便") | |
| 40 | - private String description; | |
| 41 | + @Schema(description = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 42 | + @NotNull(message = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备不能为空") | |
| 43 | + private Integer deviceType; | |
| 44 | + | |
| 45 | + @Schema(description = "联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他", example = "2") | |
| 46 | + private Integer netType; | |
| 41 | 47 | |
| 42 | -// @Schema(description = "产品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 43 | -// private Integer status; | |
| 44 | -// | |
| 45 | -// @Schema(description = "物模型定义", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 46 | -// private String metadata; | |
| 47 | -// | |
| 48 | -// @Schema(description = "消息协议ID", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 49 | -// private Long messageProtocol; | |
| 50 | -// | |
| 51 | -// @Schema(description = "消息协议名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | |
| 52 | -// private String protocolName; | |
| 48 | + @Schema(description = "接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee", example = "2") | |
| 49 | + private Integer protocolType; | |
| 50 | + | |
| 51 | + @Schema(description = "数据格式, 0: 透传模式, 1: Alink JSON") | |
| 52 | + private Integer dataFormat; | |
| 53 | 53 | |
| 54 | 54 | } |
| 55 | 55 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/product/ProductDO.java
| ... | ... | @@ -23,57 +23,53 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 23 | 23 | public class ProductDO extends BaseDO { |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * 编号 | |
| 27 | - */ | |
| 28 | - @TableId | |
| 29 | - private Long id; | |
| 30 | - /** | |
| 31 | 26 | * 产品名称 |
| 32 | 27 | */ |
| 33 | 28 | private String name; |
| 34 | 29 | /** |
| 35 | - * 产品标识 | |
| 30 | + * 产品ID | |
| 36 | 31 | */ |
| 37 | - private String identification; | |
| 32 | + @TableId | |
| 33 | + private Long id; | |
| 38 | 34 | /** |
| 39 | - * 设备类型:device、gatway、gatway_sub | |
| 35 | + * 产品标识 | |
| 40 | 36 | */ |
| 41 | - private String deviceType; | |
| 37 | + private String productKey; | |
| 42 | 38 | /** |
| 43 | - * 厂商名称 | |
| 39 | + * 协议编号(脚本解析 id) | |
| 44 | 40 | */ |
| 45 | - private String manufacturerName; | |
| 41 | + private Long protocolId; | |
| 46 | 42 | /** |
| 47 | - * 产品型号 | |
| 43 | + * 产品所属品类标识符 | |
| 48 | 44 | */ |
| 49 | - private String model; | |
| 45 | + private Long categoryId; | |
| 50 | 46 | /** |
| 51 | - * 数据格式:1. 标准数据格式(JSON)2. 透传/自定义,脚本解析 | |
| 47 | + * 产品描述 | |
| 52 | 48 | */ |
| 53 | - private Integer dataFormat; | |
| 49 | + private String description; | |
| 54 | 50 | /** |
| 55 | - * 设备接入平台的协议类型,默认为MQTT | |
| 51 | + * 数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验 | |
| 56 | 52 | */ |
| 57 | - private String protocolType; | |
| 53 | + private Integer validateType; | |
| 58 | 54 | /** |
| 59 | - * 产品描述 | |
| 55 | + * 产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS | |
| 60 | 56 | */ |
| 61 | - private String description; | |
| 57 | + private Integer status; | |
| 62 | 58 | /** |
| 63 | - * 产品状态 (0: 启用, 1: 停用) | |
| 59 | + * 设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备 | |
| 64 | 60 | */ |
| 65 | - private Integer status; | |
| 61 | + private Integer deviceType; | |
| 66 | 62 | /** |
| 67 | - * 物模型定义 | |
| 63 | + * 联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他 | |
| 68 | 64 | */ |
| 69 | - private String metadata; | |
| 65 | + private Integer netType; | |
| 70 | 66 | /** |
| 71 | - * 消息协议ID | |
| 67 | + * 接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee | |
| 72 | 68 | */ |
| 73 | - private Long messageProtocol; | |
| 69 | + private Integer protocolType; | |
| 74 | 70 | /** |
| 75 | - * 消息协议名称 | |
| 71 | + * 数据格式, 0: 透传模式, 1: Alink JSON | |
| 76 | 72 | */ |
| 77 | - private String protocolName; | |
| 73 | + private Integer dataFormat; | |
| 78 | 74 | |
| 79 | 75 | } |
| 80 | 76 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/product/ProductMapper.java
| ... | ... | @@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 8 | 8 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO; |
| 9 | -import jakarta.validation.constraints.NotEmpty; | |
| 10 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 10 | import cn.iocoder.yudao.module.iot.controller.admin.product.vo.*; |
| 12 | 11 | |
| ... | ... | @@ -21,22 +20,18 @@ public interface ProductMapper extends BaseMapperX<ProductDO> { |
| 21 | 20 | default PageResult<ProductDO> selectPage(ProductPageReqVO reqVO) { |
| 22 | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<ProductDO>() |
| 23 | 22 | .likeIfPresent(ProductDO::getName, reqVO.getName()) |
| 24 | - .eqIfPresent(ProductDO::getIdentification, reqVO.getIdentification()) | |
| 25 | - .eqIfPresent(ProductDO::getDeviceType, reqVO.getDeviceType()) | |
| 26 | - .likeIfPresent(ProductDO::getManufacturerName, reqVO.getManufacturerName()) | |
| 27 | - .eqIfPresent(ProductDO::getModel, reqVO.getModel()) | |
| 28 | - .eqIfPresent(ProductDO::getDataFormat, reqVO.getDataFormat()) | |
| 29 | - .eqIfPresent(ProductDO::getProtocolType, reqVO.getProtocolType()) | |
| 23 | + .betweenIfPresent(ProductDO::getCreateTime, reqVO.getCreateTime()) | |
| 24 | + .eqIfPresent(ProductDO::getProductKey, reqVO.getProductKey()) | |
| 25 | + .eqIfPresent(ProductDO::getProtocolId, reqVO.getProtocolId()) | |
| 26 | + .eqIfPresent(ProductDO::getCategoryId, reqVO.getCategoryId()) | |
| 30 | 27 | .eqIfPresent(ProductDO::getDescription, reqVO.getDescription()) |
| 28 | + .eqIfPresent(ProductDO::getValidateType, reqVO.getValidateType()) | |
| 31 | 29 | .eqIfPresent(ProductDO::getStatus, reqVO.getStatus()) |
| 32 | - .eqIfPresent(ProductDO::getMetadata, reqVO.getMetadata()) | |
| 33 | - .eqIfPresent(ProductDO::getMessageProtocol, reqVO.getMessageProtocol()) | |
| 34 | - .likeIfPresent(ProductDO::getProtocolName, reqVO.getProtocolName()) | |
| 35 | - .betweenIfPresent(ProductDO::getCreateTime, reqVO.getCreateTime()) | |
| 30 | + .eqIfPresent(ProductDO::getDeviceType, reqVO.getDeviceType()) | |
| 31 | + .eqIfPresent(ProductDO::getNetType, reqVO.getNetType()) | |
| 32 | + .eqIfPresent(ProductDO::getProtocolType, reqVO.getProtocolType()) | |
| 33 | + .eqIfPresent(ProductDO::getDataFormat, reqVO.getDataFormat()) | |
| 36 | 34 | .orderByDesc(ProductDO::getId)); |
| 37 | 35 | } |
| 38 | 36 | |
| 39 | - default ProductDO selectByIdentification(String identification){ | |
| 40 | - return selectOne(new LambdaQueryWrapperX<ProductDO>().eq(ProductDO::getIdentification, identification)); | |
| 41 | - } | |
| 42 | 37 | } |
| 43 | 38 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductService.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.product; |
| 2 | 2 | |
| 3 | -import java.util.*; | |
| 4 | -import jakarta.validation.*; | |
| 5 | -import cn.iocoder.yudao.module.iot.controller.admin.product.vo.*; | |
| 6 | -import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO; | |
| 7 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import cn.iocoder.yudao.module.iot.controller.admin.product.vo.ProductPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.iot.controller.admin.product.vo.ProductSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO; | |
| 7 | +import jakarta.validation.Valid; | |
| 9 | 8 | |
| 10 | 9 | /** |
| 11 | - * iot 产品 Service 接口 | |
| 10 | + * IOT 产品 Service 接口 | |
| 12 | 11 | * |
| 13 | 12 | * @author 芋道源码 |
| 14 | 13 | */ |
| 15 | 14 | public interface ProductService { |
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | - * 创建iot 产品 | |
| 17 | + * 创建产品 | |
| 19 | 18 | * |
| 20 | 19 | * @param createReqVO 创建信息 |
| 21 | 20 | * @return 编号 |
| ... | ... | @@ -23,32 +22,32 @@ public interface ProductService { |
| 23 | 22 | Long createProduct(@Valid ProductSaveReqVO createReqVO); |
| 24 | 23 | |
| 25 | 24 | /** |
| 26 | - * 更新iot 产品 | |
| 25 | + * 更新产品 | |
| 27 | 26 | * |
| 28 | 27 | * @param updateReqVO 更新信息 |
| 29 | 28 | */ |
| 30 | 29 | void updateProduct(@Valid ProductSaveReqVO updateReqVO); |
| 31 | 30 | |
| 32 | 31 | /** |
| 33 | - * 删除iot 产品 | |
| 32 | + * 删除产品 | |
| 34 | 33 | * |
| 35 | 34 | * @param id 编号 |
| 36 | 35 | */ |
| 37 | 36 | void deleteProduct(Long id); |
| 38 | 37 | |
| 39 | 38 | /** |
| 40 | - * 获得iot 产品 | |
| 39 | + * 获得产品 | |
| 41 | 40 | * |
| 42 | 41 | * @param id 编号 |
| 43 | - * @return iot 产品 | |
| 42 | + * @return 产品 | |
| 44 | 43 | */ |
| 45 | 44 | ProductDO getProduct(Long id); |
| 46 | 45 | |
| 47 | 46 | /** |
| 48 | - * 获得iot 产品分页 | |
| 47 | + * 获得产品分页 | |
| 49 | 48 | * |
| 50 | 49 | * @param pageReqVO 分页查询 |
| 51 | - * @return iot 产品分页 | |
| 50 | + * @return 产品分页 | |
| 52 | 51 | */ |
| 53 | 52 | PageResult<ProductDO> getProductPage(ProductPageReqVO pageReqVO); |
| 54 | 53 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/ProductServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.service.product; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.util.IdUtil; | |
| 4 | -import cn.hutool.core.util.StrUtil; | |
| 5 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | 5 | import cn.iocoder.yudao.module.iot.controller.admin.product.vo.ProductPageReqVO; |
| ... | ... | @@ -9,16 +7,14 @@ import cn.iocoder.yudao.module.iot.controller.admin.product.vo.ProductSaveReqVO; |
| 9 | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO; |
| 10 | 8 | import cn.iocoder.yudao.module.iot.dal.mysql.product.ProductMapper; |
| 11 | 9 | import jakarta.annotation.Resource; |
| 12 | -import jakarta.validation.constraints.NotEmpty; | |
| 13 | 10 | import org.springframework.stereotype.Service; |
| 14 | 11 | import org.springframework.validation.annotation.Validated; |
| 15 | 12 | |
| 16 | 13 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 17 | -import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PRODUCT_IDENTIFICATION_EXISTS; | |
| 18 | 14 | import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PRODUCT_NOT_EXISTS; |
| 19 | 15 | |
| 20 | 16 | /** |
| 21 | - * iot 产品 Service 实现类 | |
| 17 | + * IOT 产品 Service 实现类 | |
| 22 | 18 | * |
| 23 | 19 | * @author 芋道源码 |
| 24 | 20 | */ |
| ... | ... | @@ -31,10 +27,6 @@ public class ProductServiceImpl implements ProductService { |
| 31 | 27 | |
| 32 | 28 | @Override |
| 33 | 29 | public Long createProduct(ProductSaveReqVO createReqVO) { |
| 34 | - // 不传自动生成产品标识 | |
| 35 | - createIdentification(createReqVO); | |
| 36 | - // 校验产品标识是否重复 | |
| 37 | - validateProductIdentification(createReqVO.getIdentification()); | |
| 38 | 30 | // 插入 |
| 39 | 31 | ProductDO product = BeanUtils.toBean(createReqVO, ProductDO.class); |
| 40 | 32 | productMapper.insert(product); |
| ... | ... | @@ -42,20 +34,6 @@ public class ProductServiceImpl implements ProductService { |
| 42 | 34 | return product.getId(); |
| 43 | 35 | } |
| 44 | 36 | |
| 45 | - private void validateProductIdentification(@NotEmpty(message = "产品标识不能为空") String identification) { | |
| 46 | - if (productMapper.selectByIdentification(identification) != null) { | |
| 47 | - throw exception(PRODUCT_IDENTIFICATION_EXISTS); | |
| 48 | - } | |
| 49 | - } | |
| 50 | - | |
| 51 | - private void createIdentification(ProductSaveReqVO createReqVO) { | |
| 52 | - if (StrUtil.isNotBlank(createReqVO.getIdentification())) { | |
| 53 | - return; | |
| 54 | - } | |
| 55 | - // 生成 19 位数字 | |
| 56 | - createReqVO.setIdentification(String.valueOf(IdUtil.getSnowflake(1, 1).nextId())); | |
| 57 | - } | |
| 58 | - | |
| 59 | 37 | @Override |
| 60 | 38 | public void updateProduct(ProductSaveReqVO updateReqVO) { |
| 61 | 39 | // 校验存在 |
| ... | ... | @@ -89,7 +67,4 @@ public class ProductServiceImpl implements ProductService { |
| 89 | 67 | return productMapper.selectPage(pageReqVO); |
| 90 | 68 | } |
| 91 | 69 | |
| 92 | - public static void main(String[] args) { | |
| 93 | - System.out.println(String.valueOf(IdUtil.getSnowflake(1, 1).nextId())); | |
| 94 | - } | |
| 95 | 70 | } |
| 96 | 71 | \ No newline at end of file | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/test/java/cn/iocoder/yudao/module/iot/service/product/ProductServiceImplTest.java
| ... | ... | @@ -111,61 +111,57 @@ public class ProductServiceImplTest extends BaseDbUnitTest { |
| 111 | 111 | // mock 数据 |
| 112 | 112 | ProductDO dbProduct = randomPojo(ProductDO.class, o -> { // 等会查询到 |
| 113 | 113 | o.setName(null); |
| 114 | - o.setIdentification(null); | |
| 115 | - o.setDeviceType(null); | |
| 116 | - o.setManufacturerName(null); | |
| 117 | - o.setModel(null); | |
| 118 | - o.setDataFormat(null); | |
| 119 | - o.setProtocolType(null); | |
| 114 | + o.setCreateTime(null); | |
| 115 | + o.setProductKey(null); | |
| 116 | + o.setProtocolId(null); | |
| 117 | + o.setCategoryId(null); | |
| 120 | 118 | o.setDescription(null); |
| 119 | + o.setValidateType(null); | |
| 121 | 120 | o.setStatus(null); |
| 122 | - o.setMetadata(null); | |
| 123 | - o.setMessageProtocol(null); | |
| 124 | - o.setProtocolName(null); | |
| 125 | - o.setCreateTime(null); | |
| 121 | + o.setDeviceType(null); | |
| 122 | + o.setNetType(null); | |
| 123 | + o.setProtocolType(null); | |
| 124 | + o.setDataFormat(null); | |
| 126 | 125 | }); |
| 127 | 126 | productMapper.insert(dbProduct); |
| 128 | 127 | // 测试 name 不匹配 |
| 129 | 128 | productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setName(null))); |
| 130 | - // 测试 identification 不匹配 | |
| 131 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setIdentification(null))); | |
| 132 | - // 测试 deviceType 不匹配 | |
| 133 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDeviceType(null))); | |
| 134 | - // 测试 manufacturerName 不匹配 | |
| 135 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setManufacturerName(null))); | |
| 136 | - // 测试 model 不匹配 | |
| 137 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setModel(null))); | |
| 138 | - // 测试 dataFormat 不匹配 | |
| 139 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDataFormat(null))); | |
| 140 | - // 测试 protocolType 不匹配 | |
| 141 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProtocolType(null))); | |
| 129 | + // 测试 createTime 不匹配 | |
| 130 | + productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setCreateTime(null))); | |
| 131 | + // 测试 productKey 不匹配 | |
| 132 | + productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProductKey(null))); | |
| 133 | + // 测试 protocolId 不匹配 | |
| 134 | + productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProtocolId(null))); | |
| 135 | + // 测试 categoryId 不匹配 | |
| 136 | + productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setCategoryId(null))); | |
| 142 | 137 | // 测试 description 不匹配 |
| 143 | 138 | productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDescription(null))); |
| 139 | + // 测试 validateType 不匹配 | |
| 140 | + productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setValidateType(null))); | |
| 144 | 141 | // 测试 status 不匹配 |
| 145 | 142 | productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setStatus(null))); |
| 146 | - // 测试 metadata 不匹配 | |
| 147 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setMetadata(null))); | |
| 148 | - // 测试 messageProtocol 不匹配 | |
| 149 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setMessageProtocol(null))); | |
| 150 | - // 测试 protocolName 不匹配 | |
| 151 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProtocolName(null))); | |
| 152 | - // 测试 createTime 不匹配 | |
| 153 | - productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setCreateTime(null))); | |
| 143 | + // 测试 deviceType 不匹配 | |
| 144 | + productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDeviceType(null))); | |
| 145 | + // 测试 netType 不匹配 | |
| 146 | + productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setNetType(null))); | |
| 147 | + // 测试 protocolType 不匹配 | |
| 148 | + productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProtocolType(null))); | |
| 149 | + // 测试 dataFormat 不匹配 | |
| 150 | + productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDataFormat(null))); | |
| 154 | 151 | // 准备参数 |
| 155 | 152 | ProductPageReqVO reqVO = new ProductPageReqVO(); |
| 156 | 153 | reqVO.setName(null); |
| 157 | - reqVO.setIdentification(null); | |
| 158 | - reqVO.setDeviceType(null); | |
| 159 | - reqVO.setManufacturerName(null); | |
| 160 | - reqVO.setModel(null); | |
| 161 | - reqVO.setDataFormat(null); | |
| 162 | - reqVO.setProtocolType(null); | |
| 154 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 155 | + reqVO.setProductKey(null); | |
| 156 | + reqVO.setProtocolId(null); | |
| 157 | + reqVO.setCategoryId(null); | |
| 163 | 158 | reqVO.setDescription(null); |
| 159 | + reqVO.setValidateType(null); | |
| 164 | 160 | reqVO.setStatus(null); |
| 165 | - reqVO.setMetadata(null); | |
| 166 | - reqVO.setMessageProtocol(null); | |
| 167 | - reqVO.setProtocolName(null); | |
| 168 | - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 161 | + reqVO.setDeviceType(null); | |
| 162 | + reqVO.setNetType(null); | |
| 163 | + reqVO.setProtocolType(null); | |
| 164 | + reqVO.setDataFormat(null); | |
| 169 | 165 | |
| 170 | 166 | // 调用 |
| 171 | 167 | PageResult<ProductDO> pageResult = productService.getProductPage(reqVO); | ... | ... |