diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/pom.xml b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/pom.xml index dedbf253..e4e81e75 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/pom.xml +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/pom.xml @@ -28,12 +28,6 @@ spring-boot-starter-web - - - com.orion.ops - orion-ops-spring-boot-starter-datasource - - com.baomidou @@ -47,6 +41,19 @@ org.apache.velocity velocity-engine-core + + + + org.springdoc + springdoc-openapi-ui + provided + + + + + com.mysql + mysql-connector-j + \ No newline at end of file diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/domain/BaseDO.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/domain/BaseDO.java index 06949f66..b49a79e2 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/domain/BaseDO.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/domain/BaseDO.java @@ -3,6 +3,7 @@ package com.orion.ops.framework.mybatis.core.domain; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableLogic; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.apache.ibatis.type.JdbcType; @@ -19,37 +20,28 @@ import java.util.Date; @Data public class BaseDO implements Serializable { - /** - * 创建时间 - */ @TableField(fill = FieldFill.INSERT) + @Schema(description = "创建时间") private Date createTime; - /** - * 更新时间 - */ @TableField(fill = FieldFill.INSERT_UPDATE) + @Schema(description = "修改时间") private Date updateTime; - /** - * 创建人 - */ @TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.VARCHAR) + @Schema(description = "创建人") private String creator; - /** - * 更新人 - */ @TableField(fill = FieldFill.INSERT_UPDATE, jdbcType = JdbcType.VARCHAR) + @Schema(description = "修改人") private String updater; /** - * 是否删除 0未删除 1已删除 - * * @see com.orion.ops.framework.common.constant.Const#NOT_DELETE * @see com.orion.ops.framework.common.constant.Const#IS_DELETED */ @TableLogic + @Schema(description = "是否删除 0未删除 1已删除") private Boolean deleted; } diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerator.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerator.java index 72596187..25bb75c7 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerator.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerator.java @@ -2,10 +2,8 @@ package com.orion.ops.framework.mybatis.core.generator; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.generator.AutoGenerator; -import com.baomidou.mybatisplus.generator.config.DataSourceConfig; -import com.baomidou.mybatisplus.generator.config.GlobalConfig; -import com.baomidou.mybatisplus.generator.config.PackageConfig; -import com.baomidou.mybatisplus.generator.config.StrategyConfig; +import com.baomidou.mybatisplus.generator.config.*; +import com.baomidou.mybatisplus.generator.config.builder.CustomFile; import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert; import com.baomidou.mybatisplus.generator.config.querys.MySqlQuery; import com.baomidou.mybatisplus.generator.config.rules.DateType; @@ -21,7 +19,11 @@ import org.apache.ibatis.annotations.Mapper; import java.io.File; /** + * 代码生成器 + * * @author Jiahang Li + * @version 1.0.0 + * @since 2022/4/20 10:33 */ public class CodeGenerator { @@ -29,9 +31,9 @@ public class CodeGenerator { String outputDir = "D:/MP/"; String author = Const.ORION_AUTHOR; // 表名 - String[] tables = {"user_info"}; + String[] tables = {"test_table"}; // 模块 - String module = "user"; + String module = "infra"; // 连接 File yamlFile = new File("orion-ops-launch/src/main/resources/application-dev.yaml"); YmlExt yaml = YmlExt.load(yamlFile); @@ -56,30 +58,83 @@ public class CodeGenerator { String password, String[] tables, String module) { + // 获取全局配置 + GlobalConfig globalConfig = getGlobalConfig(outputDir, author); + // 数据源配置 + DataSourceConfig dataSourceConfig = getDataSourceConfig(url, username, password); + + // 策略配置 + StrategyConfig strategyConfig = getStrategyConfig(tables); + + // 包名配置 + PackageConfig packageConfig = getPackageConfig(module); + + // 模板配置 + TemplateConfig templateConfig = getTemplateConfig(); + + // 注入配置 + InjectionConfig injectionConfig = getInjectionConfig(); + + // 整合配置 + AutoGenerator ag = new AutoGenerator(dataSourceConfig) + // 整合全局配置 + .global(globalConfig) + // 整合表名配置 + .strategy(strategyConfig) + // 整合包名配置 + .packageInfo(packageConfig) + // 整合模板配置 + .template(templateConfig) + // 整合注入配置 + .injection(injectionConfig); + + // 执行 + ag.execute(); + } + + /** + * 获取全局配置 + * + * @param outputDir 输出地址 + * @param author 作者 + * @return config + */ + private static GlobalConfig getGlobalConfig(String outputDir, String author) { // 全局配置 GlobalConfig gbConfig = new GlobalConfig.Builder() // 设置作者 .author(author) // 生成路径 .outputDir(outputDir) - // 生成 swagger 注解 - .enableSwagger() // 生成 spring doc 注解 .enableSpringdoc() // date类型 .dateType(DateType.ONLY_DATE) // 注释时间 - .commentDate("yyyy-MM-dd") + .commentDate("yyyy-M-d HH:mm") // 构建 .build(); + return gbConfig; + } - // 数据源配置 + /** + * 获取数据源配置 + * + * @param url url + * @param username username + * @param password password + * @return 数据源配置 + */ + private static DataSourceConfig getDataSourceConfig(String url, String username, String password) { DataSourceConfig dsConfig = new DataSourceConfig.Builder(url, username, password) // 转换器 .typeConvert(new MySqlTypeConvert() { @Override public IColumnType processTypeConvert(GlobalConfig globalConfig, String fieldType) { + if (fieldType.toLowerCase().contains("bit")) { + return DbColumnType.INTEGER; + } if (fieldType.toLowerCase().contains("tinyint")) { return DbColumnType.INTEGER; } @@ -90,8 +145,16 @@ public class CodeGenerator { .dbQuery(new MySqlQuery()) // 构建 .build(); + return dsConfig; + } - // 策略配置 + /** + * 获取策略配置 + * + * @param tables 生成的表名 + * @return 策略配置 + */ + private static StrategyConfig getStrategyConfig(String[] tables) { StrategyConfig stConfig = new StrategyConfig.Builder() // 生成的表 .addInclude(tables) @@ -131,13 +194,41 @@ public class CodeGenerator { .formatXmlFileName("%sMapper") // 覆盖 mapper 文件 .enableFileOverride() + // controller 配置 + .controllerBuilder() + // controller 文件名称 + .formatFileName("%sController") + // 脊柱命名法 + .enableHyphenStyle() + // @RestController + .enableRestStyle() + // 覆盖 controller 文件 + .enableFileOverride() + // service 配置 + .serviceBuilder() + // 覆盖 service 文件 + .enableFileOverride() + // service 名称 + .formatServiceFileName("%sService") + // service impl 名称 + .formatServiceImplFileName("%sServiceImpl") // 构建 .build(); + return stConfig; + } - // 包名策略配置 + /** + * 获取包名配置 + * + * @param module 模块 + * @return 包名配置 + */ + private static PackageConfig getPackageConfig(String module) { PackageConfig pkConfig = new PackageConfig.Builder() // 声明父包 - .parent("com.orion.ops.module." + module) + .parent("com.orion.ops.module") + // 模块名称 + .moduleName(module) // 实体类的包 .entity("entity.domain") // 映射接口的包 @@ -152,23 +243,77 @@ public class CodeGenerator { .controller("controller") // 构建 .build(); + return pkConfig; + } - // 整合配置 - AutoGenerator ag = new AutoGenerator(dsConfig) - // 整合全局配置 - .global(gbConfig) - // 整合表名配置 - .strategy(stConfig) - // 整合包名策略 - .packageInfo(pkConfig) - // TODO 自定义convert文件 request VO - // .injection() - // TODO 自定义模板以及convert文件 - // .template() - ; + /** + * 获取模板配置 + * + * @return 模板配置 + */ + private static TemplateConfig getTemplateConfig() { + TemplateConfig tplConfig = new TemplateConfig.Builder() + .controller("/templates/orion-controller.java.vm") + .entity("/templates/orion-domain.java.vm") + .service("/templates/orion-service.java.vm") + .serviceImpl("/templates/orion-service-impl.java.vm") + .mapper("/templates/orion-dao.java.vm") + .xml("/templates/orion-mapper.xml") + .build(); + return tplConfig; + } - // 执行 - ag.execute(); + /** + * 获取注入配置 + * + * @return 注入配置 + */ + private static InjectionConfig getInjectionConfig() { + // vo 文件 + CustomFile voFile = new CustomFile.Builder() + .enableFileOverride() + .templatePath("/templates/orion-vo.java.vm") + .fileName("VO.java") + .packageName("vo") + .build(); + + // dto 文件 + CustomFile dtoFile = new CustomFile.Builder() + .enableFileOverride() + .templatePath("/templates/orion-dto.java.vm") + .fileName("DTO.java") + .packageName("dto") + .build(); + + // request 文件 + CustomFile requestFile = new CustomFile.Builder() + .enableFileOverride() + .templatePath("/templates/orion-request.java.vm") + .fileName("Request.java") + .packageName("request") + .build(); + + // convert 文件 + CustomFile convertFile = new CustomFile.Builder() + .enableFileOverride() + .templatePath("/templates/orion-convert.java.vm") + .fileName("Convert.java") + .packageName("convert") + .build(); + + // 注入配置 + InjectionConfig injection = new InjectionConfig.Builder() + // vo 文件 + .customFile(voFile) + // dto 文件 + .customFile(dtoFile) + // request 文件 + .customFile(requestFile) + // convert 文件 + .customFile(convertFile) + // 构建 + .build(); + return injection; } } diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/mapper/IMapper.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/mapper/IMapper.java index 38146b2b..84d301f7 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/mapper/IMapper.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/mapper/IMapper.java @@ -2,6 +2,7 @@ package com.orion.ops.framework.mybatis.core.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.toolkit.Db; +import com.orion.ops.framework.mybatis.core.query.CacheQuery; import com.orion.ops.framework.mybatis.core.query.DataQuery; import java.util.Collection; @@ -97,4 +98,13 @@ public interface IMapper extends BaseMapper { return DataQuery.of(this); } + /** + * 获取 CacheQuery 对象 + * + * @return CacheQuery + */ + default CacheQuery cache() { + return CacheQuery.of(this); + } + } diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-controller.java.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-controller.java.vm new file mode 100644 index 00000000..46722c0f --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-controller.java.vm @@ -0,0 +1,46 @@ +package ${package.Controller}; + +import com.orion.ops.framework.common.annotation.RestWrapper; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestMapping; + #if(${restControllerStyle}) + import org.springframework.web.bind.annotation.RestController; + #else + import org.springframework.stereotype.Controller; + #end + #if(${superControllerClassPackage}) + import ${superControllerClassPackage}; + #end +import lombok.extern.slf4j.Slf4j; + +/** + * $!{table.comment} api + * + * @author ${author} + * @version 1.0.0 + * @since ${date} + */ +@Tag(name = "${package.ModuleName} - $!{table.comment}服务") +@Slf4j +@Validated +@RestWrapper + #if(${restControllerStyle}) + @RestController + #else + @Controller + #end +@RequestMapping("#if(${package.ModuleName})/${package.ModuleName}#end/#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end") +#if(${kotlin}) +class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end + +#else + #if(${superControllerClass}) + public class ${table.controllerName} extends ${superControllerClass} { + #else + public class ${table.controllerName} { + #end + + } +#end diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-convert.java.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-convert.java.vm new file mode 100644 index 00000000..ef3e5b5b --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-convert.java.vm @@ -0,0 +1,41 @@ +package ${package.Entity}; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * $!{table.comment} 转换器 + * + * @author ${author} + * @version 1.0.0 + * @since ${date} + */ +@Mapper +@SuppressWarnings("ALL") +public interface ${entity}Convert { + + ${entity}Convert MAPPER = Mappers.getMapper(${entity}Convert.class); + + ${entity} toDomain(${entity}Request request); + + ${entity}DTO toDto(${entity}Request request); + + ${entity}VO toVo(${entity} domain); + + ${entity}DTO toDto(${entity} domain); + + List<${entity}VO> toVoListForDomain(List<${entity}> domain); + + List<${entity}DTO> toDtoListForDomain(List<${entity}> domain); + + ${entity}VO toVo(${entity}DTO dto); + + ${entity} toDto(${entity}DTO dto); + + List<${entity}VO> toVoListForDto(List<${entity}DTO> dto); + + List<${entity}> toDoListForDto(List<${entity}DTO> dto); + +} diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-dao.java.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-dao.java.vm new file mode 100644 index 00000000..e55dafc6 --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-dao.java.vm @@ -0,0 +1,24 @@ +package ${package.Mapper}; + +import ${package.Entity}.${entity}; +import ${superMapperClassPackage}; +#if(${mapperAnnotationClass}) +import ${mapperAnnotationClass.name}; +#end + +/** + * $!{table.comment} Mapper 接口 + * + * @author ${author} + * @since ${date} + */ +#if(${mapperAnnotationClass}) +@${mapperAnnotationClass.simpleName} +#end +#if(${kotlin}) +interface ${table.mapperName} : ${superMapperClass}<${entity}> +#else +public interface ${table.mapperName} extends ${superMapperClass}<${entity}> { + + } +#end diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-domain.java.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-domain.java.vm new file mode 100644 index 00000000..28a3d70a --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-domain.java.vm @@ -0,0 +1,164 @@ +package ${package.Entity}; + +#foreach($pkg in ${table.importPackages}) +import ${pkg}; +#end +#if(${springdoc}) +import io.swagger.v3.oas.annotations.media.Schema; +#elseif(${swagger}) +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +#end +#if(${entityLombokModel}) +import lombok.Data; +import lombok.EqualsAndHashCode; + #if(${chainModel}) + import lombok.experimental.Accessors; + #end +#end + +/** + * $!{table.comment} + * + * @author ${author} + * @version 1.0.0 + * @since ${date} + */ +#if(${entityLombokModel}) +@Data +@EqualsAndHashCode(callSuper = true) + #if(${chainModel}) + @Accessors(chain = true) + #end +#end +#if(${table.convert}) +@TableName("${schemaName}${table.name}") +#end +#if(${springdoc}) +@Schema(name = "${entity}", description = "$!{table.comment}") +#elseif(${swagger}) +@ApiModel(value = "${entity}对象", description = "$!{table.comment}") +#end +#if(${superEntityClass}) +public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end { +#elseif(${activeRecord}) +public class ${entity} extends Model<${entity}> { +#elseif(${entitySerialVersionUID}) +public class ${entity} implements Serializable{ +#else +public class ${entity} { +#end +#if(${entitySerialVersionUID}) + +private static final long serialVersionUID=1L; +#end +## ---------- BEGIN 字段循环遍历 ---------- +#foreach($field in ${table.fields}) + + #if(${field.keyFlag}) + #set($keyPropertyName=${field.propertyName}) + #end + #if("$!field.comment" != "") + #if(${springdoc}) + @Schema(description = "${field.comment}") + #elseif(${swagger}) + @ApiModelProperty("${field.comment}") + #else + /** + * ${field.comment} + */ + #end + #end + #if(${field.keyFlag}) + ## 主键 + #if(${field.keyIdentityFlag}) + @TableId(value = "${field.annotationColumnName}", type = IdType.AUTO) + #elseif(!$null.isNull(${idType}) && "$!idType" != "") + @TableId(value = "${field.annotationColumnName}", type = IdType.${idType}) + #elseif(${field.convert}) + @TableId("${field.annotationColumnName}") + #end + ## 普通字段 + #elseif(${field.fill}) + ## ----- 存在字段填充设置 ----- + #if(${field.convert}) + @TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill}) + #else + @TableField(fill = FieldFill.${field.fill}) + #end + #elseif(${field.convert}) + @TableField("${field.annotationColumnName}") + #end + ## 乐观锁注解 + #if(${field.versionField}) + @Version + #end + ## 逻辑删除注解 + #if(${field.logicDeleteField}) + @TableLogic + #end +private ${field.propertyType} ${field.propertyName}; + #if(!$foreach.hasNext) + + #end +#end +## ---------- END 字段循环遍历 ---------- +#if(!${entityLombokModel}) + #foreach($field in ${table.fields}) + #if(${field.propertyType.equals("boolean")}) + #set($getprefix="is") + #else + #set($getprefix="get") + #end + + public ${field.propertyType} ${getprefix}${field.capitalName}(){ + return ${field.propertyName}; + } + + #if(${chainModel}) + public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}){ + #else + public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) { + #end + this.${field.propertyName} = ${field.propertyName}; + #if(${chainModel}) + return this; + #end + } + #end + ## --foreach end--- +#end +## --end of #if(!${entityLombokModel})-- +#if(${entityColumnConstant}) + #foreach($field in ${table.fields}) + + public static final String ${field.name.toUpperCase()} ="${field.name}"; + #end +#end +#if(${activeRecord}) + +@Override +public Serializable pkVal(){ + #if(${keyPropertyName}) + return this.${keyPropertyName}; + #else + return null; + #end + } +#end +#if(!${entityLombokModel}) + +@Override +public String toString() { + return "${entity}{" + + #foreach($field in ${table.fields}) + #if($!{foreach.index}==0) + "${field.propertyName} = " + ${field.propertyName} + + #else + ", ${field.propertyName} = " + ${field.propertyName} + + #end + #end + "}"; + } +#end + } diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-dto.java.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-dto.java.vm new file mode 100644 index 00000000..7530702c --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-dto.java.vm @@ -0,0 +1,47 @@ +package ${package.Entity}; + + #foreach($pkg in ${table.importPackages}) + import ${pkg}; + #end +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * $!{table.comment} + * + * @author ${author} + * @version 1.0.0 + * @since ${date} + */ +@Data +@Schema(name = "${entity}DTO", description = "$!{table.comment}") +public class ${entity}DTO implements Serializable { + + private static final long serialVersionUID = 1L; + ## ---------- BEGIN 字段循环遍历 ---------- + #foreach($field in ${table.fields}) + + #if(${field.keyFlag}) + #set($keyPropertyName=${field.propertyName}) + #end + #if("$!field.comment" != "") + @Schema(description = "${field.comment}") + #end + private ${field.propertyType} ${field.propertyName}; + #end + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改时间") + private Date updateTime; + + @Schema(description = "创建人") + private String creator; + + @Schema(description = "修改人") + private String updater; + +} diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-mapper.xml.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-mapper.xml.vm new file mode 100644 index 00000000..50a6daec --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-mapper.xml.vm @@ -0,0 +1,39 @@ + + + + + #if(${enableCache}) + + + + #end + #if(${baseResultMap}) + + + #foreach($field in ${table.fields}) + #if(${field.keyFlag})##生成主键排在第一位 + + #end + #end + #foreach($field in ${table.commonFields})##生成公共字段 + + #end + #foreach($field in ${table.fields}) + #if(!${field.keyFlag})##生成普通字段 + + #end + #end + + + #end + #if(${baseColumnList}) + + + #foreach($field in ${table.commonFields}) + ${field.columnName}, + #end + ${table.fieldNames} + + + #end + diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-request.java.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-request.java.vm new file mode 100644 index 00000000..e9be4867 --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-request.java.vm @@ -0,0 +1,33 @@ +package ${package.Entity}; + + #foreach($pkg in ${table.importPackages}) + import ${pkg}; + #end +import com.orion.lang.define.wrapper.PageRequest; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * $!{table.comment} + * + * @author ${author} + * @version 1.0.0 + * @since ${date} + */ +@Data +@EqualsAndHashCode(callSuper = true) +@Schema(name = "${entity}Request", description = "$!{table.comment}") +public class ${entity}Request extends PageRequest { + #foreach($field in ${table.fields}) + + #if(${field.keyFlag}) + #set($keyPropertyName=${field.propertyName}) + #end + #if("$!field.comment" != "") + @Schema(description = "${field.comment}") + #end + private ${field.propertyType} ${field.propertyName}; + #end + +} diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-service-impl.java.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-service-impl.java.vm new file mode 100644 index 00000000..0ea68a2f --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-service-impl.java.vm @@ -0,0 +1,28 @@ +package ${package.ServiceImpl}; + +import ${package.Entity}.${entity}; +import ${package.Mapper}.${table.mapperName}; + #if(${table.serviceInterface}) + import ${package.Service}.${table.serviceName}; + #end +import ${superServiceImplClassPackage}; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * $!{table.comment} 服务实现类 + * + * @author ${author} + * @since ${date} + */ +@Slf4j +@Service +#if(${kotlin}) +open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>()#if(${table.serviceInterface}), ${table.serviceName}#end { + + } +#else + public class ${table.serviceImplName} implements ${table.serviceName} { + + } +#end diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-service.java.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-service.java.vm new file mode 100644 index 00000000..71e30b10 --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-service.java.vm @@ -0,0 +1,18 @@ +package ${package.Service}; + +import ${package.Entity}.${entity}; +import ${superServiceClassPackage}; + +/** + * $!{table.comment} 服务类 + * + * @author ${author} + * @since ${date} + */ +#if(${kotlin}) +interface ${table.serviceName} : ${superServiceClass}<${entity}> +#else +public interface ${table.serviceName} { + + } +#end diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-vo.java.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-vo.java.vm new file mode 100644 index 00000000..a8056f30 --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-vo.java.vm @@ -0,0 +1,47 @@ +package ${package.Entity}; + + #foreach($pkg in ${table.importPackages}) + import ${pkg}; + #end +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Date; + +/** + * $!{table.comment} VO + * + * @author ${author} + * @version 1.0.0 + * @since ${date} + */ +@Data +@Schema(name = "${entity}VO", description = "$!{table.comment}") +public class ${entity}VO implements Serializable { + + private static final long serialVersionUID = 1L; + ## ---------- BEGIN 字段循环遍历 ---------- + #foreach($field in ${table.fields}) + + #if(${field.keyFlag}) + #set($keyPropertyName=${field.propertyName}) + #end + #if("$!field.comment" != "") + @Schema(description = "${field.comment}") + #end + private ${field.propertyType} ${field.propertyName}; + #end + + @Schema(description = "创建时间") + private Date createTime; + + @Schema(description = "修改时间") + private Date updateTime; + + @Schema(description = "创建人") + private String creator; + + @Schema(description = "修改人") + private String updater; + +}