mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 12:18:42 +08:00 
			
		
		
		
	修改:iot 产品 字段修改
This commit is contained in:
		@@ -27,7 +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;
 | 
			
		||||
 | 
			
		||||
@Tag(name = "管理后台 - iot 产品")
 | 
			
		||||
@Tag(name = "管理后台 - IOT 产品")
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/iot/product")
 | 
			
		||||
@Validated
 | 
			
		||||
 
 | 
			
		||||
@@ -18,41 +18,38 @@ public class ProductPageReqVO extends PageParam {
 | 
			
		||||
    @Schema(description = "产品名称", example = "李四")
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品标识")
 | 
			
		||||
    private String identification;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "设备类型:device、gatway、gatway_sub", example = "1")
 | 
			
		||||
    private String deviceType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "厂商名称", example = "李四")
 | 
			
		||||
    private String manufacturerName;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品型号")
 | 
			
		||||
    private String model;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "数据格式:1. 标准数据格式(JSON)2. 透传/自定义,脚本解析")
 | 
			
		||||
    private Integer dataFormat;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "设备接入平台的协议类型,默认为MQTT", example = "2")
 | 
			
		||||
    private String protocolType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品描述", example = "随便")
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品状态 (0: 启用, 1: 停用)", example = "2")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "物模型定义")
 | 
			
		||||
    private String metadata;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "消息协议ID")
 | 
			
		||||
    private Long messageProtocol;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "消息协议名称", example = "芋艿")
 | 
			
		||||
    private String protocolName;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "创建时间")
 | 
			
		||||
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
 | 
			
		||||
    private LocalDateTime[] createTime;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品标识")
 | 
			
		||||
    private String productKey;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "协议编号(脚本解析 id)", example = "13177")
 | 
			
		||||
    private Long protocolId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品所属品类标识符", example = "14237")
 | 
			
		||||
    private Long categoryId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品描述", example = "你猜")
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验", example = "1")
 | 
			
		||||
    private Integer validateType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS", example = "1")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备", example = "2")
 | 
			
		||||
    private Integer deviceType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他", 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")
 | 
			
		||||
    private Integer dataFormat;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -12,60 +12,56 @@ import com.alibaba.excel.annotation.*;
 | 
			
		||||
@ExcelIgnoreUnannotated
 | 
			
		||||
