Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
a9d68980
Commit
a9d68980
authored
May 28, 2021
by
taabe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加mybatisplus代码生成器
parent
ad20175c
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
1514 additions
and
0 deletions
+1514
-0
MyBatisPlusCodeGenerator.java
.../amos/boot/biz/common/utils/MyBatisPlusCodeGenerator.java
+292
-0
NameUtils.java
...ava/com/yeejoin/amos/boot/biz/common/utils/NameUtils.java
+68
-0
bean.java.ftl
...boot-biz-common/src/main/resources/template/bean.java.ftl
+154
-0
bean.java.vm
...-boot-biz-common/src/main/resources/template/bean.java.vm
+151
-0
beanback.java.ftl
...-biz-common/src/main/resources/template/beanback.java.ftl
+159
-0
controller.java.ftl
...iz-common/src/main/resources/template/controller.java.ftl
+150
-0
controller.java.vm
...biz-common/src/main/resources/template/controller.java.vm
+40
-0
dto.java.ftl
...-boot-biz-common/src/main/resources/template/dto.java.ftl
+153
-0
mapper.java.ftl
...ot-biz-common/src/main/resources/template/mapper.java.ftl
+18
-0
mapper.java.vm
...oot-biz-common/src/main/resources/template/mapper.java.vm
+18
-0
mapper.xml.ftl
...oot-biz-common/src/main/resources/template/mapper.xml.ftl
+39
-0
mapper.xml.vm
...boot-biz-common/src/main/resources/template/mapper.xml.vm
+39
-0
service.java.ftl
...t-biz-common/src/main/resources/template/service.java.ftl
+18
-0
service.java.vm
...ot-biz-common/src/main/resources/template/service.java.vm
+18
-0
serviceImpl.java.ftl
...z-common/src/main/resources/template/serviceImpl.java.ftl
+24
-0
serviceImpl.java.vm
...iz-common/src/main/resources/template/serviceImpl.java.vm
+24
-0
vo.java.ftl
amos-boot-biz-common/src/main/resources/template/vo.java.ftl
+149
-0
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/MyBatisPlusCodeGenerator.java
0 → 100644
View file @
a9d68980
package
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
utils
;
import
com.baomidou.mybatisplus.core.exceptions.MybatisPlusException
;
import
com.baomidou.mybatisplus.core.toolkit.StringPool
;
import
com.baomidou.mybatisplus.generator.AutoGenerator
;
import
com.baomidou.mybatisplus.generator.InjectionConfig
;
import
com.baomidou.mybatisplus.generator.config.DataSourceConfig
;
import
com.baomidou.mybatisplus.generator.config.FileOutConfig
;
import
com.baomidou.mybatisplus.generator.config.GlobalConfig
;
import
com.baomidou.mybatisplus.generator.config.ITypeConvert
;
import
com.baomidou.mybatisplus.generator.config.PackageConfig
;
import
com.baomidou.mybatisplus.generator.config.StrategyConfig
;
import
com.baomidou.mybatisplus.generator.config.TemplateConfig
;
import
com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert
;
import
com.baomidou.mybatisplus.generator.config.po.TableInfo
;
import
com.baomidou.mybatisplus.generator.config.rules.DbColumnType
;
import
com.baomidou.mybatisplus.generator.config.rules.IColumnType
;
import
com.baomidou.mybatisplus.generator.config.rules.NamingStrategy
;
import
com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine
;
import
org.apache.commons.lang.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Scanner
;
/**
* @author DELL
*/
public
class
MyBatisPlusCodeGenerator
{
/**
* 项目名称缩写
*/
static
String
projectShortName
=
"tzs"
;
/**
* 项目api目录
*/
static
String
apiAddress
=
"/amos-boot-module/amos-boot-module-api/"
+
"amos-boot-module-"
+
projectShortName
+
"-api/"
;
/**
* 项目biz目录
*/
static
String
bizAddress
=
"/amos-boot-module/amos-boot-module-biz/"
+
"amos-boot-module-"
+
projectShortName
+
"-biz/"
;
/**
* 项目api路径
*/
static
String
apiPath
=
apiAddress
+
"src/main/java/com/yeejoin/amos/boot/module/"
+
projectShortName
+
"/api"
;
/**
* 项目biz路径
*/
static
String
bizPath
=
bizAddress
+
"src/main/java/com/yeejoin/amos/boot/module/"
+
projectShortName
+
"/biz"
;
/**
* 接口及实体等代码生成路径
*/
static
String
interfaceCodeOutPath
=
System
.
getProperty
(
"user.dir"
)
+
apiPath
;
/**
* 控制器及接口实现等代码生成路径
*/
static
String
controllerCodeOutPath
=
System
.
getProperty
(
"user.dir"
)
+
bizPath
;
/**
* 读取控制台内容
*/
public
static
String
scanner
(
String
tip
)
{
Scanner
scanner
=
new
Scanner
(
System
.
in
);
StringBuilder
help
=
new
StringBuilder
();
help
.
append
(
"请输入"
+
tip
+
":"
);
System
.
out
.
println
(
help
.
toString
());
if
(
scanner
.
hasNext
())
{
String
ipt
=
scanner
.
next
();
if
(
StringUtils
.
isNotEmpty
(
ipt
))
{
return
ipt
;
}
}
throw
new
MybatisPlusException
(
"请输入正确的"
+
tip
+
"!"
);
}
public
static
void
main
(
String
[]
args
)
{
// 代码生成器
AutoGenerator
autoGenerator
=
new
AutoGenerator
();
// 全局配置
GlobalConfig
gc
=
new
GlobalConfig
();
// 工程路径-最外层
final
String
projectPath
=
System
.
getProperty
(
"user.dir"
);
// 代码输出目录
//gc.setOutputDir(codeOutPath);
// 作者
gc
.
setAuthor
(
"tb"
);
// 是否自动打开文件夹 建议开启
gc
.
setOpen
(
false
);
// 开启Swagger2 注解支持
gc
.
setSwagger2
(
true
);
// 注入autoGenerator
autoGenerator
.
setGlobalConfig
(
gc
);
gc
.
setActiveRecord
(
false
);
// 数据源配置
DataSourceConfig
dsc
=
new
DataSourceConfig
();
dsc
.
setUrl
(
"jdbc:mysql://172.16.10.66:3306/amos_demo?serverTimezone=GMT%2B8"
);
// dsc.setSchemaName("public");
dsc
.
setDriverName
(
"com.mysql.jdbc.Driver"
);
dsc
.
setUsername
(
"root"
);
dsc
.
setPassword
(
"root_123"
);
dsc
.
setTypeConvert
(
new
ITypeConvert
()
{
@Override
public
IColumnType
processTypeConvert
(
GlobalConfig
globalConfig
,
String
fieldType
)
{
String
t
=
fieldType
.
toLowerCase
();
if
(
t
.
contains
(
"datetime"
))
{
return
DbColumnType
.
DATE
;
}
if
(
t
.
contains
(
"date"
))
{
return
DbColumnType
.
DATE
;
}
//其它字段采用默认转换(非mysql数据库可以使用其它默认的数据库转换器)
return
new
MySqlTypeConvert
().
processTypeConvert
(
globalConfig
,
fieldType
);
}
});
autoGenerator
.
setDataSource
(
dsc
);
// 包配置
final
PackageConfig
pc
=
new
PackageConfig
();
// 填写对应模块
pc
.
setModuleName
(
projectShortName
);
// 实体路径
pc
.
setParent
(
"com.yeejoin.amos.boot.module"
);
pc
.
setEntity
(
"api.entity"
);
pc
.
setMapper
(
"api.mapper"
);
pc
.
setService
(
"api.service"
);
pc
.
setServiceImpl
(
"biz.service.impl"
);
pc
.
setController
(
"biz.controller"
);
autoGenerator
.
setPackageInfo
(
pc
);
// 自定义配置
InjectionConfig
cfg
=
new
InjectionConfig
()
{
@Override
public
void
initMap
()
{
// to do nothing
}
};
// 如果模板引擎是 freemarker
String
controller
=
"/template/controller.java.ftl"
;
String
entity
=
"/template/bean.java.ftl"
;
String
mapper
=
"/template/mapper.java.ftl"
;
String
service
=
"/template/service.java.ftl"
;
String
serviceImpl
=
"/template/serviceImpl.java.ftl"
;
String
mapperXml
=
"/template/mapper.xml.ftl"
;
String
dto
=
"/template/dto.java.ftl"
;
String
vo
=
"/template/vo.java.ftl"
;
// 自定义配置会被优先输出
List
<
FileOutConfig
>
focList
=
new
ArrayList
<>();
focList
.
add
(
new
FileOutConfig
(
controller
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
String
filePath
=
controllerCodeOutPath
+
"/controller/"
+
tableInfo
.
getControllerName
()
+
StringPool
.
DOT_JAVA
;
return
filePath
;
}
});
focList
.
add
(
new
FileOutConfig
(
entity
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
String
filePath
=
interfaceCodeOutPath
+
"/entity/"
+
tableInfo
.
getEntityName
()
+
StringPool
.
DOT_JAVA
;
return
filePath
;
}
});
focList
.
add
(
new
FileOutConfig
(
dto
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
String
filePath
=
interfaceCodeOutPath
+
"/dto/"
+
tableInfo
.
getEntityName
()
+
"Dto"
+
StringPool
.
DOT_JAVA
;
return
filePath
;
}
});
focList
.
add
(
new
FileOutConfig
(
vo
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
String
filePath
=
interfaceCodeOutPath
+
"/vo/"
+
tableInfo
.
getEntityName
()
+
"Vo"
+
StringPool
.
DOT_JAVA
;
return
filePath
;
}
});
focList
.
add
(
new
FileOutConfig
(
mapper
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
return
interfaceCodeOutPath
+
"/mapper/"
+
tableInfo
.
getEntityName
()
+
"Mapper"
+
StringPool
.
DOT_JAVA
;
}
});
focList
.
add
(
new
FileOutConfig
(
service
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
return
interfaceCodeOutPath
+
"/service/"
+
tableInfo
.
getServiceName
()
+
StringPool
.
DOT_JAVA
;
}
});
focList
.
add
(
new
FileOutConfig
(
serviceImpl
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
return
controllerCodeOutPath
+
"/service/impl/"
+
tableInfo
.
getServiceImplName
()
+
StringPool
.
DOT_JAVA
;
}
});
// focList.add(new FileOutConfig(mapperXml) {
// @Override
// public String outputFile(TableInfo tableInfo) {
// // 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
// return projectPath + projectName + "src/main/resources/mapper/" + pc.getModuleName()
// + "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML;
// }
// });
focList
.
add
(
new
FileOutConfig
(
mapperXml
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!!
return
projectPath
+
apiAddress
+
"src/main/resources/mapper/"
+
tableInfo
.
getEntityName
()
+
"Mapper"
+
StringPool
.
DOT_XML
;
}
});
/*
cfg.setFileCreate(new IFileCreate() {
@Override
public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) {
// 判断自定义文件夹是否需要创建
checkDir("调用默认方法创建的目录");
return false;
}
});
*/
cfg
.
setFileOutConfigList
(
focList
);
autoGenerator
.
setCfg
(
cfg
);
// 配置模板
TemplateConfig
templateConfig
=
new
TemplateConfig
();
// 配置自定义输出模板
//指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别
// templateConfig.setEntity("templates/entity2.java");
// templateConfig.setService();
// templateConfig.setController();
templateConfig
.
setXml
(
null
);
autoGenerator
.
setTemplate
(
templateConfig
);
// 策略配置
StrategyConfig
strategy
=
new
StrategyConfig
();
strategy
.
setNaming
(
NamingStrategy
.
underline_to_camel
);
strategy
.
setColumnNaming
(
NamingStrategy
.
underline_to_camel
);
strategy
.
setSuperEntityClass
(
"org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity"
);
strategy
.
setEntityLombokModel
(
true
);
strategy
.
setRestControllerStyle
(
true
);
// 公共父类-开启将导致swagger无效化
//strategy.setSuperControllerClass("com.test.base.BaseController");
// 写于父类中的公共字段
strategy
.
setSuperEntityColumns
(
new
String
[]{
"SEQUENCE_NBR"
,
"REC_DATE"
,
"REC_USER_ID"
});
// 建议以后开启
strategy
.
setInclude
(
scanner
(
"表名,多个英文逗号分割"
).
split
(
","
));
strategy
.
setControllerMappingHyphenStyle
(
true
);
strategy
.
setTablePrefix
();
//去除表名前缀
strategy
.
setTablePrefix
(
"t_"
,
"tb_"
,
"sys_"
,
"other_"
,
"rpm_"
,
"s_"
);
autoGenerator
.
setStrategy
(
strategy
);
autoGenerator
.
setTemplateEngine
(
new
FreemarkerTemplateEngine
());
autoGenerator
.
execute
();
}
}
\ No newline at end of file
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/NameUtils.java
0 → 100644
View file @
a9d68980
package
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
utils
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* @description: 驼峰工具类
* @author: duanwei
* @create: 2020-05-28 13:57
**/
public
class
NameUtils
{
private
static
Pattern
NUMBER_PATTERN
=
Pattern
.
compile
(
"([A-Za-z\\d]+)(_)?"
);
private
static
Pattern
AZTEXT_PATTERN
=
Pattern
.
compile
(
"[A-Z]([a-z\\d]+)?"
);
/**
* 下划线转驼峰法(默认小驼峰)
*
* @param line 源字符串
* @param smallCamel 大小驼峰,是否为小驼峰(驼峰,第一个字符是大写还是小写)
* @return 转换后的字符串
*/
public
static
String
underline2Camel
(
String
line
,
boolean
...
smallCamel
)
{
if
(
line
==
null
||
""
.
equals
(
line
))
{
return
""
;
}
StringBuffer
sb
=
new
StringBuffer
();
Matcher
matcher
=
NUMBER_PATTERN
.
matcher
(
line
);
//匹配正则表达式
while
(
matcher
.
find
())
{
String
word
=
matcher
.
group
();
//当是true 或则是空的情况
if
((
smallCamel
.
length
==
0
||
smallCamel
[
0
])
&&
matcher
.
start
()
==
0
)
{
sb
.
append
(
Character
.
toLowerCase
(
word
.
charAt
(
0
)));
}
else
{
sb
.
append
(
Character
.
toUpperCase
(
word
.
charAt
(
0
)));
}
int
index
=
word
.
lastIndexOf
(
'_'
);
if
(
index
>
0
)
{
sb
.
append
(
word
.
substring
(
1
,
index
).
toLowerCase
());
}
else
{
sb
.
append
(
word
.
substring
(
1
).
toLowerCase
());
}
}
return
sb
.
toString
();
}
/**
* 驼峰法转下划线
*
* @param line 源字符串
* @return 转换后的字符串
*/
public
static
String
camel2Underline
(
String
line
)
{
if
(
line
==
null
||
""
.
equals
(
line
))
{
return
""
;
}
line
=
String
.
valueOf
(
line
.
charAt
(
0
)).
toUpperCase
()
.
concat
(
line
.
substring
(
1
));
StringBuffer
sb
=
new
StringBuffer
();
Matcher
matcher
=
AZTEXT_PATTERN
.
matcher
(
line
);
while
(
matcher
.
find
())
{
String
word
=
matcher
.
group
();
sb
.
append
(
word
.
toUpperCase
());
sb
.
append
(
matcher
.
end
()
==
line
.
length
()
?
""
:
"_"
);
}
return
sb
.
toString
();
}
}
amos-boot-biz-common/src/main/resources/template/bean.java.ftl
0 → 100644
View file @
a9d68980
package
${
package
.
Entity
};
<#
list
table
.
importPackages
as
pkg
>
import
${
pkg
};
</#
list
>
<#
if
swagger2
>
import
io
.
swagger
.
annotations
.
ApiModel
;
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
</#
if
>
<#
if
entityLombokModel
>
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
import
lombok
.
experimental
.
Accessors
;
</#
if
>
import
com
.
baomidou
.
mybatisplus
.
annotation
.
IdType
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableId
;
import
com
.
fasterxml
.
jackson
.
databind
.
annotation
.
JsonSerialize
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableName
;
import
com
.
fasterxml
.
jackson
.
databind
.
ser
.
std
.
ToStringSerializer
;
/**
*
${
table
.
comment
!}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
entityLombokModel
>
@
Data
<#
if
superEntityClass
??>
@
EqualsAndHashCode
(
callSuper
=
true
)
<#
else
>
@
EqualsAndHashCode
(
callSuper
=
false
)
</#
if
>
@
Accessors
(
chain
=
true
)
</#
if
>
<#
if
table
.
convert
>
@
TableName
(
"${table.name}"
)
</#
if
>
<#
if
swagger2
>
@
ApiModel
(
value
=
"${entity}对象"
,
description
=
"${table.comment!}"
)
</#
if
>
<#
if
superEntityClass
??>
public
class
${
entity
}
extends
${
superEntityClass
}<#
if
activeRecord
><${
entity
}></#
if
>
{
<#
elseif
activeRecord
>
public
class
${
entity
}
extends
Model
<${
entity
}>
{
<#
else
>
public
class
${
entity
}
implements
Serializable
{
</#
if
>
<#
if
entitySerialVersionUID
>
private
static
final
long
serialVersionUID
=
1L
;
</#
if
>
<#--
----------
BEGIN
字段循环遍历
---------->
<#
list
table
.
fields
as
field
>
<#
if
field
.
keyFlag
>
<#
assign
keyPropertyName
=
"${field.propertyName}"
/>
</#
if
>
<#
if
field
.
comment
!?length gt 0>
<#
if
swagger2
>
@
ApiModelProperty
(
value
=
"${field.comment}"
)
<#
else
>
/**
*
${
field
.
comment
}
*/
</#
if
>
</#
if
>
<#
if
field
.
keyFlag
>
<#--
主键
-->
<#
if
field
.
keyIdentityFlag
>
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.
AUTO
)
<#
elseif
idType
??>
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.${
idType
})
<#
elseif
field
.
convert
>
@
TableId
(
"${field.name}"
)
</#
if
>
<#--
普通字段
-->
<#
elseif
field
.
fill
??>
<#--
-----
存在字段填充设置
----->
<#
if
field
.
convert
>
@
TableField
(
value
=
"${field.name}"
,
fill
=
FieldFill
.${
field
.
fill
})
<#
else
>
@
TableField
(
fill
=
FieldFill
.${
field
.
fill
})
</#
if
>
<#
elseif
field
.
convert
>
@
TableField
(
"${field.name}"
)
</#
if
>
<#--
乐观锁注解
-->
<#
if
(
versionFieldName
!"") == field.name>
@
Version
</#
if
>
<#--
逻辑删除注解
-->
<#
if
(
logicDeleteFieldName
!"") == field.name>
@
TableLogic
</#
if
>
private
${
field
.
propertyType
}
${
field
.
propertyName
};
</#
list
>
<#------------
END
字段循环遍历
---------->
<#
if
!entityLombokModel>
<#
list
table
.
fields
as
field
>
<#
if
field
.
propertyType
==
"boolean"
>
<#
assign
getprefix
=
"is"
/>
<#
else
>
<#
assign
getprefix
=
"get"
/>
</#
if
>
public
${
field
.
propertyType
}
${
getprefix
}${
field
.
capitalName
}()
{
return
${
field
.
propertyName
};
}
<#
if
entityBuilderModel
>
public
${
entity
}
set
${
field
.
capitalName
}(${
field
.
propertyType
}
${
field
.
propertyName
})
{
<#
else
>
public
void
set
${
field
.
capitalName
}(${
field
.
propertyType
}
${
field
.
propertyName
})
{
</#
if
>
this
.${
field
.
propertyName
}
=
${
field
.
propertyName
};
<#
if
entityBuilderModel
>
return
this
;
</#
if
>
}
</#
list
>
</#
if
>
<#
if
entityColumnConstant
>
<#
list
table
.
fields
as
field
>
public
static
final
String
${
field
.
name
?
upper_case
}
=
"${field.name}"
;
</#
list
>
</#
if
>
<#
if
activeRecord
>
@
Override
protected
Serializable
pkVal
()
{
<#
if
keyPropertyName
??>
return
this
.${
keyPropertyName
};
<#
else
>
return
null
;
</#
if
>
}
</#
if
>
<#
if
!entityLombokModel>
@
Override
public
String
toString
()
{
return
"${entity}{"
+
<#
list
table
.
fields
as
field
>
<#
if
field_index
==
0
>
"${field.propertyName}="
+
${
field
.
propertyName
}
+
<#
else
>
", ${field.propertyName}="
+
${
field
.
propertyName
}
+
</#
if
>
</#
list
>
"}"
;
}
</#
if
>
}
amos-boot-biz-common/src/main/resources/template/bean.java.vm
0 → 100644
View file @
a9d68980
package
${
package
.
Entity
};
#
foreach
($
pkg
in
${
table
.
importPackages
})
import
${
pkg
};
#
end
#
if
(${
swagger2
})
import
io
.
swagger
.
annotations
.
ApiModel
;
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
#
end
#
if
(${
entityLombokModel
})
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
import
lombok
.
experimental
.
Accessors
;
#
end
/**
*
$
!{table.comment}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
#
if
(${
entityLombokModel
})
@
Data
#
if
(${
superEntityClass
})
@
EqualsAndHashCode
(
callSuper
=
true
)
#
else
@
EqualsAndHashCode
(
callSuper
=
false
)
#
end
@
Accessors
(
chain
=
true
)
#
end
#
if
(${
table
.
convert
})
@
TableName
(
"${table.name}"
)
#
end
#
if
(${
swagger2
})
@
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
}>
{
#
else
public
class
${
entity
}
implements
Serializable
{
#
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
(${
swagger2
})
@
ApiModelProperty
(
value
=
"${field.comment}"
)
#
else
/**
*
${
field
.
comment
}
*/
#
end
#
end
#
if
(${
field
.
keyFlag
})
##
主键
#
if
(${
field
.
keyIdentityFlag
})
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.
AUTO
)
#
elseif
(
!$null.isNull(${idType}) && "$!idType" != "")
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.${
idType
})
#
elseif
(${
field
.
convert
})
@
TableId
(
"${field.name}"
)
#
end
##
普通字段
#
elseif
(${
field
.
fill
})
##
-----
存在字段填充设置
-----
#
if
(${
field
.
convert
})
@
TableField
(
value
=
"${field.name}"
,
fill
=
FieldFill
.${
field
.
fill
})
#
else
@
TableField
(
fill
=
FieldFill
.${
field
.
fill
})
#
end
#
elseif
(${
field
.
convert
})
@
TableField
(
"${field.name}"
)
#
end
##
乐观锁注解
#
if
(${
versionFieldName
}==${
field
.
name
})
@
Version
#
end
##
逻辑删除注解
#
if
(${
logicDeleteFieldName
}==${
field
.
name
})
@
TableLogic
#
end
private
${
field
.
propertyType
}
${
field
.
propertyName
};
#
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
(${
entityBuilderModel
})
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
(${
entityBuilderModel
})
return
this
;
#
end
}
#
end
#
end
#
if
(${
entityColumnConstant
})
#
foreach
($
field
in
${
table
.
fields
})
public
static
final
String
${
field
.
name
.
toUpperCase
()}
=
"${field.name}"
;
#
end
#
end
#
if
(${
activeRecord
})
@
Override
protected
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
}
amos-boot-biz-common/src/main/resources/template/beanback.java.ftl
0 → 100644
View file @
a9d68980
package
${
package
.
Entity
};
<#
list
table
.
importPackages
as
pkg
>
import
${
pkg
};
</#
list
>
<#
if
swagger2
>
import
io
.
swagger
.
annotations
.
ApiModel
;
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
</#
if
>
<#
if
entityLombokModel
>
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
import
lombok
.
experimental
.
Accessors
;
</#
if
>
import
com
.
baomidou
.
mybatisplus
.
annotation
.
IdType
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableId
;
import
com
.
fasterxml
.
jackson
.
databind
.
annotation
.
JsonSerialize
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableName
;
import
com
.
fasterxml
.
jackson
.
databind
.
ser
.
std
.
ToStringSerializer
;
/**
*
${
table
.
comment
!}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
entityLombokModel
>
@
Data
<#
if
superEntityClass
??>
@
EqualsAndHashCode
(
callSuper
=
true
)
<#
else
>
@
EqualsAndHashCode
(
callSuper
=
false
)
</#
if
>
@
Accessors
(
chain
=
true
)
</#
if
>
<#
if
table
.
convert
>
@
TableName
(
"${table.name}"
)
</#
if
>
<#
if
swagger2
>
@
ApiModel
(
value
=
"${entity}对象"
,
description
=
"${table.comment!}"
)
</#
if
>
<#
if
superEntityClass
??>
public
class
${
entity
}
extends
${
superEntityClass
}<#
if
activeRecord
><${
entity
}></#
if
>
{
<#
elseif
activeRecord
>
public
class
${
entity
}
extends
Model
<${
entity
}>
{
<#
else
>
public
class
${
entity
}
implements
Serializable
{
</#
if
>
<#
if
entitySerialVersionUID
>
private
static
final
long
serialVersionUID
=
1L
;
</#
if
>
@
TableId
(
type
=
IdType
.
ID_WORKER
)
@
JsonSerialize
(
using
=
ToStringSerializer
.
class
)
private
Long
id
;
<#--
----------
BEGIN
字段循环遍历
---------->
<#
list
table
.
fields
as
field
>
<#
if
field
.
keyFlag
>
<#
assign
keyPropertyName
=
"${field.propertyName}"
/>
</#
if
>
<#
if
field
.
comment
!?length gt 0>
<#
if
swagger2
>
@
ApiModelProperty
(
value
=
"${field.comment}"
)
<#
else
>
/**
*
${
field
.
comment
}
*/
</#
if
>
</#
if
>
<#
if
field
.
keyFlag
>
<#--
主键
-->
<#
if
field
.
keyIdentityFlag
>
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.
AUTO
)
<#
elseif
idType
??>
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.${
idType
})
<#
elseif
field
.
convert
>
@
TableId
(
"${field.name}"
)
</#
if
>
<#--
普通字段
-->
<#
elseif
field
.
fill
??>
<#--
-----
存在字段填充设置
----->
<#
if
field
.
convert
>
@
TableField
(
value
=
"${field.name}"
,
fill
=
FieldFill
.${
field
.
fill
})
<#
else
>
@
TableField
(
fill
=
FieldFill
.${
field
.
fill
})
</#
if
>
<#
elseif
field
.
convert
>
@
TableField
(
"${field.name}"
)
</#
if
>
<#--
乐观锁注解
-->
<#
if
(
versionFieldName
!"") == field.name>
@
Version
</#
if
>
<#--
逻辑删除注解
-->
<#
if
(
logicDeleteFieldName
!"") == field.name>
@
TableLogic
</#
if
>
private
${
field
.
propertyType
}
${
field
.
propertyName
};
</#
list
>
<#------------
END
字段循环遍历
---------->
<#
if
!entityLombokModel>
<#
list
table
.
fields
as
field
>
<#
if
field
.
propertyType
==
"boolean"
>
<#
assign
getprefix
=
"is"
/>
<#
else
>
<#
assign
getprefix
=
"get"
/>
</#
if
>
public
${
field
.
propertyType
}
${
getprefix
}${
field
.
capitalName
}()
{
return
${
field
.
propertyName
};
}
<#
if
entityBuilderModel
>
public
${
entity
}
set
${
field
.
capitalName
}(${
field
.
propertyType
}
${
field
.
propertyName
})
{
<#
else
>
public
void
set
${
field
.
capitalName
}(${
field
.
propertyType
}
${
field
.
propertyName
})
{
</#
if
>
this
.${
field
.
propertyName
}
=
${
field
.
propertyName
};
<#
if
entityBuilderModel
>
return
this
;
</#
if
>
}
</#
list
>
</#
if
>
<#
if
entityColumnConstant
>
<#
list
table
.
fields
as
field
>
public
static
final
String
${
field
.
name
?
upper_case
}
=
"${field.name}"
;
</#
list
>
</#
if
>
<#
if
activeRecord
>
@
Override
protected
Serializable
pkVal
()
{
<#
if
keyPropertyName
??>
return
this
.${
keyPropertyName
};
<#
else
>
return
null
;
</#
if
>
}
</#
if
>
<#
if
!entityLombokModel>
@
Override
public
String
toString
()
{
return
"${entity}{"
+
<#
list
table
.
fields
as
field
>
<#
if
field_index
==
0
>
"${field.propertyName}="
+
${
field
.
propertyName
}
+
<#
else
>
", ${field.propertyName}="
+
${
field
.
propertyName
}
+
</#
if
>
</#
list
>
"}"
;
}
</#
if
>
}
amos-boot-biz-common/src/main/resources/template/controller.java.ftl
0 → 100644
View file @
a9d68980
package
${
package
.
Controller
};
import
org
.
springframework
.
http
.
MediaType
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestMapping
;
import
io
.
swagger
.
annotations
.
ApiOperation
;
import
io
.
swagger
.
annotations
.
Api
;
import
org
.
apache
.
commons
.
lang3
.
StringUtils
;
<#
if
restControllerStyle
>
import
org
.
springframework
.
web
.
bind
.
annotation
.
RestController
;
<#
else
>
import
org
.
springframework
.
stereotype
.
Controller
;
</#
if
>
<#
if
superControllerClassPackage
??>
import
${
superControllerClassPackage
};
</#
if
>
import
${
package
.
Service
}.${
table
.
serviceName
};
import
com
.
baomidou
.
mybatisplus
.
core
.
conditions
.
query
.
QueryWrapper
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
javax
.
servlet
.
http
.
HttpServletRequest
;
import
com
.
baomidou
.
mybatisplus
.
core
.
metadata
.
IPage
;
import
org
.
springframework
.
web
.
bind
.
annotation
.*;
import
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
;
import
${
package
.
Entity
}.${
entity
};
import
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
utils
.
NameUtils
;
import
java
.
util
.
Arrays
;
/**
*
${
table
.
comment
!}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
restControllerStyle
>
@
RestController
@
Api
(
tags
=
"${table.comment}Api"
)
<#
else
>
@
Controller
</#
if
>
@
RequestMapping
(
value
=
"<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>"
,
produces
=
MediaType
.
APPLICATION_JSON_UTF8_VALUE
)
<#
if
kotlin
>
class
${
table
.
controllerName
}<#
if
superControllerClass
??>
:
${
superControllerClass
}()</#
if
>
<#
else
>
<#
if
superControllerClass
??>
public
class
${
table
.
controllerName
}
extends
${
superControllerClass
}
{
<#
else
>
public
class
${
table
.
controllerName
}
{
</#
if
>
@
Autowired
${
table
.
serviceName
}
${
table
.
serviceName
?
uncap_first
};
/**
*
新增
${
table
.
comment
}
*
@
return
*/
@
RequestMapping
(
value
=
"/save"
,
method
=
RequestMethod
.
POST
)
@
ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增${table.comment}"
,
notes
=
"新增${table.comment}"
)
public
boolean
save
${
entity
}(
HttpServletRequest
request
,
@
RequestBody
${
entity
}
${
entity
?
uncap_first
}){
return
${
table
.
serviceName
?
uncap_first
}.
save
(${
entity
?
uncap_first
});
}
/**
*
根据
id
删除
*
@
param
id
*
@
return
*/
@
RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
DELETE
)
@
ApiOperation
(
httpMethod
=
"DELETE"
,
value
=
"根据id删除"
,
notes
=
"根据id删除"
)
public
boolean
deleteById
(
HttpServletRequest
request
,
@
PathVariable
Long
id
){
return
${
table
.
serviceName
?
uncap_first
}.
removeById
(
id
);
}
/**
*
修改
${
table
.
comment
}
*
@
return
*/
@
RequestMapping
(
value
=
"/updateById"
,
method
=
RequestMethod
.
PUT
)
@
ApiOperation
(
httpMethod
=
"PUT"
,
value
=
"修改${table.comment}"
,
notes
=
"修改${table.comment}"
)
public
boolean
updateById
${
entity
}(
HttpServletRequest
request
,
@
RequestBody
${
entity
}
${
entity
?
uncap_first
}){
return
${
table
.
serviceName
?
uncap_first
}.
updateById
(${
entity
?
uncap_first
});
}
/**
*
根据
id
查询
*
@
param
id
*
@
return
*/
@
RequestMapping
(
value
=
"/{id}"
,
method
=
RequestMethod
.
GET
)
@
ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据id查询"
,
notes
=
"根据id查询"
)
public
${
entity
}
selectById
(
HttpServletRequest
request
,
@
PathVariable
Long
id
){
return
${
table
.
serviceName
?
uncap_first
}.
getById
(
id
);
}
/**
*
列表分页查询
*
@
return
*/
@
RequestMapping
(
value
=
"/list"
,
method
=
RequestMethod
.
GET
)
@
ApiOperation
(
httpMethod
=
"GET"
,
value
=
"列表分页查询"
,
notes
=
"列表分页查询"
)
public
IPage
<${
entity
}>
listPage
(
String
pageNum
,
String
pageSize
,
${
entity
}
${
entity
?
uncap_first
}){
Page
<${
entity
}>
pageBean
;
QueryWrapper
<${
entity
}>
${
entity
?
uncap_first
}
QueryWrapper
=
new
QueryWrapper
<>();
Class
<?
extends
${
entity
}>
aClass
=
${
entity
?
uncap_first
}.
getClass
();
Arrays
.
stream
(
aClass
.
getDeclaredFields
()).
forEach
(
field
->
{
try
{
field
.
setAccessible
(
true
);
Object
o
=
field
.
get
(${
entity
?
uncap_first
});
if
(
o
!= null) {
Class
<?>
type
=
field
.
getType
();
String
name
=
NameUtils
.
camel2Underline
(
field
.
getName
());
if
(
type
.
equals
(
Integer
.
class
))
{
Integer
fileValue
=
(
Integer
)
field
.
get
(${
entity
?
uncap_first
});
${
entity
?
uncap_first
}
QueryWrapper
.
eq
(
name
,
fileValue
);
}
else
if
(
type
.
equals
(
Long
.
class
))
{
Long
fileValue
=
(
Long
)
field
.
get
(${
entity
?
uncap_first
});
${
entity
?
uncap_first
}
QueryWrapper
.
eq
(
name
,
fileValue
);
}
else
if
(
type
.
equals
(
String
.
class
))
{
String
fileValue
=
(
String
)
field
.
get
(${
entity
?
uncap_first
});
${
entity
?
uncap_first
}
QueryWrapper
.
eq
(
name
,
fileValue
);
}
else
{
String
fileValue
=
(
String
)
field
.
get
(${
entity
?
uncap_first
});
${
entity
?
uncap_first
}
QueryWrapper
.
eq
(
name
,
fileValue
);
}
}
}
catch
(
Exception
e
)
{
}
});
IPage
<${
entity
}>
page
;
if
(
StringUtils
.
isBlank
(
pageNum
)
||
StringUtils
.
isBlank
(
pageSize
))
{
pageBean
=
new
Page
<>(
0
,
Long
.
MAX_VALUE
);
}
else
{
pageBean
=
new
Page
<>(
Integer
.
parseInt
(
pageNum
),
Integer
.
parseInt
(
pageSize
));
}
page
=
${
table
.
serviceName
?
uncap_first
}.
page
(
pageBean
,
${
entity
?
uncap_first
}
QueryWrapper
);
return
page
;
}
}
</#
if
>
amos-boot-biz-common/src/main/resources/template/controller.java.vm
0 → 100644
View file @
a9d68980
package
${
package
.
Controller
};
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
/**
*
$
!{table.comment}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
#
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
\ No newline at end of file
amos-boot-biz-common/src/main/resources/template/dto.java.ftl
0 → 100644
View file @
a9d68980
package
com
.
yeejoin
.
amos
.
boot
.
module
.${
package
.
ModuleName
}.
api
.
dto
;
<#
list
table
.
importPackages
as
pkg
>
import
${
pkg
};
</#
list
>
<#
if
swagger2
>
import
io
.
swagger
.
annotations
.
ApiModel
;
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
</#
if
>
<#
if
entityLombokModel
>
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
import
lombok
.
experimental
.
Accessors
;
</#
if
>
import
com
.
baomidou
.
mybatisplus
.
annotation
.
IdType
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableId
;
import
com
.
fasterxml
.
jackson
.
databind
.
annotation
.
JsonSerialize
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableName
;
import
com
.
fasterxml
.
jackson
.
databind
.
ser
.
std
.
ToStringSerializer
;
/**
*
${
table
.
comment
!}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
entityLombokModel
>
@
Data
<#
if
superEntityClass
??>
@
EqualsAndHashCode
(
callSuper
=
true
)
<#
else
>
@
EqualsAndHashCode
(
callSuper
=
false
)
</#
if
>
@
Accessors
(
chain
=
true
)
</#
if
>
<#
if
table
.
convert
>
@
TableName
(
"${table.name}"
)
</#
if
>
<#
if
swagger2
>
@
ApiModel
(
value
=
"${entity}Dto"
,
description
=
"${table.comment!}"
)
</#
if
>
<#
if
superEntityClass
??>
public
class
${
entity
}
Dto
extends
${
superEntityClass
}<#
if
activeRecord
><${
entity
}></#
if
>
{
<#
elseif
activeRecord
>
public
class
${
entity
}
Dto
{
<#
else
>
public
class
${
entity
}
Dto
implements
Serializable
{
</#
if
>
<#
if
entitySerialVersionUID
>
private
static
final
long
serialVersionUID
=
1L
;
</#
if
>
<#--
----------
BEGIN
字段循环遍历
---------->
<#
list
table
.
fields
as
field
>
<#
if
field
.
keyFlag
>
<#
assign
keyPropertyName
=
"${field.propertyName}"
/>
</#
if
>
<#
if
field
.
comment
!?length gt 0>
<#
if
swagger2
>
@
ApiModelProperty
(
value
=
"${field.comment}"
)
<#
else
>
/**
*
${
field
.
comment
}
*/
</#
if
>
</#
if
>
<#
if
field
.
keyFlag
>
<#--
主键
-->
<#
if
field
.
keyIdentityFlag
>
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.
AUTO
)
<#
elseif
idType
??>
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.${
idType
})
<#
elseif
field
.
convert
>
@
TableId
(
"${field.name}"
)
</#
if
>
<#--
普通字段
-->
<#
elseif
field
.
fill
??>
<#--
-----
存在字段填充设置
----->
<#
if
field
.
convert
>
@
TableField
(
value
=
"${field.name}"
,
fill
=
FieldFill
.${
field
.
fill
})
<#
else
>
@
TableField
(
fill
=
FieldFill
.${
field
.
fill
})
</#
if
>
<#
elseif
field
.
convert
>
@
TableField
(
"${field.name}"
)
</#
if
>
<#--
乐观锁注解
-->
<#
if
(
versionFieldName
!"") == field.name>
@
Version
</#
if
>
<#--
逻辑删除注解
-->
<#
if
(
logicDeleteFieldName
!"") == field.name>
@
TableLogic
</#
if
>
private
${
field
.
propertyType
}
${
field
.
propertyName
};
</#
list
>
<#------------
END
字段循环遍历
---------->
<#
if
!entityLombokModel>
<#
list
table
.
fields
as
field
>
<#
if
field
.
propertyType
==
"boolean"
>
<#
assign
getprefix
=
"is"
/>
<#
else
>
<#
assign
getprefix
=
"get"
/>
</#
if
>
public
${
field
.
propertyType
}
${
getprefix
}${
field
.
capitalName
}()
{
return
${
field
.
propertyName
};
}
<#
if
entityBuilderModel
>
public
${
entity
}
set
${
field
.
capitalName
}(${
field
.
propertyType
}
${
field
.
propertyName
})
{
<#
else
>
public
void
set
${
field
.
capitalName
}(${
field
.
propertyType
}
${
field
.
propertyName
})
{
</#
if
>
this
.${
field
.
propertyName
}
=
${
field
.
propertyName
};
<#
if
entityBuilderModel
>
return
this
;
</#
if
>
}
</#
list
>
</#
if
>
<#
if
entityColumnConstant
>
<#
list
table
.
fields
as
field
>
public
static
final
String
${
field
.
name
?
upper_case
}
=
"${field.name}"
;
</#
list
>
</#
if
>
<#
if
activeRecord
>
@
Override
protected
Serializable
pkVal
()
{
<#
if
keyPropertyName
??>
return
this
.${
keyPropertyName
};
<#
else
>
return
null
;
</#
if
>
}
</#
if
>
<#
if
!entityLombokModel>
@
Override
public
String
toString
()
{
return
"${entity}{"
+
<#
list
table
.
fields
as
field
>
<#
if
field_index
==
0
>
"${field.propertyName}="
+
${
field
.
propertyName
}
+
<#
else
>
", ${field.propertyName}="
+
${
field
.
propertyName
}
+
</#
if
>
</#
list
>
"}"
;
}
</#
if
>
}
amos-boot-biz-common/src/main/resources/template/mapper.java.ftl
0 → 100644
View file @
a9d68980
package
${
package
.
Mapper
};
import
${
package
.
Entity
}.${
entity
};
import
${
superMapperClassPackage
};
/**
*
${
table
.
comment
!} Mapper 接口
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
kotlin
>
interface
${
table
.
mapperName
}
:
${
superMapperClass
}<${
entity
}>
<#
else
>
public
interface
${
table
.
mapperName
}
extends
${
superMapperClass
}<${
entity
}>
{
}
</#
if
>
amos-boot-biz-common/src/main/resources/template/mapper.java.vm
0 → 100644
View file @
a9d68980
package
${
package
.
Mapper
};
import
${
package
.
Entity
}.${
entity
};
import
${
superMapperClassPackage
};
/**
*
$
!{table.comment} Mapper 接口
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
#
if
(${
kotlin
})
interface
${
table
.
mapperName
}
:
${
superMapperClass
}<${
entity
}>
#
else
public
interface
${
table
.
mapperName
}
extends
${
superMapperClass
}<${
entity
}>
{
}
#
end
amos-boot-biz-common/src/main/resources/template/mapper.xml.ftl
0 → 100644
View file @
a9d68980
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"${package.Mapper}.${table.mapperName}"
>
<
#if enableCache>
<!-- 开启二级缓存 -->
<cache
type=
"org.mybatis.caches.ehcache.LoggingEhcache"
/>
<
/#if>
<
#if baseResultMap>
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"${package.Entity}.${entity}"
>
<
#list table.fields as field>
<
#if field.keyFlag>
<
#--生成主键排在第一位-->
<id
column=
"${field.name}"
property=
"${field.propertyName}"
/>
<
/#if>
<
/#list>
<
#list table.commonFields as field>
<
#--生成公共字段 -->
<result
column=
"${field.name}"
property=
"${field.propertyName}"
/>
<
/#list>
<
#list table.fields as field>
<
#if !field.keyFlag>
<
#--生成普通字段 -->
<result
column=
"${field.name}"
property=
"${field.propertyName}"
/>
<
/#if>
<
/#list>
</resultMap>
<
/#if>
<
#if baseColumnList>
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
<
#list table.commonFields as field>
${field.name},
<
/#list>
${table.fieldNames}
</sql>
<
/#if>
</mapper>
amos-boot-biz-common/src/main/resources/template/mapper.xml.vm
0 → 100644
View file @
a9d68980
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"${package.Mapper}.${table.mapperName}"
>
#if(${enableCache})
<!-- 开启二级缓存 -->
<cache
type=
"org.mybatis.caches.ehcache.LoggingEhcache"
/>
#end
#if(${baseResultMap})
<!-- 通用查询映射结果 -->
<resultMap
id=
"BaseResultMap"
type=
"${package.Entity}.${entity}"
>
#foreach($field in ${table.fields})
#if(${field.keyFlag})##生成主键排在第一位
<id
column=
"${field.name}"
property=
"${field.propertyName}"
/>
#end
#end
#foreach($field in ${table.commonFields})##生成公共字段
<result
column=
"${field.name}"
property=
"${field.propertyName}"
/>
#end
#foreach($field in ${table.fields})
#if(!${field.keyFlag})##生成普通字段
<result
column=
"${field.name}"
property=
"${field.propertyName}"
/>
#end
#end
</resultMap>
#end
#if(${baseColumnList})
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
#foreach($field in ${table.commonFields})
${field.name},
#end
${table.fieldNames}
</sql>
#end
</mapper>
amos-boot-biz-common/src/main/resources/template/service.java.ftl
0 → 100644
View file @
a9d68980
package
com
.
yeejoin
.
amos
.
boot
.
module
.${
package
.
ModuleName
}.
api
.
service
;
import
${
package
.
Entity
}.${
entity
};
import
${
superServiceClassPackage
};
/**
*
${
table
.
comment
!} 服务类
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
kotlin
>
interface
${
table
.
serviceName
}
:
${
superServiceClass
}<${
entity
}>
<#
else
>
public
interface
${
table
.
serviceName
}
extends
${
superServiceClass
}<${
entity
}>
{
}
</#
if
>
amos-boot-biz-common/src/main/resources/template/service.java.vm
0 → 100644
View file @
a9d68980
package
${
package
.
Service
};
import
${
package
.
Entity
}.${
entity
};
import
${
superServiceClassPackage
};
/**
*
$
!{table.comment} 服务类
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
#
if
(${
kotlin
})
interface
${
table
.
serviceName
}
:
${
superServiceClass
}<${
entity
}>
#
else
public
interface
${
table
.
serviceName
}
extends
${
superServiceClass
}<${
entity
}>
{
}
#
end
amos-boot-biz-common/src/main/resources/template/serviceImpl.java.ftl
0 → 100644
View file @
a9d68980
package
${
package
.
ServiceImpl
};
import
${
package
.
Entity
}.${
entity
};
import
${
package
.
Mapper
}.${
table
.
mapperName
};
import
${
package
.
Service
}.${
table
.
serviceName
};
import
${
superServiceImplClassPackage
};
import
org
.
springframework
.
stereotype
.
Service
;
/**
*
${
table
.
comment
!} 服务实现类
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
@
Service
<#
if
kotlin
>
open
class
${
table
.
serviceImplName
}
:
${
superServiceImplClass
}<${
table
.
mapperName
},
${
entity
}>(),
${
table
.
serviceName
}
{
}
<#
else
>
public
class
${
table
.
serviceImplName
}
extends
${
superServiceImplClass
}<${
table
.
mapperName
},
${
entity
}>
implements
${
table
.
serviceName
}
{
}
</#
if
>
amos-boot-biz-common/src/main/resources/template/serviceImpl.java.vm
0 → 100644
View file @
a9d68980
package
${
package
.
ServiceImpl
};
import
${
package
.
Entity
}.${
entity
};
import
${
package
.
Mapper
}.${
table
.
mapperName
};
import
${
package
.
Service
}.${
table
.
serviceName
};
import
${
superServiceImplClassPackage
};
import
org
.
springframework
.
stereotype
.
Service
;
/**
*
$
!{table.comment} 服务实现类
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
@
Service
#
if
(${
kotlin
})
open
class
${
table
.
serviceImplName
}
:
${
superServiceImplClass
}<${
table
.
mapperName
},
${
entity
}>(),
${
table
.
serviceName
}
{
}
#
else
public
class
${
table
.
serviceImplName
}
extends
${
superServiceImplClass
}<${
table
.
mapperName
},
${
entity
}>
implements
${
table
.
serviceName
}
{
}
#
end
amos-boot-biz-common/src/main/resources/template/vo.java.ftl
0 → 100644
View file @
a9d68980
package
com
.
yeejoin
.
amos
.
boot
.
module
.${
package
.
ModuleName
}.
api
.
vo
;
<#
list
table
.
importPackages
as
pkg
>
import
${
pkg
};
</#
list
>
<#
if
swagger2
>
import
io
.
swagger
.
annotations
.
ApiModel
;
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
</#
if
>
<#
if
entityLombokModel
>
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
import
lombok
.
experimental
.
Accessors
;
</#
if
>
import
com
.
baomidou
.
mybatisplus
.
annotation
.
IdType
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableId
;
import
com
.
fasterxml
.
jackson
.
databind
.
annotation
.
JsonSerialize
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableName
;
import
com
.
fasterxml
.
jackson
.
databind
.
ser
.
std
.
ToStringSerializer
;
/**
*
${
table
.
comment
!}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
entityLombokModel
>
@
Data
@
Accessors
(
chain
=
true
)
</#
if
>
<#
if
table
.
convert
>
@
TableName
(
"${table.name}"
)
</#
if
>
<#
if
swagger2
>
@
ApiModel
(
value
=
"${entity}Vo"
,
description
=
"${table.comment!}"
)
</#
if
>
<#
if
superEntityClass
??>
public
class
${
entity
}
Vo
{
<#
elseif
activeRecord
>
public
class
${
entity
}
Vo
{
<#
else
>
public
class
${
entity
}
Vo
implements
Serializable
{
</#
if
>
<#
if
entitySerialVersionUID
>
private
static
final
long
serialVersionUID
=
1L
;
</#
if
>
<#--
----------
BEGIN
字段循环遍历
---------->
<#
list
table
.
fields
as
field
>
<#
if
field
.
keyFlag
>
<#
assign
keyPropertyName
=
"${field.propertyName}"
/>
</#
if
>
<#
if
field
.
comment
!?length gt 0>
<#
if
swagger2
>
@
ApiModelProperty
(
value
=
"${field.comment}"
)
<#
else
>
/**
*
${
field
.
comment
}
*/
</#
if
>
</#
if
>
<#
if
field
.
keyFlag
>
<#--
主键
-->
<#
if
field
.
keyIdentityFlag
>
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.
AUTO
)
<#
elseif
idType
??>
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.${
idType
})
<#
elseif
field
.
convert
>
@
TableId
(
"${field.name}"
)
</#
if
>
<#--
普通字段
-->
<#
elseif
field
.
fill
??>
<#--
-----
存在字段填充设置
----->
<#
if
field
.
convert
>
@
TableField
(
value
=
"${field.name}"
,
fill
=
FieldFill
.${
field
.
fill
})
<#
else
>
@
TableField
(
fill
=
FieldFill
.${
field
.
fill
})
</#
if
>
<#
elseif
field
.
convert
>
@
TableField
(
"${field.name}"
)
</#
if
>
<#--
乐观锁注解
-->
<#
if
(
versionFieldName
!"") == field.name>
@
Version
</#
if
>
<#--
逻辑删除注解
-->
<#
if
(
logicDeleteFieldName
!"") == field.name>
@
TableLogic
</#
if
>
private
${
field
.
propertyType
}
${
field
.
propertyName
};
</#
list
>
<#------------
END
字段循环遍历
---------->
<#
if
!entityLombokModel>
<#
list
table
.
fields
as
field
>
<#
if
field
.
propertyType
==
"boolean"
>
<#
assign
getprefix
=
"is"
/>
<#
else
>
<#
assign
getprefix
=
"get"
/>
</#
if
>
public
${
field
.
propertyType
}
${
getprefix
}${
field
.
capitalName
}()
{
return
${
field
.
propertyName
};
}
<#
if
entityBuilderModel
>
public
${
entity
}
set
${
field
.
capitalName
}(${
field
.
propertyType
}
${
field
.
propertyName
})
{
<#
else
>
public
void
set
${
field
.
capitalName
}(${
field
.
propertyType
}
${
field
.
propertyName
})
{
</#
if
>
this
.${
field
.
propertyName
}
=
${
field
.
propertyName
};
<#
if
entityBuilderModel
>
return
this
;
</#
if
>
}
</#
list
>
</#
if
>
<#
if
entityColumnConstant
>
<#
list
table
.
fields
as
field
>
public
static
final
String
${
field
.
name
?
upper_case
}
=
"${field.name}"
;
</#
list
>
</#
if
>
<#
if
activeRecord
>
@
Override
protected
Serializable
pkVal
()
{
<#
if
keyPropertyName
??>
return
this
.${
keyPropertyName
};
<#
else
>
return
null
;
</#
if
>
}
</#
if
>
<#
if
!entityLombokModel>
@
Override
public
String
toString
()
{
return
"${entity}{"
+
<#
list
table
.
fields
as
field
>
<#
if
field_index
==
0
>
"${field.propertyName}="
+
${
field
.
propertyName
}
+
<#
else
>
", ${field.propertyName}="
+
${
field
.
propertyName
}
+
</#
if
>
</#
list
>
"}"
;
}
</#
if
>
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment