mapstruct配置

V0.5.x
jay 2023-06-05 11:07:27 +08:00
parent 4125b71352
commit f4b588fa46
15 changed files with 259 additions and 168 deletions

View File

@ -33,8 +33,9 @@
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.32</version>
</dependency>
<dependency>

View File

@ -9,7 +9,7 @@ import io.github.linpeilie.annotations.MapperConfig;
* @Version: V1.0
* @Description: mapperstruct
*/
@MapperConfig
@ComponentModelConfig(componentModel = "default")
@MapperConfig(mapperPackage = "cc.iotkit.data.model")
public class AutoMapperConfig3 {
}

View File

@ -116,7 +116,10 @@
<groupId>cc.iotkit</groupId>
<artifactId>iot-common-log</artifactId>
</dependency>
<dependency>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
@ -124,9 +127,28 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>${java.version}</source> <!-- depending on your project -->
<target>${java.version}</target> <!-- depending on your project -->
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-processor</artifactId>
<version>${mapstruct-plus.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
<!-- other annotation processors -->
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>

View File

@ -9,7 +9,7 @@ import io.github.linpeilie.annotations.MapperConfig;
* @Version: V1.0
* @Description: mapperstruct
*/
@MapperConfig
@MapperConfig(mapperPackage = "cc.iotkit.manager.dto")
@ComponentModelConfig(componentModel = "default")
public class AutoMapperConfig2 {
}

View File

@ -3,6 +3,8 @@ package cc.iotkit.manager.dto.bo.device;
import cc.iotkit.model.device.DeviceInfo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;
import jakarta.validation.constraints.Size;
import org.springframework.format.annotation.DateTimeFormat;
@ -26,49 +28,51 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = DeviceInfo.class, reverseConvertGenerate = false)
public class DeviceInfoBo extends BaseDto {
public class DeviceInfoBo extends BaseDto {
private static final long serialVersionUID = -1L;
private static final long serialVersionUID = -1L;
@ApiModelProperty(value="创建时间")
private Long createAt;
@ApiModelProperty(value = "创建时间")
private Long createAt;
@ApiModelProperty(value="设备id")
@Size(max = 255, message = "设备id长度不正确")
private String deviceId;
@ApiModelProperty(value = "设备id")
@Size(max = 255, message = "设备id长度不正确")
private String deviceId;
@ApiModelProperty(value="设备名称")
@Size(max = 255, message = "设备名称长度不正确")
private String deviceName;
@ApiModelProperty(value = "设备名称")
@Size(max = 255, message = "设备名称长度不正确")
private String deviceName;
@ApiModelProperty(value="设备类型")
@Size(max = 255, message = "设备类型长度不正确")
private String model;
@ApiModelProperty(value = "设备类型")
@Size(max = 255, message = "设备类型长度不正确")
private String model;
@ApiModelProperty(value="设备离线时间")
private Long offlineTime;
@ApiModelProperty(value = "设备离线时间")
private Long offlineTime;
@ApiModelProperty(value="设备在线时间")
private Long onlineTime;
@ApiModelProperty(value = "设备在线时间")
private Long onlineTime;
@ApiModelProperty(value="父级id")
@Size(max = 255, message = "父级id长度不正确")
private String parentId;
@ApiModelProperty(value = "父级id")
@Size(max = 255, message = "父级id长度不正确")
private String parentId;
@ApiModelProperty(value="产品key")
@Size(max = 255, message = "产品key长度不正确")
private String productKey;
@ApiModelProperty(value = "产品key")
@Size(max = 255, message = "产品key长度不正确")
private String productKey;
@ApiModelProperty(value="设备描述")
@Size(max = 255, message = "设备描述长度不正确")
private String secret;
@ApiModelProperty(value = "设备描述")
@Size(max = 255, message = "设备描述长度不正确")
private String secret;
@ApiModelProperty(value="设备状态")
@Size(max = 255, message = "设备状态长度不正确")
private String state;
@ApiModelProperty(value = "设备状态")
@Size(max = 255, message = "设备状态长度不正确")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String state;
@ApiModelProperty(value="用户id")
@Size(max = 255, message = "用户id长度不正确")
private String uid;
@ApiModelProperty(value = "用户id")
@Size(max = 255, message = "用户id长度不正确")
private String uid;
}
}

View File

@ -13,6 +13,8 @@ import cc.iotkit.common.api.BaseDto;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.model.product.Category;
import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.Size;
@ -30,6 +32,8 @@ public class DeviceQueryBo extends BaseDto {
private String keyword;
@ApiModelProperty(value="分组")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String group;
@ApiModelProperty(value="设备id")
@ -55,6 +59,8 @@ public class DeviceQueryBo extends BaseDto {
@ApiModelProperty(value="设备状态")
@Size(max = 255, message = "设备状态长度不正确")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String state;
@ApiModelProperty(value="用户id")

View File

@ -3,6 +3,8 @@ package cc.iotkit.manager.dto.bo.ruleinfo;
import cc.iotkit.model.rule.RuleInfo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;
import org.springframework.format.annotation.DateTimeFormat;
import io.swagger.annotations.ApiModel;
@ -27,46 +29,52 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = RuleInfo.class, reverseConvertGenerate = false)
public class RuleInfoBo extends BaseDto {
public class RuleInfoBo extends BaseDto {
private static final long serialVersionUID = -1L;
private static final long serialVersionUID = -1L;
@ApiModelProperty(value="id")
private String id;
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value="动作")
@Size(max = 65535, message = "动作长度不正确")
private String actions;
@ApiModelProperty(value = "动作")
@Size(max = 65535, message = "动作长度不正确")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String actions;
@ApiModelProperty(value="创建时间")
private Long createAt;
@ApiModelProperty(value = "创建时间")
private Long createAt;
@ApiModelProperty(value="描述")
@Size(max = 255, message = "描述长度不正确")
private String desc;
@ApiModelProperty(value = "描述")
@Size(max = 255, message = "描述长度不正确")
private String desc;
@ApiModelProperty(value="过滤器")
@Size(max = 65535, message = "过滤器长度不正确")
private String filters;
@ApiModelProperty(value = "过滤器")
@Size(max = 65535, message = "过滤器长度不正确")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String filters;
@ApiModelProperty(value="监听器")
@Size(max = 65535, message = "监听器长度不正确")
private String listeners;
@ApiModelProperty(value = "监听器")
@Size(max = 65535, message = "监听器长度不正确")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String listeners;
@ApiModelProperty(value="规则名称")
@Size(max = 255, message = "规则名称长度不正确")
private String name;
@ApiModelProperty(value = "规则名称")
@Size(max = 255, message = "规则名称长度不正确")
private String name;
@ApiModelProperty(value="状态")
@Size(max = 255, message = "状态长度不正确")
private String state;
@ApiModelProperty(value = "状态")
@Size(max = 255, message = "状态长度不正确")
private String state;
@ApiModelProperty(value="规则类型")
@Size(max = 255, message = "规则类型长度不正确")
private String type;
@ApiModelProperty(value = "规则类型")
@Size(max = 255, message = "规则类型长度不正确")
private String type;
@ApiModelProperty(value="用户id")
@Size(max = 255, message = "用户id长度不正确")
private String uid;
@ApiModelProperty(value = "用户id")
@Size(max = 255, message = "用户id长度不正确")
private String uid;
}
}

View File

@ -3,6 +3,8 @@ package cc.iotkit.manager.dto.bo.taskinfo;
import cc.iotkit.model.rule.TaskInfo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;
import jakarta.validation.constraints.Size;
import org.springframework.format.annotation.DateTimeFormat;
@ -27,43 +29,45 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = TaskInfo.class, reverseConvertGenerate = false)
public class TaskInfoBo extends BaseDto {
public class TaskInfoBo extends BaseDto {
private static final long serialVersionUID = -1L;
private static final long serialVersionUID = -1L;
@ApiModelProperty(value="任务输出")
@Size(max = 65535, message = "任务输出长度不正确")
private String actions;
@ApiModelProperty(value = "任务输出")
@Size(max = 65535, message = "任务输出长度不正确")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String actions;
@ApiModelProperty(value="创建时间")
private Long createAt;
@ApiModelProperty(value = "创建时间")
private Long createAt;
@ApiModelProperty(value="描述")
@Size(max = 255, message = "描述长度不正确")
private String desc;
@ApiModelProperty(value = "描述")
@Size(max = 255, message = "描述长度不正确")
private String desc;
@ApiModelProperty(value="表达式")
@Size(max = 255, message = "表达式长度不正确")
private String expression;
@ApiModelProperty(value = "表达式")
@Size(max = 255, message = "表达式长度不正确")
private String expression;
@ApiModelProperty(value="任务名称")
@Size(max = 255, message = "任务名称长度不正确")
private String name;
@ApiModelProperty(value = "任务名称")
@Size(max = 255, message = "任务名称长度不正确")
private String name;
@ApiModelProperty(value="操作备注")
@Size(max = 255, message = "操作备注长度不正确")
private String reason;
@ApiModelProperty(value = "操作备注")
@Size(max = 255, message = "操作备注长度不正确")
private String reason;
@ApiModelProperty(value="任务状态")
@Size(max = 255, message = "任务状态长度不正确")
private String state;
@ApiModelProperty(value = "任务状态")
@Size(max = 255, message = "任务状态长度不正确")
private String state;
@ApiModelProperty(value="任务类型")
@Size(max = 255, message = "任务类型长度不正确")
private String type;
@ApiModelProperty(value = "任务类型")
@Size(max = 255, message = "任务类型长度不正确")
private String type;
@ApiModelProperty(value="创建者")
@Size(max = 255, message = "创建者长度不正确")
private String uid;
@ApiModelProperty(value = "创建者")
@Size(max = 255, message = "创建者长度不正确")
private String uid;
}
}