public class ProductRespVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "778")
 | 
			
		||||
    @ExcelProperty("编号")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
 | 
			
		||||
    @ExcelProperty("产品名称")
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @ExcelProperty("产品标识")
 | 
			
		||||
    private String identification;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "设备类型:device、gatway、gatway_sub", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    @ExcelProperty("设备类型:device、gatway、gatway_sub")
 | 
			
		||||
    private String deviceType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "厂商名称", example = "李四")
 | 
			
		||||
    @ExcelProperty("厂商名称")
 | 
			
		||||
    private String manufacturerName;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品型号")
 | 
			
		||||
    @ExcelProperty("产品型号")
 | 
			
		||||
    private String model;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "数据格式:1. 标准数据格式(JSON)2. 透传/自定义,脚本解析")
 | 
			
		||||
    @ExcelProperty("数据格式:1. 标准数据格式(JSON)2. 透传/自定义,脚本解析")
 | 
			
		||||
    private Integer dataFormat;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "设备接入平台的协议类型,默认为MQTT", example = "2")
 | 
			
		||||
    @ExcelProperty("设备接入平台的协议类型,默认为MQTT")
 | 
			
		||||
    private String protocolType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品描述", example = "随便")
 | 
			
		||||
    @ExcelProperty("产品描述")
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品状态 (0: 启用, 1: 停用)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
 | 
			
		||||
    @ExcelProperty("产品状态 (0: 启用, 1: 停用)")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "物模型定义", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @ExcelProperty("物模型定义")
 | 
			
		||||
    private String metadata;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "消息协议ID", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @ExcelProperty("消息协议ID")
 | 
			
		||||
    private Long messageProtocol;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "消息协议名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
 | 
			
		||||
    @ExcelProperty("消息协议名称")
 | 
			
		||||
    private String protocolName;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @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 = "协议编号(脚本解析 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13177")
 | 
			
		||||
    @ExcelProperty("协议编号(脚本解析 id)")
 | 
			
		||||
    private Long protocolId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品所属品类标识符", example = "14237")
 | 
			
		||||
    @ExcelProperty("产品所属品类标识符")
 | 
			
		||||
    private Long categoryId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品描述", example = "你猜")
 | 
			
		||||
    @ExcelProperty("产品描述")
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    @ExcelProperty("数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验")
 | 
			
		||||
    private Integer validateType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    @ExcelProperty("产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
 | 
			
		||||
    @ExcelProperty("设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备")
 | 
			
		||||
    private Integer deviceType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他", example = "2")
 | 
			
		||||
    @ExcelProperty("联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他")
 | 
			
		||||
    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")
 | 
			
		||||
    private Integer dataFormat;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1,54 +1,54 @@
 | 
			
		||||
package cn.iocoder.yudao.module.iot.controller.admin.product.vo;
 | 
			
		||||
 | 
			
		||||
import io.swagger.v3.oas.annotations.media.Schema;
 | 
			
		||||
import jakarta.validation.constraints.NotEmpty;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.*;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import jakarta.validation.constraints.*;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "管理后台 - iot 产品新增/修改 Request VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class ProductSaveReqVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "778")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "温湿度")
 | 
			
		||||
    @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
 | 
			
		||||
    @NotEmpty(message = "产品名称不能为空")
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品标识", example = "123456")
 | 
			
		||||
    private String identification;
 | 
			
		||||
    @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26087")
 | 
			
		||||
    private Long id;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "设备类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "device")
 | 
			
		||||
    @NotEmpty(message = "设备类型不能为空")
 | 
			
		||||
    private String deviceType;
 | 
			
		||||
    @Schema(description = "产品标识", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
    @NotEmpty(message = "产品标识不能为空")
 | 
			
		||||
    private String productKey;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "数据格式:1. 标准数据格式(JSON)2. 透传/自定义", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    @NotEmpty(message = "数据格式不能为空")
 | 
			
		||||
    private Integer dataFormat;
 | 
			
		||||
    @Schema(description = "协议编号(脚本解析 id)", requiredMode = Schema.RequiredMode.REQUIRED, example = "13177")
 | 
			
		||||
    @NotNull(message = "协议编号(脚本解析 id)不能为空")
 | 
			
		||||
    private Long protocolId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "设备接入平台的协议类型,默认为MQTT", requiredMode = Schema.RequiredMode.REQUIRED, example = "mqtt")
 | 
			
		||||
    @NotEmpty(message = "设备接入平台的协议类型不能为空")
 | 
			
		||||
    private String protocolType;
 | 
			
		||||
    @Schema(description = "产品所属品类标识符", example = "14237")
 | 
			
		||||
    private Long categoryId;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "厂商名称", example = "电信")
 | 
			
		||||
    private String manufacturerName;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品型号", example = "wsd-01")
 | 
			
		||||
    private String model;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品描述", example = "随便")
 | 
			
		||||
    @Schema(description = "产品描述", example = "你猜")
 | 
			
		||||
    private String description;
 | 
			
		||||
 | 
			
		||||
//    @Schema(description = "产品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
 | 
			
		||||
//    private Integer status;
 | 
			
		||||
//
 | 
			
		||||
//    @Schema(description = "物模型定义", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
//    private String metadata;
 | 
			
		||||
//
 | 
			
		||||
//    @Schema(description = "消息协议ID", requiredMode = Schema.RequiredMode.REQUIRED)
 | 
			
		||||
//    private Long messageProtocol;
 | 
			
		||||
//
 | 
			
		||||
//    @Schema(description = "消息协议名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
 | 
			
		||||
//    private String protocolName;
 | 
			
		||||
    @Schema(description = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    @NotNull(message = "数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验不能为空")
 | 
			
		||||
    private Integer validateType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
 | 
			
		||||
    @NotNull(message = "产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS不能为空")
 | 
			
		||||
    private Integer status;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
 | 
			
		||||
    @NotNull(message = "设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备不能为空")
 | 
			
		||||
    private Integer deviceType;
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他", 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")
 | 
			
		||||
    private Integer dataFormat;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -22,58 +22,54 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
 | 
			
		||||
@AllArgsConstructor
 | 
			
		||||
public class ProductDO extends BaseDO {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 编号
 | 
			
		||||
     */
 | 
			
		||||
    @TableId
 | 
			
		||||
    private Long id;
 | 
			
		||||
    /**
 | 
			
		||||
     * 产品名称
 | 
			
		||||
     */
 | 
			
		||||
    private String name;
 | 
			
		||||
    /**
 | 
			
		||||
     * 产品ID
 | 
			
		||||
     */
 | 
			
		||||
    @TableId
 | 
			
		||||
    private Long id;
 | 
			
		||||
    /**
 | 
			
		||||
     * 产品标识
 | 
			
		||||
     */
 | 
			
		||||
    private String identification;
 | 
			
		||||
    private String productKey;
 | 
			
