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
ad07a2b4
Commit
ad07a2b4
authored
Dec 15, 2023
by
LiuLin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(common):调整代码生成类,修改BaseEntity为tyboot
parent
2e47c117
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
844 additions
and
0 deletions
+844
-0
MyBatisPlusCodeGeneratorJyjc.java
...s/boot/biz/common/utils/MyBatisPlusCodeGeneratorJyjc.java
+305
-0
bean.java.ftl
...oot-biz-common/src/main/resources/template2/bean.java.ftl
+33
-0
controller.java.ftl
...z-common/src/main/resources/template2/controller.java.ftl
+135
-0
dto.java.ftl
...boot-biz-common/src/main/resources/template2/dto.java.ftl
+134
-0
mapper.java.ftl
...t-biz-common/src/main/resources/template2/mapper.java.ftl
+18
-0
mapper.xml.ftl
...ot-biz-common/src/main/resources/template2/mapper.xml.ftl
+39
-0
model.java.ftl
...ot-biz-common/src/main/resources/template2/model.java.ftl
+133
-0
service.java.ftl
...-biz-common/src/main/resources/template2/service.java.ftl
+13
-0
serviceImpl.java.ftl
...-common/src/main/resources/template2/serviceImpl.java.ftl
+34
-0
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/MyBatisPlusCodeGeneratorJyjc.java
0 → 100644
View file @
ad07a2b4
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.*
;
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.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
MyBatisPlusCodeGeneratorJyjc
{
/**
* 项目名称缩写
*/
static
String
projectShortName
=
"tzs"
;
/**
* 拆分服务名 可根据实际拆分项目进行修改
*/
static
String
ShortName
=
"jyjc"
;
/**
* 项目api目录
*/
static
String
apiAddress
=
"/amos-boot-system-"
+
projectShortName
+
"/"
+
"amos-boot-module-"
+
ShortName
+
"/"
+
"amos-boot-module-"
+
ShortName
+
"-api/"
;
/**
* 项目biz目录
*/
static
String
bizAddress
=
"/amos-boot-system-"
+
projectShortName
+
"/"
+
"amos-boot-module-"
+
ShortName
+
"/"
+
"amos-boot-module-"
+
ShortName
+
"-biz/"
;
/**
* 项目api路径
*/
static
String
apiPath
=
apiAddress
+
"src/main/java/com/yeejoin/amos/boot/module/"
+
ShortName
+
"/api"
;
/**
* 项目biz路径
*/
static
String
bizPath
=
bizAddress
+
"src/main/java/com/yeejoin/amos/boot/module/"
+
ShortName
+
"/biz"
;
/**
* 接口及实体等代码生成路径
*/
static
String
interfaceCodeOutPath
=
System
.
getProperty
(
"user.dir"
).
replace
(
"\\amos-boot-biz-common"
,
"\\"
)
+
apiPath
;
/**
* 控制器及接口实现等代码生成路径
*/
static
String
controllerCodeOutPath
=
System
.
getProperty
(
"user.dir"
).
replace
(
"\\amos-boot-biz-common"
,
"\\"
)
+
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"
).
replace
(
"\\amos-boot-biz-common"
,
"\\"
);
System
.
out
.
println
(
"projectPath:"
+
projectPath
);
// 代码输出目录
//gc.setOutputDir(codeOutPath);
// 作者
gc
.
setAuthor
(
"system_generator"
);
// 是否自动打开文件夹 建议开启
gc
.
setOpen
(
false
);
// 开启Swagger2 注解支持
gc
.
setSwagger2
(
true
);
// 注入autoGenerator
autoGenerator
.
setGlobalConfig
(
gc
);
gc
.
setActiveRecord
(
false
);
// 数据源配置
DataSourceConfig
dsc
=
new
DataSourceConfig
();
dsc
.
setUrl
(
"jdbc:postgresql://172.16.10.243:5432/tzs_amos_tzs_biz_init?&serverTimezone=GMT%2B8"
);
dsc
.
setSchemaName
(
"amos_tzs_biz"
);
dsc
.
setDriverName
(
"org.postgresql.Driver"
);
// dsc.setDriverName("cn.com.vastbase.Driver");
dsc
.
setUsername
(
"admin"
);
dsc
.
setPassword
(
"Yeejoin@2023"
);
dsc
.
setTypeConvert
((
globalConfig
,
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
(
ShortName
);
// 实体路径
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"
);
pc
.
setXml
(
"api.model"
);
autoGenerator
.
setPackageInfo
(
pc
);
// 自定义配置
InjectionConfig
cfg
=
new
InjectionConfig
()
{
@Override
public
void
initMap
()
{
// to do nothing
}
};
// 如果模板引擎是 freemarker
String
controller
=
"/template2/controller.java.ftl"
;
String
entity
=
"/template2/bean.java.ftl"
;
String
mapper
=
"/template2/mapper.java.ftl"
;
String
service
=
"/template2/service.java.ftl"
;
String
serviceImpl
=
"/template2/serviceImpl.java.ftl"
;
String
mapperXml
=
"/template2/mapper.xml.ftl"
;
String
model
=
"/template2/model.java.ftl"
;
String
vo
=
"/template2/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
;
System
.
out
.
println
(
"controller:"
+
filePath
);
return
filePath
;
}
});
focList
.
add
(
new
FileOutConfig
(
entity
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
String
filePath
=
interfaceCodeOutPath
+
"/entity/"
+
tableInfo
.
getEntityName
()
+
StringPool
.
DOT_JAVA
;
System
.
out
.
println
(
"entity:"
+
filePath
);
return
filePath
;
}
});
focList
.
add
(
new
FileOutConfig
(
model
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
String
filePath
=
interfaceCodeOutPath
+
"/model/"
+
tableInfo
.
getEntityName
()
+
"Model"
+
StringPool
.
DOT_JAVA
;
System
.
out
.
println
(
"model:"
+
filePath
);
return
filePath
;
}
});
// focList.add(new FileOutConfig(vo) {
// @Override
// public String outputFile(TableInfo tableInfo) {
// String filePath = interfaceCodeOutPath
// + "/vo/" + tableInfo.getEntityName() + "Vo" + StringPool.DOT_JAVA;
// System.out.println("vo:"+filePath);
// return filePath;
// }
// });
focList
.
add
(
new
FileOutConfig
(
mapper
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
String
filePath
=
interfaceCodeOutPath
+
"/mapper/"
+
tableInfo
.
getEntityName
()
+
"Mapper"
+
StringPool
.
DOT_JAVA
;
System
.
out
.
println
(
"mapper:"
+
filePath
);
return
filePath
;
}
});
focList
.
add
(
new
FileOutConfig
(
service
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
String
filePath
=
interfaceCodeOutPath
+
"/service/"
+
tableInfo
.
getServiceName
()
+
StringPool
.
DOT_JAVA
;
System
.
out
.
println
(
"service:"
+
filePath
);
return
filePath
;
}
});
focList
.
add
(
new
FileOutConfig
(
serviceImpl
)
{
@Override
public
String
outputFile
(
TableInfo
tableInfo
)
{
String
filePath
=
controllerCodeOutPath
+
"/service/impl/"
+
tableInfo
.
getServiceImplName
()
+
StringPool
.
DOT_JAVA
;
System
.
out
.
println
(
"service/impl:"
+
filePath
);
return
filePath
;
}
});
// 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 的名称会跟着发生变化!!
String
filePath
=
projectPath
+
apiAddress
+
"src/main/resources/mapper/"
+
tableInfo
.
getEntityName
()
+
"Mapper"
+
StringPool
.
DOT_XML
;
System
.
out
.
println
(
"mapper:"
+
filePath
);
return
filePath
;
}
});
/*
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
(
"sequence_nbr"
,
"rec_date"
,
"rec_user_id"
,
"rec_user_name"
,
"is_delete"
);
// 建议以后开启
strategy
.
setInclude
(
scanner
(
"表名,多个英文逗号分割"
).
split
(
","
));
strategy
.
setControllerMappingHyphenStyle
(
true
);
strategy
.
setTablePrefix
();
//去除表名前缀
//去除表名前缀
strategy
.
setTablePrefix
(
"t_"
,
"tb_"
,
"sys_"
,
"other_"
,
"rpm_"
,
"s_"
,
"tcb_"
,
"cb_"
,
"tz_"
,
"jc_"
,
"jcb_"
,
"tzs_"
);
// 设置父级Controller
strategy
.
setSuperControllerClass
(
"com.yeejoin.amos.boot.biz.common.controller.BaseController"
);
autoGenerator
.
setStrategy
(
strategy
);
autoGenerator
.
setTemplateEngine
(
new
FreemarkerTemplateEngine
());
autoGenerator
.
execute
();
}
}
\ No newline at end of file
amos-boot-biz-common/src/main/resources/template2/bean.java.ftl
0 → 100644
View file @
ad07a2b4
package
${
package
.
Entity
};
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableField
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableName
;
import
org
.
typroject
.
tyboot
.
core
.
rdbms
.
orm
.
entity
.
BaseEntity
;
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
import
lombok
.
experimental
.
Accessors
;
/**
*
${
table
.
comment
!}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
@
Data
@
EqualsAndHashCode
(
callSuper
=
true
)
@
Accessors
(
chain
=
true
)
@
TableName
(
"${table.name}"
)
public
class
${
entity
}
extends
BaseEntity
{
private
static
final
long
serialVersionUID
=
1L
;
<#--
----------
BEGIN
字段循环遍历
---------->
<#
list
table
.
fields
as
field
>
/**
*
${
field
.
comment
}
*/
@
TableField
(
"${field.name}"
)
private
${
field
.
propertyType
}
${
field
.
propertyName
};
</#
list
>
}
amos-boot-biz-common/src/main/resources/template2/controller.java.ftl
0 → 100644
View file @
ad07a2b4
package
${
package
.
Controller
};
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestMapping
;
import
io
.
swagger
.
annotations
.
ApiOperation
;
import
io
.
swagger
.
annotations
.
Api
;
<#
if
restControllerStyle
>
import
org
.
springframework
.
web
.
bind
.
annotation
.
RestController
;
<#
else
>
import
org
.
springframework
.
stereotype
.
Controller
;
</#
if
>
<#
if
superControllerClassPackage
??>
import
${
superControllerClassPackage
};
</#
if
>
import
java
.
util
.
List
;
import
${
package
.
ServiceImpl
}.${
table
.
serviceImplName
};
import
org
.
typroject
.
tyboot
.
core
.
restful
.
utils
.
ResponseHelper
;
import
org
.
typroject
.
tyboot
.
core
.
restful
.
utils
.
ResponseModel
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
javax
.
servlet
.
http
.
HttpServletRequest
;
import
org
.
springframework
.
web
.
bind
.
annotation
.*;
import
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
;
import
${
package
.
Xml
}.${
entity
}
Model
;
import
org
.
typroject
.
tyboot
.
core
.
restful
.
doc
.
TycloudOperation
;
import
org
.
typroject
.
tyboot
.
core
.
foundation
.
enumeration
.
UserType
;
/**
*
${
table
.
comment
!}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
restControllerStyle
>
@
RestController
@
Api
(
tags
=
"${table.comment}Api"
)
<#
else
>
@
Controller
</#
if
>
@
RequestMapping
(
value
=
"/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>"
)
<#
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
.
serviceImplName
}
${
table
.
serviceImplName
?
uncap_first
};
/**
*
新增
${
table
.
comment
}
*
*
@
return
*/
@
TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@
PostMapping
(
value
=
"/save"
)
@
ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增${table.comment}"
,
notes
=
"新增${table.comment}"
)
public
ResponseModel
<${
entity
}
Model
>
save
(@
RequestBody
${
entity
}
Model
model
)
{
model
=
${
table
.
serviceImplName
?
uncap_first
}.
createWithModel
(
model
);
return
ResponseHelper
.
buildResponse
(
model
);
}
/**
*
根据
sequenceNbr
更新
*
*
@
param
sequenceNbr
主键
*
@
return
*/
@
TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@
PutMapping
(
value
=
"/{sequenceNbr}"
)
@
ApiOperation
(
httpMethod
=
"PUT"
,
value
=
"根据sequenceNbr更新${table.comment}"
,
notes
=
"根据sequenceNbr更新${table.comment}"
)
public
ResponseModel
<${
entity
}
Model
>
updateBySequenceNbr
${
entity
}(@
RequestBody
${
entity
}
Model
model
,@
PathVariable
(
value
=
"sequenceNbr"
)
Long
sequenceNbr
)
{
model
.
setSequenceNbr
(
sequenceNbr
);
return
ResponseHelper
.
buildResponse
(${
table
.
serviceImplName
?
uncap_first
}.
updateWithModel
(
model
));
}
/**
*
根据
sequenceNbr
删除
*
*
@
param
sequenceNbr
主键
*
@
return
*/
@
TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@
DeleteMapping
(
value
=
"/{sequenceNbr}"
)
@
ApiOperation
(
httpMethod
=
"DELETE"
,
value
=
"根据sequenceNbr删除${table.comment}"
,
notes
=
"根据sequenceNbr删除${table.comment}"
)
public
ResponseModel
<
Boolean
>
deleteBySequenceNbr
(
HttpServletRequest
request
,
@
PathVariable
(
value
=
"sequenceNbr"
)
Long
sequenceNbr
){
return
ResponseHelper
.
buildResponse
(${
table
.
serviceImplName
?
uncap_first
}.
removeById
(
sequenceNbr
));
}
/**
*
根据
sequenceNbr
查询
*
*
@
param
sequenceNbr
主键
*
@
return
*/
@
TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@
GetMapping
(
value
=
"/{sequenceNbr}"
)
@
ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据sequenceNbr查询单个${table.comment}"
,
notes
=
"根据sequenceNbr查询单个${table.comment}"
)
public
ResponseModel
<${
entity
}
Model
>
selectOne
(@
PathVariable
Long
sequenceNbr
)
{
return
ResponseHelper
.
buildResponse
(${
table
.
serviceImplName
?
uncap_first
}.
queryBySeq
(
sequenceNbr
));
}
/**
*
列表分页查询
*
*
@
param
current
当前页
*
@
param
current
每页大小
*
@
return
*/
@
TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@
GetMapping
(
value
=
"/page"
)
@
ApiOperation
(
httpMethod
=
"GET"
,
value
=
"分页查询${table.comment}"
,
notes
=
"分页查询${table.comment}"
)
public
ResponseModel
<
Page
<${
entity
}
Model
>>
queryForPage
(@
RequestParam
(
value
=
"current"
)
int
current
,@
RequestParam
(
value
=
"size"
)
int
size
)
{
Page
<${
entity
}
Model
>
page
=
new
Page
<${
entity
}
Model
>();
page
.
setCurrent
(
current
);
page
.
setSize
(
size
);
return
ResponseHelper
.
buildResponse
(${
table
.
serviceImplName
?
uncap_first
}.
queryFor
${
entity
}
Page
(
page
));
}
/**
*
列表全部数据查询
*
*
@
return
*/
@
TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@
ApiOperation
(
httpMethod
=
"GET"
,
value
=
"列表全部数据查询${table.comment}"
,
notes
=
"列表全部数据查询${table.comment}"
)
@
GetMapping
(
value
=
"/list"
)
public
ResponseModel
<
List
<${
entity
}
Model
>>
selectForList
()
{
return
ResponseHelper
.
buildResponse
(${
table
.
serviceImplName
?
uncap_first
}.
queryFor
${
entity
}
List
());
}
}
</#
if
>
\ No newline at end of file
amos-boot-biz-common/src/main/resources/template2/dto.java.ftl
0 → 100644
View file @
ad07a2b4
package
com
.
yeejoin
.
amos
.
boot
.
module
.${
package
.
ModuleName
}.
api
.
dto
;
import
io
.
swagger
.
annotations
.
ApiModel
;
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
import
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
dto
.
BaseDto
;
<#
if
entityLombokModel
>
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
</#
if
>
import
java
.
util
.
Date
;
/**
*
${
table
.
comment
!}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
entityLombokModel
>
@
Data
<#
if
superEntityClass
??>
@
EqualsAndHashCode
(
callSuper
=
true
)
<#
else
>
@
EqualsAndHashCode
(
callSuper
=
false
)
</#
if
>
</#
if
>
<#
if
swagger2
>
@
ApiModel
(
value
=
"${entity}Dto"
,
description
=
"${table.comment!}"
)
</#
if
>
public
class
${
entity
}
Dto
extends
BaseDto
{
private
static
final
long
serialVersionUID
=
1L
;
<#--
----------
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/template2/mapper.java.ftl
0 → 100644
View file @
ad07a2b4
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/template2/mapper.xml.ftl
0 → 100644
View file @
ad07a2b4
<?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/template2/model.java.ftl
0 → 100644
View file @
ad07a2b4
package
com
.
yeejoin
.
amos
.
boot
.
module
.${
package
.
ModuleName
}.
api
.
model
;
import
io
.
swagger
.
annotations
.
ApiModel
;
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
import
org
.
typroject
.
tyboot
.
core
.
rdbms
.
model
.
BaseModel
;
<#
if
entityLombokModel
>
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
</#
if
>
/**
*
${
table
.
comment
!}
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
entityLombokModel
>
@
Data
<#
if
superEntityClass
??>
@
EqualsAndHashCode
(
callSuper
=
true
)
<#
else
>
@
EqualsAndHashCode
(
callSuper
=
false
)
</#
if
>
</#
if
>
<#
if
swagger2
>
@
ApiModel
(
value
=
"${entity}Model"
,
description
=
"${table.comment!}"
)
</#
if
>
public
class
${
entity
}
Model
extends
BaseModel
{
private
static
final
long
serialVersionUID
=
1L
;
<#--
----------
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/template2/service.java.ftl
0 → 100644
View file @
ad07a2b4
package
com
.
yeejoin
.
amos
.
boot
.
module
.${
package
.
ModuleName
}.
api
.
service
;
/**
*
${
table
.
comment
!}接口类
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
<#
if
kotlin
>
interface
${
table
.
serviceName
}
:
${
superServiceClass
}<${
entity
}>
<#
else
>
public
interface
${
table
.
serviceName
}
{}
</#
if
>
amos-boot-biz-common/src/main/resources/template2/serviceImpl.java.ftl
0 → 100644
View file @
ad07a2b4
package
${
package
.
ServiceImpl
};
import
${
package
.
Entity
}.${
entity
};
import
${
package
.
Mapper
}.${
table
.
mapperName
};
import
${
package
.
Service
}.${
table
.
serviceName
};
import
${
package
.
Xml
}.${
entity
}
Model
;
import
org
.
typroject
.
tyboot
.
core
.
rdbms
.
service
.
BaseService
;
import
org
.
springframework
.
stereotype
.
Service
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
;
import
java
.
util
.
List
;
/**
*
${
table
.
comment
!}服务实现类
*
*
@
author
${
author
}
*
@
date
${
date
}
*/
@
Service
public
class
${
table
.
serviceImplName
}
extends
BaseService
<${
entity
}
Model
,${
entity
},${
table
.
mapperName
}>
implements
${
table
.
serviceName
}
{
/**
*
分页查询
*/
public
Page
<${
entity
}
Model
>
queryFor
${
entity
}
Page
(
Page
<${
entity
}
Model
>
page
)
{
return
this
.
queryForPage
(
page
,
null
,
false
);
}
/**
*
列表查询
示例
*/
public
List
<${
entity
}
Model
>
queryFor
${
entity
}
List
()
{
return
this
.
queryForList
(
""
,
false
);
}
}
\ No newline at end of file
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