Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
ydl-generator
Overview
Overview
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
余保谷
ydl-generator
Commits
9214bf2c
Commit
9214bf2c
authored
Apr 10, 2019
by
flying-cattle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整合mybatis-plus组件,使用了lombok,带swagger文档api,实现增删改查、分页查询接口
parent
fb2e190c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
308 deletions
+106
-308
controller.ftl
src/main/resources/freemarker/ftl/controller.ftl
+44
-100
dao.ftl
src/main/resources/freemarker/ftl/dao.ftl
+10
-15
entity.ftl
src/main/resources/freemarker/ftl/entity.ftl
+27
-13
mapper.ftl
src/main/resources/freemarker/ftl/mapper.ftl
+4
-67
service.ftl
src/main/resources/freemarker/ftl/service.ftl
+10
-57
serviceImpl.ftl
src/main/resources/freemarker/ftl/serviceImpl.ftl
+11
-56
No files found.
src/main/resources/freemarker/ftl/controller.ftl
View file @
9214bf2c
...
@@ -6,35 +6,40 @@
...
@@ -6,35 +6,40 @@
*/
*/
package
${
controllerUrl
};
package
${
controllerUrl
};
import
java
.
util
.
List
;
import
org
.
slf4j
.
Logger
;
import
org
.
slf4j
.
LoggerFactory
;
import
com
.
item
.
util
.
JsonResult
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
${
entityUrl
}.${
entityName
};
import
${
serviceUrl
}.${
entityName
}
Service
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
GetMapping
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
GetMapping
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
PathVariable
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
PathVariable
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
PostMapping
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
PostMapping
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestMapping
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestMapping
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RestController
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RestController
;
import
com
.
baomidou
.
mybatisplus
.
core
.
conditions
.
query
.
QueryWrapper
;
import
com
.
github
.
pagehelper
.
PageInfo
;
import
com
.
baomidou
.
mybatisplus
.
core
.
metadata
.
IPage
;
import
com
.
item
.
util
.
AppPage
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
;
import
com
.
item
.
util
.
JsonResult
;
import
${
entityUrl
}.${
entityName
};
import
${
serviceUrl
}.${
entityName
}
Service
;
import
io
.
swagger
.
annotations
.
Api
;
import
io
.
swagger
.
annotations
.
Api
;
import
io
.
swagger
.
annotations
.
ApiImplicitParam
;
import
io
.
swagger
.
annotations
.
ApiImplicitParam
;
import
io
.
swagger
.
annotations
.
ApiImplicitParams
;
import
io
.
swagger
.
annotations
.
ApiImplicitParams
;
import
io
.
swagger
.
annotations
.
ApiOperation
;
import
io
.
swagger
.
annotations
.
ApiOperation
;
import
org
.
slf4j
.
Logger
;
import
org
.
slf4j
.
LoggerFactory
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
/**
/**
*
Copyright
:
Copyright
(
c
)
2019
*
*
*
@
Description
:
${
entityComment
}
接口层
*
<
p
>
说明:
${
entityComment
}
API
接口层
</
P
>
*
@
Author
:
${
author
}
*
@
version
:
${
version
}
*
@
CreateDate
:
${
createTime
}
*
@
author
:
${
author
}
*
@
Version
:
${
version
}
*
*
*
Modification
History
:
*
Date
Author
Version
Description
*---------------------------------------------------------------*
*
${
createTime
}
${
author
}
${
version
}
initialize
*/
*/
@
Api
(
description
=
"${entityComment}"
,
value
=
"${entityComment}"
)
@
Api
(
description
=
"${entityComment}"
,
value
=
"${entityComment}"
)
@
RestController
@
RestController
...
@@ -59,26 +64,25 @@ public class ${entityName}Controller {
...
@@ -59,26 +64,25 @@ public class ${entityName}Controller {
public
JsonResult
<${
entityName
}>
get
${
entityName
}
ById
(@
PathVariable
(
"id"
)${
idType
}
id
){
public
JsonResult
<${
entityName
}>
get
${
entityName
}
ById
(@
PathVariable
(
"id"
)${
idType
}
id
){
JsonResult
<${
entityName
}>
result
=
new
JsonResult
<${
entityName
}>();
JsonResult
<${
entityName
}>
result
=
new
JsonResult
<${
entityName
}>();
try
{
try
{
${
entityName
}
${
objectName
}=${
objectName
}
ServiceImpl
.
selectByPrimaryKey
(
id
);
${
entityName
}
${
objectName
}=${
objectName
}
ServiceImpl
.
getById
(
id
);
if
(${
objectName
}
!=null) {
if
(${
objectName
}
!=null) {
result
.
set
Code
(
1
);
result
.
set
Type
(
"success"
);
result
.
setMessage
(
"成功"
);
result
.
setMessage
(
"成功"
);
result
.
setData
(${
objectName
});
result
.
setData
(${
objectName
});
}
else
{
}
else
{
logger
.
error
(
"获取${entityComment}失败ID:"
+
id
);
logger
.
error
(
"获取${entityComment}失败ID:"
+
id
);
result
.
set
Code
(-
1
);
result
.
set
Type
(
"fail"
);
result
.
setMessage
(
"你获取的${entityComment}不存在"
);
result
.
setMessage
(
"你获取的${entityComment}不存在"
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取${entityComment}执行异常:"
+
e
.
getMessage
());
logger
.
error
(
"获取${entityComment}执行异常:"
+
e
.
getMessage
());
result
.
setCode
(-
1
);
result
=
new
JsonResult
<${
entityName
}>(
e
);
result
.
setMessage
(
"执行异常,请稍后重试"
);
}
}
return
result
;
return
result
;
}
}
/**
/**
*
@
explain
添加
${
entityComment
}
对象
*
@
explain
添加
或者更新
${
entityComment
}
对象
*
@
param
对象参数:
${
objectName
}
*
@
param
对象参数:
${
objectName
}
*
@
return
int
*
@
return
int
*
@
author
${
author
}
*
@
author
${
author
}
...
@@ -89,20 +93,19 @@ public class ${entityName}Controller {
...
@@ -89,20 +93,19 @@ public class ${entityName}Controller {
public
JsonResult
<${
entityName
}>
insertSelective
(${
entityName
}
${
objectName
}){
public
JsonResult
<${
entityName
}>
insertSelective
(${
entityName
}
${
objectName
}){
JsonResult
<${
entityName
}>
result
=
new
JsonResult
<${
entityName
}>();
JsonResult
<${
entityName
}>
result
=
new
JsonResult
<${
entityName
}>();
try
{
try
{
int
rg
=${
objectName
}
ServiceImpl
.
insertSelectiv
e
(${
objectName
});
boolean
rg
=${
objectName
}
ServiceImpl
.
saveOrUpdat
e
(${
objectName
});
if
(
rg
>
0
)
{
if
(
rg
)
{
result
.
set
Code
(
1
);
result
.
set
Type
(
"success"
);
result
.
setMessage
(
"成功"
);
result
.
setMessage
(
"成功"
);
result
.
setData
(${
objectName
});
result
.
setData
(${
objectName
});
}
else
{
}
else
{
logger
.
error
(
"添加${entityComment}执行失败:"
+${
objectName
}.
toString
());
logger
.
error
(
"添加${entityComment}执行失败:"
+${
objectName
}.
toString
());
result
.
set
Code
(-
1
);
result
.
set
Type
(
"fail"
);
result
.
setMessage
(
"执行失败,请稍后重试"
);
result
.
setMessage
(
"执行失败,请稍后重试"
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"添加${entityComment}执行异常:"
+
e
.
getMessage
());
logger
.
error
(
"添加${entityComment}执行异常:"
+
e
.
getMessage
());
result
.
setCode
(-
1
);
result
=
new
JsonResult
<${
entityName
}>(
e
);
result
.
setMessage
(
"执行异常,请稍后重试"
);
}
}
return
result
;
return
result
;
}
}
...
@@ -120,74 +123,19 @@ public class ${entityName}Controller {
...
@@ -120,74 +123,19 @@ public class ${entityName}Controller {
public
JsonResult
<
Object
>
deleteByPrimaryKey
(${
idType
}
id
){
public
JsonResult
<
Object
>
deleteByPrimaryKey
(${
idType
}
id
){
JsonResult
<
Object
>
result
=
new
JsonResult
<
Object
>();
JsonResult
<
Object
>
result
=
new
JsonResult
<
Object
>();
try
{
try
{
int
reg
=${
objectName
}
ServiceImpl
.
deleteByPrimaryKey
(
id
);
boolean
reg
=${
objectName
}
ServiceImpl
.
removeById
(
id
);
if
(
reg
>
0
)
{
if
(
reg
)
{
result
.
set
Code
(
1
);
result
.
set
Type
(
"success"
);
result
.
setMessage
(
"成功"
);
result
.
setMessage
(
"成功"
);
result
.
setData
(
id
);
result
.
setData
(
id
);
}
else
{
}
else
{
logger
.
error
(
"删除${entityComment}失败ID:"
+
id
);
logger
.
error
(
"删除${entityComment}失败ID:"
+
id
);
result
.
set
Code
(-
1
);
result
.
set
Type
(
"fail"
);
result
.
setMessage
(
"执行错误,请稍后重试"
);
result
.
setMessage
(
"执行错误,请稍后重试"
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"删除${entityComment}执行异常:"
+
e
.
getMessage
());
logger
.
error
(
"删除${entityComment}执行异常:"
+
e
.
getMessage
());
result
.
setCode
(-
1
);
result
=
new
JsonResult
<
Object
>(
e
);
result
.
setMessage
(
"执行异常,请稍后重试"
);
}
return
result
;
}
/**
*
@
explain
修改
${
entityComment
}
对象
*
@
param
对象参数:
${
objectName
}
*
@
return
${
objectName
}
*
@
author
${
author
}
*
@
time
${
createTime
}
*/
@
ApiOperation
(
value
=
"修改${entityComment}"
,
notes
=
"修改${entityComment}[${objectName}],作者:${author}"
)
@
PostMapping
(
"/updateByPrimaryKeySelective"
)
public
JsonResult
<${
entityName
}>
updateByPrimaryKeySelective
(${
entityName
}
${
objectName
}){
JsonResult
<${
entityName
}>
result
=
new
JsonResult
<${
entityName
}>();
try
{
int
reg
=
${
objectName
}
ServiceImpl
.
updateByPrimaryKeySelective
(${
objectName
});
if
(
reg
>
0
)
{
result
.
setCode
(
1
);
result
.
setMessage
(
"成功"
);
result
.
setData
(${
objectName
});
}
else
{
logger
.
error
(
"修改${entityComment}失败ID:"
+${
objectName
}.
toString
());
result
.
setCode
(-
1
);
result
.
setMessage
(
"执行错误,请稍后重试"
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"修改${entityComment}执行异常:"
+
e
.
getMessage
());
result
.
setCode
(-
1
);
result
.
setMessage
(
"执行异常,请稍后重试"
);
}
return
result
;
}
/**
*
@
explain
获取匹配
${
entityComment
}
*
@
param
对象参数:
${
objectName
}
*
@
return
List
<${
entityName
}>
*
@
author
${
author
}
*
@
time
${
createTime
}
*/
@
ApiOperation
(
value
=
"条件查询${entityComment}"
,
notes
=
"条件查询[${objectName}],作者:${author}"
)
@
PostMapping
(
"/query${entityName}List"
)
public
JsonResult
<
List
<${
entityName
}>>
query
${
entityName
}
List
(${
entityName
}
${
objectName
}){
JsonResult
<
List
<${
entityName
}>>
result
=
new
JsonResult
<
List
<${
entityName
}>>();
try
{
List
<${
entityName
}>
list
=
${
objectName
}
ServiceImpl
.
query
${
entityName
}
List
(${
objectName
});
result
.
setCode
(
1
);
result
.
setMessage
(
"成功"
);
result
.
setData
(
list
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"获取${entityComment}执行异常:"
+
e
.
getMessage
());
result
.
setCode
(-
1
);
result
.
setMessage
(
"执行异常,请稍后重试"
);
}
}
return
result
;
return
result
;
}
}
...
@@ -199,30 +147,26 @@ public class ${entityName}Controller {
...
@@ -199,30 +147,26 @@ public class ${entityName}Controller {
*
@
author
${
author
}
*
@
author
${
author
}
*
@
time
${
createTime
}
*
@
time
${
createTime
}
*/
*/
@
GetMapping
(
"/get
Page${entityName}
"
)
@
GetMapping
(
"/get
${entityName}Pages
"
)
@
ApiOperation
(
value
=
"分页查询"
,
notes
=
"分页查询返回对象[
PageInfo
<${entityName}>],作者:边鹏"
)
@
ApiOperation
(
value
=
"分页查询"
,
notes
=
"分页查询返回对象[
IPage
<${entityName}>],作者:边鹏"
)
@
ApiImplicitParams
({
@
ApiImplicitParams
({
@
ApiImplicitParam
(
paramType
=
"query"
,
name
=
"pageNum"
,
value
=
"当前页"
,
required
=
true
,
dataType
=
"int"
),
@
ApiImplicitParam
(
paramType
=
"query"
,
name
=
"pageNum"
,
value
=
"当前页"
,
required
=
true
,
dataType
=
"int"
),
@
ApiImplicitParam
(
paramType
=
"query"
,
name
=
"pageSize"
,
value
=
"页行数"
,
required
=
true
,
dataType
=
"int"
)
@
ApiImplicitParam
(
paramType
=
"query"
,
name
=
"pageSize"
,
value
=
"页行数"
,
required
=
true
,
dataType
=
"int"
)
})
})
public
JsonResult
<
PageInfo
<${
entityName
}>>
get
${
entityName
}
BySearch
(
Integer
pageNum
,
Integer
pageSize
){
public
JsonResult
<
IPage
<${
entityName
}>>
get
${
entityName
}
Pages
(
Integer
pageNum
,
Integer
pageSize
){
JsonResult
<
PageInfo
<${
entityName
}>>
result
=
new
JsonResult
<
PageInfo
<${
entityName
}>>();
AppPage
<${
entityName
}>
page
=
new
AppPage
<${
entityName
}>();
JsonResult
<
IPage
<${
entityName
}>>
result
=
new
JsonResult
<
IPage
<${
entityName
}>>();
page
.
setPageNum
(
pageNum
);
Page
<${
entityName
}>
page
=
new
Page
<${
entityName
}>(
pageNum
,
pageSize
);
page
.
setPageSize
(
pageSize
);
QueryWrapper
<${
entityName
}>
queryWrapper
=
new
QueryWrapper
<${
entityName
}>();
//
其他参数
${
entityName
}
${
objectName
}=
new
${
entityName
}();
page
.
setParam
(${
objectName
});
//
分页数据
//
分页数据
try
{
try
{
PageInfo
<${
entityName
}>
pageInfo
=
${
objectName
}
ServiceImpl
.
get
${
entityName
}
BySearch
(
page
);
IPage
<${
entityName
}>
pageInfo
=${
objectName
}
ServiceImpl
.
page
(
page
,
queryWrapper
);
result
.
set
Code
(
1
);
result
.
set
Type
(
"success"
);
result
.
setMessage
(
"成功"
);
result
.
setMessage
(
"成功"
);
result
.
setData
(
pageInfo
);
result
.
setData
(
pageInfo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"分页查询${entityComment}执行异常:"
+
e
.
getMessage
());
logger
.
error
(
"分页查询${entityComment}执行异常:"
+
e
.
getMessage
());
result
.
setCode
(-
1
);
result
=
new
JsonResult
<
IPage
<${
entityName
}>>(
e
);
result
.
setMessage
(
"执行异常,请稍后重试"
);
}
}
return
result
;
return
result
;
}
}
...
...
src/main/resources/freemarker/ftl/dao.ftl
View file @
9214bf2c
...
@@ -7,28 +7,24 @@
...
@@ -7,28 +7,24 @@
package
${
daoUrl
};
package
${
daoUrl
};
import
java
.
util
.
List
;
import
java
.
util
.
List
;
import
com
.
baomidou
.
mybatisplus
.
core
.
mapper
.
BaseMapper
;
import
org
.
apache
.
ibatis
.
annotations
.
Mapper
;
import
org
.
apache
.
ibatis
.
annotations
.
Mapper
;
import
${
entityUrl
}.${
entityName
};
import
${
entityUrl
}.${
entityName
};
/**
/**
*
Copyright
:
Copyright
(
c
)
2019
*
*
*
@
Description
:
${
entityComment
}
——
DAO
*
<
p
>
说明:
${
entityComment
}
数据访问层
</
P
>
*
@
Author
:
${
author
}
*
@
version
:
${
version
}
*
@
CreateDate
:
${
createTime
}
*
@
author
:
${
author
}
*
@
Version
:
${
version
}
*
*
*
Modification
History
:
*
Date
Author
Version
Description
*---------------------------------------------------------------*
*
${
createTime
}
${
author
}
${
version
}
initialize
*/
*/
@
Mapper
@
Mapper
public
interface
${
entityName
}
Dao
{
public
interface
${
entityName
}
Dao
extends
BaseMapper
<${
entityName
}>
{
public
${
entityName
}
selectByPrimaryKey
(${
idType
}
id
);
public
int
deleteByPrimaryKey
(${
idType
}
id
);
public
int
insertSelective
(${
entityName
}
${
objectName
});
public
int
updateByPrimaryKeySelective
(${
entityName
}
${
objectName
});
public
List
<${
entityName
}>
query
${
entityName
}
List
(${
entityName
}
${
objectName
});
}
}
\ No newline at end of file
src/main/resources/freemarker/ftl/entity.ftl
View file @
9214bf2c
...
@@ -6,28 +6,34 @@
...
@@ -6,28 +6,34 @@
*/
*/
package
${
entityUrl
};
package
${
entityUrl
};
import
java
.
io
.
Serializabl
e
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
IdTyp
e
;
import
java
.
util
.
Date
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableId
;
import
org
.
springframework
.
format
.
annotation
.
DateTimeFormat
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
activerecord
.
Model
;
import
com
.
fasterxml
.
jackson
.
annotation
.
JsonFormat
;
import
com
.
fasterxml
.
jackson
.
annotation
.
JsonFormat
;
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
import
io
.
swagger
.
annotations
.
ApiModelProperty
;
import
lombok
.
Data
;
import
lombok
.
Data
;
import
lombok
.
NoArgsConstructor
;
import
lombok
.
EqualsAndHashCode
;
import
lombok
.
AllArgsConstructor
;
import
lombok
.
experimental
.
Accessors
;
import
java
.
util
.
Date
;
import
org
.
springframework
.
format
.
annotation
.
DateTimeFormat
;
import
java
.
io
.
Serializable
;
/**
/**
*
Copyright
:
Copyright
(
c
)
2019
*
*
*
@
Description
:
${
entityComment
}
*
<
p
>
说明:
${
entityComment
}
实体类
</
P
>
*
@
Author
:
${
author
}
*
@
version
:
${
version
}
*
@
CreateDate
:
${
createTime
}
*
@
author
:
${
author
}
*
@
Version
:
${
version
}
*
*
*
Modification
History
:
*
Date
Author
Version
Description
*---------------------------------------------------------------*
*
${
createTime
}
${
author
}
${
version
}
initialize
*/
*/
@
Data
@
Data
@
AllArgsConstructor
@
EqualsAndHashCode
(
callSuper
=
false
)
@
NoArgsConstructor
@
Accessors
(
chain
=
true
)
public
class
${
entityName
}
implements
Serializable
{
public
class
${
entityName
}
extends
Model
<${
entityName
}>
{
private
static
final
long
serialVersionUID
=
${
agile
}
L
;
private
static
final
long
serialVersionUID
=
${
agile
}
L
;
...
@@ -44,8 +50,15 @@ public class ${entityName} implements Serializable {
...
@@ -44,8 +50,15 @@ public class ${entityName} implements Serializable {
@
JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@
JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
</#
if
>
</#
if
>
</#
if
>
</#
if
>
<#
if
ci
.
property
==
"id"
>
@
TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
</#
if
>
@
ApiModelProperty
(
name
=
"${ci.property}"
,
value
=
"${ci.comment}"
)
@
ApiModelProperty
(
name
=
"${ci.property}"
,
value
=
"${ci.comment}"
)
private
${
ci
.
javaType
}
${
ci
.
property
};
private
${
ci
.
javaType
}
${
ci
.
property
};
</#
list
>
</#
list
>
@
Override
protected
Serializable
pkVal
()
{
return
this
.
id
;
}
}
}
\ No newline at end of file
src/main/resources/freemarker/ftl/mapper.ftl
View file @
9214bf2c
<?xml version="1.0" encoding="UTF-8"?>
<?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">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"${daoUrl}.${entityName}Dao"
>
<mapper
namespace=
"${daoUrl}.${entityName}Dao"
>
<resultMap
id=
"BaseResultMap"
type=
"${entityUrl}.${entityName}"
>
<resultMap
id=
"BaseResultMap"
type=
"${entityUrl}.${entityName}"
>
<
#list cis as ci>
<
#list cis as ci>
<id
column=
"${ci.column}"
jdbcType=
"${ci.jdbcType?upper_case
}"
property=
"${ci.property}"
/>
<id
column=
"${ci.column
}"
property=
"${ci.property}"
/>
<
/#list>
<
/#list>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
${agile}
${agile}
</sql>
</sql>
<!-- 查询 -->
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.${idType}"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from ${table}
where id = ${r'#{'}id,jdbcType=${idJdbcType?upper_case}}
</select>
<!-- 删除 -->
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.${idType}"
>
delete from ${table}
where id = ${r'#{'}id,jdbcType=${idJdbcType?upper_case}}
</delete>
<!-- 选择添加 -->
<insert
id=
"insertSelective"
parameterType=
"${entityUrl}.${entityName}"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.${idType}"
>
SELECT
LAST_INSERT_ID()
</selectKey>
insert into ${table}
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<
#list cis as ci>
<if
test=
"${ci.property} != null"
>
${ci.column},
</if>
<
/#list>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<
#list cis as ci>
<if
test=
"${ci.property} != null"
>
${r'#{'}${ci.property},jdbcType=${ci.jdbcType?upper_case}},
</if>
<
/#list>
</trim>
</insert>
<!-- 选择修改 -->
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"${entityUrl}.${entityName}"
>
update ${table}
<set>
<
#list cis as ci>
<if
test=
"${ci.property} != null"
>
${ci.column} = ${r'#{'}${ci.property},jdbcType=${ci.jdbcType?upper_case}},
</if>
<
/#list>
</set>
where id = ${r'#{'}id,jdbcType=${idJdbcType}}
</update>
<!-- 组合条件查询 -->
<select
id=
"query${entityName}List"
parameterType=
"${entityUrl}.${entityName}"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from ${table}
<where>
<if
test=
"id != null"
>
id = ${r'#{'}id,jdbcType=${idJdbcType?upper_case}}
</if>
<
#list cis as ci>
<
#if ci.column!="id">
<if
test=
"${ci.property} != null"
>
AND ${ci.column} = ${r'#{'}${ci.property} ,jdbcType=${ci.jdbcType?upper_case}}
</if>
<
/#if>
<
/#list>
</where>
</select>
</mapper>
</mapper>
\ No newline at end of file
src/main/resources/freemarker/ftl/service.ftl
View file @
9214bf2c
...
@@ -6,66 +6,20 @@
...
@@ -6,66 +6,20 @@
*/
*/
package
${
serviceUrl
};
package
${
serviceUrl
};
import
java
.
util
.
List
;
import
com
.
github
.
pagehelper
.
PageInfo
;
import
com
.
item
.
util
.
AppPage
;
import
${
entityUrl
}.${
entityName
};
import
${
entityUrl
}.${
entityName
};
import
com
.
baomidou
.
mybatisplus
.
extension
.
service
.
IService
;
/**
/**
*
Copyright
:
Copyright
(
c
)
2019
*
*
*
@
Description
:
${
entityComment
}
——
SERVICE
*
<
p
>
说明:
${
entityComment
}
服务层
</
P
>
*
@
Author
:
${
author
}
*
@
version
:
${
version
}
*
@
CreateDate
:
${
createTime
}
*
@
author
:
${
author
}
*
@
Version
:
${
version
}
*
*
*
Modification
History
:
*
Date
Author
Version
Description
*---------------------------------------------------------------*
*
${
createTime
}
${
author
}
${
version
}
initialize
*/
*/
public
interface
${
entityName
}
Service
{
public
interface
${
entityName
}
Service
extends
IService
<${
entityName
}>
{
/**
*
@
explain
查询
${
entityComment
}
对象
*
@
param
对象参数:
id
*
@
return
${
entityName
}
*
@
author
${
author
}
*/
public
${
entityName
}
selectByPrimaryKey
(${
idType
}
id
);
/**
*
@
explain
删除
${
entityComment
}
对象
*
@
param
对象参数:
id
*
@
return
int
*
@
author
${
author
}
*/
public
int
deleteByPrimaryKey
(${
idType
}
id
);
/**
*
@
explain
添加
${
entityComment
}
对象
*
@
param
对象参数:
${
entityName
}
*
@
return
int
*
@
author
${
author
}
*/
public
int
insertSelective
(${
entityName
}
${
objectName
});
/**
*
@
explain
修改
${
entityComment
}
对象
*
@
param
对象参数:
${
entityName
}
*
@
return
int
*
@
author
${
author
}
*/
public
int
updateByPrimaryKeySelective
(${
entityName
}
${
objectName
});
/**
*
@
explain
查询
${
entityComment
}
集合
*
@
param
对象参数:
${
entityName
}
*
@
return
List
<${
entityName
}>
*
@
author
${
author
}
*/
public
List
<${
entityName
}>
query
${
entityName
}
List
(${
entityName
}
${
objectName
});
/**
*
@
explain
分页查询
${
entityComment
}
*
@
param
对象参数:
${
entityName
}
*
@
return
PageInfo
<${
entityName
}>
*
@
author
${
author
}
*/
public
PageInfo
<${
entityName
}>
get
${
entityName
}
BySearch
(
AppPage
<${
entityName
}>
page
);
}
}
\ No newline at end of file
src/main/resources/freemarker/ftl/serviceImpl.ftl
View file @
9214bf2c
...
@@ -6,69 +6,25 @@
...
@@ -6,69 +6,25 @@
*/
*/
package
${
serviceImplUrl
};
package
${
serviceImplUrl
};
import
java
.
util
.
List
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
stereotype
.
Service
;
import
com
.
github
.
pagehelper
.
PageHelper
;
import
com
.
github
.
pagehelper
.
PageInfo
;
import
com
.
item
.
util
.
AppPage
;
import
${
entityUrl
}.${
entityName
};
import
${
entityUrl
}.${
entityName
};
import
${
daoUrl
}.${
entityName
}
Dao
;
import
${
daoUrl
}.${
entityName
}
Dao
;
import
${
serviceUrl
}.${
entityName
}
Service
;
import
${
serviceUrl
}.${
entityName
}
Service
;
import
org
.
springframework
.
stereotype
.
Service
;
import
com
.
baomidou
.
mybatisplus
.
extension
.
service
.
impl
.
ServiceImpl
;
/**
/**
*
Copyright
:
Copyright
(
c
)
2019
*
*
*
@
Description
:
${
entityComment
}
——
SERVICEIMPL
*
<
p
>
说明:
${
entityComment
}
服务实现层
</
P
>
*
@
Author
:
${
author
}
*
@
version
:
${
version
}
*
@
CreateDate
:
${
createTime
}
*
@
author
:
${
author
}
*
@
Version
:
${
version
}
*
*
*
Modification
History
:
*
Date
Author
Version
Description
*---------------------------------------------------------------*
*
${
createTime
}
${
author
}
${
version
}
initialize
*/
*/
@
Service
@
Service
public
class
${
entityName
}
ServiceImpl
implements
${
entityName
}
Service
{
public
class
${
entityName
}
ServiceImpl
extends
ServiceImpl
<${
entityName
}
Dao
,
${
entityName
}>
implements
${
entityName
}
Service
{
@
Autowired
public
${
entityName
}
Dao
${
objectName
}
Dao
;
//
查询对象
@
Override
public
${
entityName
}
selectByPrimaryKey
(${
idType
}
id
)
{
return
${
objectName
}
Dao
.
selectByPrimaryKey
(
id
);
}
//
删除对象
@
Override
public
int
deleteByPrimaryKey
(${
idType
}
id
)
{
return
${
objectName
}
Dao
.
deleteByPrimaryKey
(
id
);
}
//
添加对象
@
Override
public
int
insertSelective
(${
entityName
}
${
objectName
})
{
return
${
objectName
}
Dao
.
insertSelective
(${
objectName
});
}
//
修改对象
@
Override
public
int
updateByPrimaryKeySelective
(${
entityName
}
${
objectName
})
{
return
${
objectName
}
Dao
.
updateByPrimaryKeySelective
(${
objectName
});
}
//
查询集合
@
Override
public
List
<${
entityName
}>
query
${
entityName
}
List
(${
entityName
}
${
objectName
})
{
return
${
objectName
}
Dao
.
query
${
entityName
}
List
(${
objectName
});
}
//
分页查询
@
Override
public
PageInfo
<${
entityName
}>
get
${
entityName
}
BySearch
(
AppPage
<${
entityName
}>
page
)
{
//
TODO
Auto
-
generated
method
stub
PageHelper
.
startPage
(
page
.
getPageNum
(),
page
.
getPageSize
());
List
<${
entityName
}>
list
=${
objectName
}
Dao
.
query
${
entityName
}
List
(
page
.
getParam
());
PageInfo
<${
entityName
}>
pageInfo
=
new
PageInfo
<${
entityName
}>(
list
);
return
pageInfo
;
}
}
}
\ 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