		||||
    /**
 | 
			
		||||
     * 设备类型:device、gatway、gatway_sub
 | 
			
		||||
     * 协议编号(脚本解析 id)
 | 
			
		||||
     */
 | 
			
		||||
    private String deviceType;
 | 
			
		||||
    private Long protocolId;
 | 
			
		||||
    /**
 | 
			
		||||
     * 厂商名称
 | 
			
		||||
     * 产品所属品类标识符
 | 
			
		||||
     */
 | 
			
		||||
    private String manufacturerName;
 | 
			
		||||
    /**
 | 
			
		||||
     * 产品型号
 | 
			
		||||
     */
 | 
			
		||||
    private String model;
 | 
			
		||||
    /**
 | 
			
		||||
     * 数据格式:1. 标准数据格式(JSON)2. 透传/自定义,脚本解析
 | 
			
		||||
     */
 | 
			
		||||
    private Integer dataFormat;
 | 
			
		||||
    /**
 | 
			
		||||
     * 设备接入平台的协议类型,默认为MQTT
 | 
			
		||||
     */
 | 
			
		||||
    private String protocolType;
 | 
			
		||||
    private Long categoryId;
 | 
			
		||||
    /**
 | 
			
		||||
     * 产品描述
 | 
			
		||||
     */
 | 
			
		||||
    private String description;
 | 
			
		||||
    /**
 | 
			
		||||
     * 产品状态 (0: 启用, 1: 停用)
 | 
			
		||||
     * 数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验
 | 
			
		||||
     */
 | 
			
		||||
    private Integer validateType;
 | 
			
		||||
    /**
 | 
			
		||||
     * 产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS
 | 
			
		||||
     */
 | 
			
		||||
    private Integer status;
 | 
			
		||||
    /**
 | 
			
		||||
     * 物模型定义
 | 
			
		||||
     * 设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备
 | 
			
		||||
     */
 | 
			
		||||
    private String metadata;
 | 
			
		||||
    private Integer deviceType;
 | 
			
		||||
    /**
 | 
			
		||||
     * 消息协议ID
 | 
			
		||||
     * 联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他
 | 
			
		||||
     */
 | 
			
		||||
    private Long messageProtocol;
 | 
			
		||||
    private Integer netType;
 | 
			
		||||
    /**
 | 
			
		||||
     * 消息协议名称
 | 
			
		||||
     * 接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee
 | 
			
		||||
     */
 | 
			
		||||
    private String protocolName;
 | 
			
		||||
    private Integer protocolType;
 | 
			
		||||
    /**
 | 
			
		||||
     * 数据格式, 0: 透传模式, 1: Alink JSON
 | 
			
		||||
     */
 | 
			
		||||
    private Integer dataFormat;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 | 
			
		||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 | 
			
		||||
import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO;
 | 
			
		||||
import jakarta.validation.constraints.NotEmpty;
 | 
			
		||||
import org.apache.ibatis.annotations.Mapper;
 | 
			
		||||
import cn.iocoder.yudao.module.iot.controller.admin.product.vo.*;
 | 
			
		||||
 | 
			