View File

@ -3,6 +3,8 @@ package cc.iotkit.manager.dto.bo.thingmodel;
import cc.iotkit.model.product.ThingModel;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;
import org.springframework.format.annotation.DateTimeFormat;
import io.swagger.annotations.ApiModel;
@ -28,16 +30,18 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = ThingModel.class, reverseConvertGenerate = false)
public class ThingModelBo extends BaseDto {
public class ThingModelBo extends BaseDto {
private static final long serialVersionUID = -1L;
private static final long serialVersionUID = -1L;
@ApiModelProperty(value="模型内容")
@Size(max = 65535, message = "模型内容长度不正确")
private String model;
@ApiModelProperty(value = "模型内容")
@Size(max = 65535, message = "模型内容长度不正确")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String model;
@ApiModelProperty(value="产品key")
@Size(max = 255, message = "产品key长度不正确")
private String productKey;
@ApiModelProperty(value = "产品key")
@Size(max = 255, message = "产品key长度不正确")
private String productKey;
}
}

View File

@ -1,6 +1,8 @@
package cc.iotkit.manager.dto.vo.deviceinfo;
import cc.iotkit.model.device.DeviceInfo;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -67,6 +69,8 @@ public class DeviceInfoVo implements Serializable {
@ApiModelProperty(value = "设备状态")
@ExcelProperty(value = "设备状态")
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String state;
@ApiModelProperty(value = "用户id")

View File

@ -1,13 +1,17 @@
package cc.iotkit.manager.dto.vo.ruleinfo;
import cc.iotkit.model.rule.RuleInfo;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
import java.io.Serializable;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
@ -19,50 +23,55 @@ import io.github.linpeilie.annotations.AutoMapper;
@ExcelIgnoreUnannotated
@AutoMapper(target = RuleInfo.class)
public class RuleInfoVo implements Serializable {
public class RuleInfoVo implements Serializable {
private static final long serialVersionUID = -1L;
private static final long serialVersionUID = -1L;
@ApiModelProperty(value="规则id")
@ApiModelProperty(value = "规则id")
@ExcelProperty(value = "规则id")
private String id;
private String id;
@ApiModelProperty(value="动作")
@ApiModelProperty(value = "动作")
@ExcelProperty(value = "动作")
private String actions;
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String actions;
@ApiModelProperty(value="创建时间")
@ApiModelProperty(value = "创建时间")
@ExcelProperty(value = "创建时间")
private Long createAt;
private Long createAt;
@ApiModelProperty(value="描述")
@ApiModelProperty(value = "描述")
@ExcelProperty(value = "描述")
private String desc;
private String desc;
@ApiModelProperty(value="过滤器")
@ApiModelProperty(value = "过滤器")
@ExcelProperty(value = "过滤器")
private String filters;
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String filters;
@ApiModelProperty(value="监听器")
@ApiModelProperty(value = "监听器")
@ExcelProperty(value = "监听器")
private String listeners;
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String listeners;
@ApiModelProperty(value="规则名称")
@ApiModelProperty(value = "规则名称")
@ExcelProperty(value = "规则名称")
private String name;
private String name;
@ApiModelProperty(value="状态")
@ApiModelProperty(value = "状态")
@ExcelProperty(value = "状态")
private String state;
private String state;
@ApiModelProperty(value="规则类型")
@ApiModelProperty(value = "规则类型")
@ExcelProperty(value = "规则类型")
private String type;
private String type;
@ApiModelProperty(value="用户id")
@ApiModelProperty(value = "用户id")
@ExcelProperty(value = "用户id")
private String uid;
private String uid;
}

View File

@ -1,13 +1,17 @@
package cc.iotkit.manager.dto.vo.taskinfo;
import cc.iotkit.model.rule.TaskInfo;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
import java.io.Serializable;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
@ -19,50 +23,51 @@ import io.github.linpeilie.annotations.AutoMapper;
@ExcelIgnoreUnannotated
@AutoMapper(target = TaskInfo.class)
public class TaskInfoVo implements Serializable {
public class TaskInfoVo implements Serializable {
private static final long serialVersionUID = -1L;
private static final long serialVersionUID = -1L;
@ApiModelProperty(value="主键")
@ApiModelProperty(value = "主键")
@ExcelProperty(value = "主键")
private String id;
private String id;
@ApiModelProperty(value="任务输出")
@ApiModelProperty(value = "任务输出")
@ExcelProperty(value = "任务输出")
private String actions;
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String actions;
@ApiModelProperty(value="创建时间")
@ApiModelProperty(value = "创建时间")
@ExcelProperty(value = "创建时间")
private Long createAt;
private Long createAt;
@ApiModelProperty(value="描述")
@ApiModelProperty(value = "描述")
@ExcelProperty(value = "描述")
private String desc;
private String desc;
@ApiModelProperty(value="表达式")
@ApiModelProperty(value = "表达式")
@ExcelProperty(value = "表达式")
private String expression;
private String expression;
@ApiModelProperty(value="任务名称")
@ApiModelProperty(value = "任务名称")
@ExcelProperty(value = "任务名称")
private String name;
private String name;
@ApiModelProperty(value="操作备注")
@ApiModelProperty(value = "操作备注")
@ExcelProperty(value = "操作备注")
private String reason;
private String reason;
@ApiModelProperty(value="任务状态")
@ApiModelProperty(value = "任务状态")
@ExcelProperty(value = "任务状态")
private String state;
private String state;
@ApiModelProperty(value="任务类型")
@ApiModelProperty(value = "任务类型")
@ExcelProperty(value = "任务类型")
private String type;
private String type;
@ApiModelProperty(value="创建者")
@ApiModelProperty(value = "创建者")
@ExcelProperty(value = "创建者")
private String uid;
private String uid;
}

View File

@ -1,13 +1,17 @@
package cc.iotkit.manager.dto.vo.thingmodel;
import cc.iotkit.model.product.ThingModel;
import io.github.linpeilie.annotations.AutoMapping;
import io.github.linpeilie.annotations.ReverseAutoMapping;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
import java.io.Serializable;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
@ -19,22 +23,23 @@ import io.github.linpeilie.annotations.AutoMapper;
@ExcelIgnoreUnannotated
@AutoMapper(target = ThingModel.class)
public class ThingModelVo implements Serializable {
public class ThingModelVo implements Serializable {
private static final long serialVersionUID = -1L;
private static final long serialVersionUID = -1L;
@ApiModelProperty(value="主键")
@ApiModelProperty(value = "主键")
@ExcelProperty(value = "主键")
private String id;
private String id;
@ApiModelProperty(value="模型内容")
@ApiModelProperty(value = "模型内容")
@ExcelProperty(value = "模型内容")
private String model;
@AutoMapping(ignore = true)
@ReverseAutoMapping(ignore = true)
private String model;
@ApiModelProperty(value="产品key")
@ApiModelProperty(value = "产品key")
@ExcelProperty(value = "产品key")
private String productKey;
private String productKey;
}

View File

@ -71,9 +71,28 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>${java.version}</source> <!-- depending on your project -->
<target>${java.version}</target> <!-- depending on your project -->
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>io.github.linpeilie</groupId>
<artifactId>mapstruct-plus-processor</artifactId>
<version>${mapstruct-plus.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
<!-- other annotation processors -->
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>

View File

@ -9,7 +9,7 @@ import io.github.linpeilie.annotations.MapperConfig;
* @Version: V1.0
* @Description: mapperstruct
*/
@MapperConfig()
@MapperConfig(mapperPackage = "cc.iotkit.system.dto")
@ComponentModelConfig(componentModel = "default")
public class AutoMapperConfig {
}