初始化

This commit is contained in:
2025-04-23 11:03:01 +08:00
commit 89c2e6c5c4
148 changed files with 11513 additions and 0 deletions

View File

@ -0,0 +1,4 @@
##自动导入包(仅导入实体属性需要的包,通常用于实体类)
#foreach($import in $importList)
import $!import;
#end

View File

@ -0,0 +1,39 @@
##Velocity宏定义
##定义设置表名后缀的宏定义,调用方式:#setTableSuffix("Test")
#macro(setTableSuffix $suffix)
#set($tableName = $!tool.append($tableInfo.name, $suffix))
#end
##定义设置包名后缀的宏定义,调用方式:#setPackageSuffix("Test")
#macro(setPackageSuffix $suffix)
#if($suffix!="")package #end#if($tableInfo.savePackageName!="")$!{tableInfo.savePackageName}.#{end}$!suffix;
#end
##定义直接保存路径与文件名简化的宏定义,调用方式:#save("/entity", ".java")
#macro(save $path $fileName)
$!callback.setSavePath($tool.append($tableInfo.savePath, $path))
$!callback.setFileName($tool.append($tableInfo.name, $fileName))
#end
##定义表注释的宏定义,调用方式:#tableComment("注释信息")
#macro(tableComment $desc)
/**
* $!{tableInfo.comment}($!{tableInfo.name})$desc
*
* @author $!author
* @since $!time.currTime()
*/
#end
##定义GETSET方法的宏定义调用方式#getSetMethod($column)
#macro(getSetMethod $column)
public $!{tool.getClsNameByFullName($column.type)} get$!{tool.firstUpperCase($column.name)}() {
return $!{column.name};
}
public void set$!{tool.firstUpperCase($column.name)}($!{tool.getClsNameByFullName($column.type)} $!{column.name}) {
this.$!{column.name} = $!{column.name};
}
#end

View File

@ -0,0 +1,41 @@
##初始化区域
##去掉表的t_前缀
$!tableInfo.setName($tool.getClassName($tableInfo.obj.name.replaceFirst("t_","")))
##参考阿里巴巴开发手册POJO 类中布尔类型的变量,都不要加 is 前缀,否则部分框架解析会引起序列化错误
## when use actual columns name, should set this.
###foreach($column in $tableInfo.fullColumn)
## $!column.setName($column.obj.name)
###end
#foreach($column in $tableInfo.fullColumn)
#if($column.name.startsWith("is") && $column.type.equals("java.lang.Boolean"))
$!column.setName($tool.firstLowerCase($column.name.substring(2)))
#end
#end
##实现动态排除列
#set($temp = $tool.newHashSet("testCreateTime", "otherColumn"))
#foreach($item in $temp)
#set($newList = $tool.newArrayList())
#foreach($column in $tableInfo.fullColumn)
#if($column.name!=$item)
##带有反回值的方法调用时使用$tool.call来消除返回值
$tool.call($newList.add($column))
#end
#end
##重新保存
$tableInfo.setFullColumn($newList)
#end
##对importList进行篡改
#set($temp = $tool.newHashSet())
#foreach($column in $tableInfo.fullColumn)
#if(!$column.type.startsWith("java.lang."))
##带有反回值的方法调用时使用$tool.call来消除返回值
$tool.call($temp.add($column.type))
#end
#end
##覆盖
#set($importList = $temp)

View File

@ -0,0 +1,27 @@
##following code can be generated use MybatisCodeHelperPro plugin mybatis generator mingrate to template generate.
##copy group for different project.
#set($javamodelSrcFolder="${projectPath}/src/main/java")
#set($modelPackageName="{{ cookiecutter.__mvn_package }}.rest.entity")
#set($mapperSrcFolder="${projectPath}/src/main/java")
#set($mapperPackageName="{{ cookiecutter.__mvn_package }}.rest.dao")
#set($mapperXmlFolder="${projectPath}/src/main/resources")
#set($mapperXmlPackage="mapper")
#set($serviceSrcFolder="${projectPath}/src/main/java")
#set($servicePackageName="{{ cookiecutter.__mvn_package }}.rest.service")
#set($serviceImplSrcFolder="${projectPath}/src/main/java")
#set($serviceImplPackageName="{{ cookiecutter.__mvn_package }}.rest.service.impl")
#set($controllerSrcFolder="${projectPath}/src/main/java")
#set($controllerPackageName="{{ cookiecutter.__mvn_package }}.rest.controller")
#set($useLombok=true)
#set($useSwagger=false)
#set($useOpenApi=false)
#set($addSchemaName=false)
#set($mapperSuffix="Mapper")
#set($daoSuffix="Dao")
#set($useActualColumName=false)
#if($useActualColumName)
#foreach($column in $tableInfo.fullColumn)
$!column.setName($column.obj.name)
#end
#end

View File

@ -0,0 +1,31 @@
##针对Mybatis 进行支持主要用于生成xml文件
#foreach($column in $tableInfo.fullColumn)
##储存列类型
$tool.call($column.ext.put("sqlType", $tool.getField($column.obj.dataType, "typeName")))
#if($tool.newHashSet("java.lang.String").contains($column.type))
#set($jdbcType="VARCHAR")
#elseif($tool.newHashSet("java.lang.Boolean", "boolean").contains($column.type))
#set($jdbcType="BOOLEAN")
#elseif($tool.newHashSet("java.lang.Byte", "byte").contains($column.type))
#set($jdbcType="BYTE")
#elseif($tool.newHashSet("java.lang.Integer", "int", "java.lang.Short", "short").contains($column.type))
#set($jdbcType="INTEGER")
#elseif($tool.newHashSet("java.lang.Long", "long").contains($column.type))
#set($jdbcType="BIGINT")
#elseif($tool.newHashSet("java.lang.Float", "float", "java.lang.Double", "double").contains($column.type))
#set($jdbcType="NUMERIC")
#elseif($tool.newHashSet(
"java.util.Date", "java.sql.Timestamp", "java.time.Instant", "java.time.LocalDateTime",
"java.time.OffsetDateTime", "java.time.ZonedDateTime").contains($column.type))
#set($jdbcType="TIMESTAMP")
#elseif($tool.newHashSet("java.sql.Date", "java.time.LocalDate", "java.time.LocalTime").contains($column.type))
#set($jdbcType="TIMESTAMP")
#else
##其他类型
#set($jdbcType="VARCHAR")
#end
$tool.call($column.ext.put("jdbcType", $jdbcType))
#end
##定义宏,查询所有列
#macro(allSqlColumn)#foreach($column in $tableInfo.fullColumn)$column.obj.name#if($velocityHasNext), #end#end#end