		||||
@@ -21,22 +20,18 @@ public interface ProductMapper extends BaseMapperX<ProductDO> {
 | 
			
		||||
    default PageResult<ProductDO> selectPage(ProductPageReqVO reqVO) {
 | 
			
		||||
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductDO>()
 | 
			
		||||
                .likeIfPresent(ProductDO::getName, reqVO.getName())
 | 
			
		||||
                .eqIfPresent(ProductDO::getIdentification, reqVO.getIdentification())
 | 
			
		||||
                .eqIfPresent(ProductDO::getDeviceType, reqVO.getDeviceType())
 | 
			
		||||
                .likeIfPresent(ProductDO::getManufacturerName, reqVO.getManufacturerName())
 | 
			
		||||
                .eqIfPresent(ProductDO::getModel, reqVO.getModel())
 | 
			
		||||
                .eqIfPresent(ProductDO::getDataFormat, reqVO.getDataFormat())
 | 
			
		||||
                .eqIfPresent(ProductDO::getProtocolType, reqVO.getProtocolType())
 | 
			
		||||
                .eqIfPresent(ProductDO::getDescription, reqVO.getDescription())
 | 
			
		||||
                .eqIfPresent(ProductDO::getStatus, reqVO.getStatus())
 | 
			
		||||
                .eqIfPresent(ProductDO::getMetadata, reqVO.getMetadata())
 | 
			
		||||
                .eqIfPresent(ProductDO::getMessageProtocol, reqVO.getMessageProtocol())
 | 
			
		||||
                .likeIfPresent(ProductDO::getProtocolName, reqVO.getProtocolName())
 | 
			
		||||
                .betweenIfPresent(ProductDO::getCreateTime, reqVO.getCreateTime())
 | 
			
		||||
                .eqIfPresent(ProductDO::getProductKey, reqVO.getProductKey())
 | 
			
		||||
                .eqIfPresent(ProductDO::getProtocolId, reqVO.getProtocolId())
 | 
			
		||||
                .eqIfPresent(ProductDO::getCategoryId, reqVO.getCategoryId())
 | 
			
		||||
                .eqIfPresent(ProductDO::getDescription, reqVO.getDescription())
 | 
			
		||||
                .eqIfPresent(ProductDO::getValidateType, reqVO.getValidateType())
 | 
			
		||||
                .eqIfPresent(ProductDO::getStatus, reqVO.getStatus())
 | 
			
		||||
                .eqIfPresent(ProductDO::getDeviceType, reqVO.getDeviceType())
 | 
			
		||||
                .eqIfPresent(ProductDO::getNetType, reqVO.getNetType())
 | 
			
		||||
                .eqIfPresent(ProductDO::getProtocolType, reqVO.getProtocolType())
 | 
			
		||||
                .eqIfPresent(ProductDO::getDataFormat, reqVO.getDataFormat())
 | 
			
		||||
                .orderByDesc(ProductDO::getId));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default ProductDO selectByIdentification(String identification){
 | 
			
		||||
        return selectOne(new LambdaQueryWrapperX<ProductDO>().eq(ProductDO::getIdentification, identification));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,21 +1,20 @@
 | 
			
		||||
package cn.iocoder.yudao.module.iot.service.product;
 | 
			
		||||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import jakarta.validation.*;
 | 
			
		||||
import cn.iocoder.yudao.module.iot.controller.admin.product.vo.*;
 | 
			
		||||
import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
 | 
			
		||||
import cn.iocoder.yudao.module.iot.controller.admin.product.vo.ProductPageReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.iot.controller.admin.product.vo.ProductSaveReqVO;
 | 
			
		||||
import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO;
 | 
			
		||||
import jakarta.validation.Valid;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * iot 产品 Service 接口
 | 
			
		||||
 * IOT 产品 Service 接口
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
public interface ProductService {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 创建iot 产品
 | 
			
		||||
     * 创建产品
 | 
			
		||||
     *
 | 
			
		||||
     * @param createReqVO 创建信息
 | 
			
		||||
     * @return 编号
 | 
			
		||||
@@ -23,32 +22,32 @@ public interface ProductService {
 | 
			
		||||
    Long createProduct(@Valid ProductSaveReqVO createReqVO);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新iot 产品
 | 
			
		||||
     * 更新产品
 | 
			
		||||
     *
 | 
			
		||||
     * @param updateReqVO 更新信息
 | 
			
		||||
     */
 | 
			
		||||
    void updateProduct(@Valid ProductSaveReqVO updateReqVO);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除iot 产品
 | 
			
		||||
     * 删除产品
 | 
			
		||||
     *
 | 
			
		||||
     * @param id 编号
 | 
			
		||||
     */
 | 
			
		||||
    void deleteProduct(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得iot 产品
 | 
			
		||||
     * 获得产品
 | 
			
		||||
     *
 | 
			
		||||
     * @param id 编号
 | 
			
		||||
     * @return iot 产品
 | 
			
		||||
     * @return 产品
 | 
			
		||||
     */
 | 
			
		||||
    ProductDO getProduct(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获得iot 产品分页
 | 
			
		||||
     * 获得产品分页
 | 
			
		||||
     *
 | 
			
		||||
     * @param pageReqVO 分页查询
 | 
			
		||||
     * @return iot 产品分页
 | 
			
		||||
     * @return 产品分页
 | 
			
		||||
     */
 | 
			
		||||
    PageResult<ProductDO> getProductPage(ProductPageReqVO pageReqVO);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,5 @@
 | 
			
		||||
package cn.iocoder.yudao.module.iot.service.product;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.util.IdUtil;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
 | 
			
		||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 | 
			
		||||
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;
 | 
			
		||||
import cn.iocoder.yudao.module.iot.dal.dataobject.product.ProductDO;
 | 
			
		||||
import cn.iocoder.yudao.module.iot.dal.mysql.product.ProductMapper;
 | 
			
		||||
import jakarta.annotation.Resource;
 | 
			
		||||
import jakarta.validation.constraints.NotEmpty;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.validation.annotation.Validated;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 | 
			
		||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PRODUCT_IDENTIFICATION_EXISTS;
 | 
			
		||||
import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.PRODUCT_NOT_EXISTS;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * iot 产品 Service 实现类
 | 
			
		||||
 * IOT 产品 Service 实现类
 | 
			
		||||
 *
 | 
			
		||||
 * @author 芋道源码
 | 
			
		||||
 */
 | 
			
		||||
@@ -31,10 +27,6 @@ public class ProductServiceImpl implements ProductService {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Long createProduct(ProductSaveReqVO createReqVO) {
 | 
			
		||||
        // 不传自动生成产品标识
 | 
			
		||||
        createIdentification(createReqVO);
 | 
			
		||||
        // 校验产品标识是否重复
 | 
			
		||||
        validateProductIdentification(createReqVO.getIdentification());
 | 
			
		||||
        // 插入
 | 
			
		||||
        ProductDO product = BeanUtils.toBean(createReqVO, ProductDO.class);
 | 
			
		||||
        productMapper.insert(product);
 | 
			
		||||
@@ -42,20 +34,6 @@ public class ProductServiceImpl implements ProductService {
 | 
			
		||||
        return product.getId();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void validateProductIdentification(@NotEmpty(message = "产品标识不能为空") String identification) {
 | 
			
		||||
        if (productMapper.selectByIdentification(identification) != null) {
 | 
			
		||||
            throw exception(PRODUCT_IDENTIFICATION_EXISTS);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void createIdentification(ProductSaveReqVO createReqVO) {
 | 
			
		||||
        if (StrUtil.isNotBlank(createReqVO.getIdentification())) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        // 生成 19 位数字
 | 
			
		||||
        createReqVO.setIdentification(String.valueOf(IdUtil.getSnowflake(1, 1).nextId()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void updateProduct(ProductSaveReqVO updateReqVO) {
 | 
			
		||||
        // 校验存在
 | 
			
		||||
@@ -89,7 +67,4 @@ public class ProductServiceImpl implements ProductService {
 | 
			
		||||
        return productMapper.selectPage(pageReqVO);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        System.out.println(String.valueOf(IdUtil.getSnowflake(1, 1).nextId()));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -111,61 +111,57 @@ public class ProductServiceImplTest extends BaseDbUnitTest {
 | 
			
		||||
       // mock 数据
 | 
			
		||||
       ProductDO dbProduct = randomPojo(ProductDO.class, o -> { // 等会查询到
 | 
			
		||||
           o.setName(null);
 | 
			
		||||
           o.setIdentification(null);
 | 
			
		||||
           o.setDeviceType(null);
 | 
			
		||||
           o.setManufacturerName(null);
 | 
			
		||||
           o.setModel(null);
 | 
			
		||||
           o.setDataFormat(null);
 | 
			
		||||
           o.setProtocolType(null);
 | 
			
		||||
           o.setDescription(null);
 | 
			
		||||
           o.setStatus(null);
 | 
			
		||||
           o.setMetadata(null);
 | 
			
		||||
           o.setMessageProtocol(null);
 | 
			
		||||
           o.setProtocolName(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)));
 | 
			
		||||
       // 测试 identification 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setIdentification(null)));
 | 
			
		||||
       // 测试 deviceType 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDeviceType(null)));
 | 
			
		||||
       // 测试 manufacturerName 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setManufacturerName(null)));
 | 
			
		||||
       // 测试 model 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setModel(null)));
 | 
			
		||||
       // 测试 dataFormat 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDataFormat(null)));
 | 
			
		||||
       // 测试 protocolType 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProtocolType(null)));
 | 
			
		||||
       // 测试 description 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setDescription(null)));
 | 
			
		||||
       // 测试 status 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setStatus(null)));
 | 
			
		||||
       // 测试 metadata 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setMetadata(null)));
 | 
			
		||||
       // 测试 messageProtocol 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setMessageProtocol(null)));
 | 
			
		||||
       // 测试 protocolName 不匹配
 | 
			
		||||
       productMapper.insert(cloneIgnoreId(dbProduct, o -> o.setProtocolName(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.setIdentification(null);
 | 
			
		||||
       reqVO.setDeviceType(null);
 | 
			
		||||
       reqVO.setManufacturerName(null);
 | 
			
		||||
       reqVO.setModel(null);
 | 
			
		||||
       reqVO.setDataFormat(null);
 | 
			
		||||
       reqVO.setProtocolType(null);
 | 
			
		||||
       reqVO.setDescription(null);
 | 
			
		||||
       reqVO.setStatus(null);
 | 
			
		||||
       reqVO.setMetadata(null);
 | 
			
		||||
       reqVO.setMessageProtocol(null);
 | 
			
		||||
       reqVO.setProtocolName(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<ProductDO> pageResult = productService.getProductPage(reqVO);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user