Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
fd9fb2a6
Commit
fd9fb2a6
authored
Nov 01, 2019
by
dqjdda
Browse files
Merge branch '2.3dev'
parents
7895e547
1839ef8d
Changes
227
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.
mapper.Entity
Mapper
;
import
me.zhengjie.
base.Base
Mapper
;
import
me.zhengjie.modules.system.domain.Dept
;
import
me.zhengjie.modules.system.service.dto.DeptDTO
;
import
org.mapstruct.Mapper
;
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-03-25
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DeptMapper
extends
Entity
Mapper
<
DeptDTO
,
Dept
>
{
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DeptMapper
extends
Base
Mapper
<
DeptDTO
,
Dept
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptSmallMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.
mapper.Entity
Mapper
;
import
me.zhengjie.
base.Base
Mapper
;
import
me.zhengjie.modules.system.domain.Dept
;
import
me.zhengjie.modules.system.service.dto.DeptSmallDTO
;
import
org.mapstruct.Mapper
;
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-03-25
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DeptSmallMapper
extends
Entity
Mapper
<
DeptSmallDTO
,
Dept
>
{
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DeptSmallMapper
extends
Base
Mapper
<
DeptSmallDTO
,
Dept
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictDetailMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.
mapper.Entity
Mapper
;
import
me.zhengjie.
base.Base
Mapper
;
import
me.zhengjie.modules.system.domain.DictDetail
;
import
me.zhengjie.modules.system.service.dto.DictDetailDTO
;
import
org.mapstruct.Mapper
;
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-04-10
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DictDetailMapper
extends
Entity
Mapper
<
DictDetailDTO
,
DictDetail
>
{
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DictDetailMapper
extends
Base
Mapper
<
DictDetailDTO
,
DictDetail
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.
mapper.Entity
Mapper
;
import
me.zhengjie.
base.Base
Mapper
;
import
me.zhengjie.modules.system.domain.Dict
;
import
me.zhengjie.modules.system.service.dto.DictDTO
;
import
org.mapstruct.Mapper
;
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-04-10
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DictMapper
extends
Entity
Mapper
<
DictDTO
,
Dict
>
{
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DictMapper
extends
Base
Mapper
<
DictDTO
,
Dict
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.
mapper.Entity
Mapper
;
import
me.zhengjie.
base.Base
Mapper
;
import
me.zhengjie.modules.system.domain.Job
;
import
me.zhengjie.modules.system.service.dto.JobDTO
;
import
org.mapstruct.Mapper
;
...
...
@@ -12,7 +12,7 @@ import org.mapstruct.ReportingPolicy;
* @date 2019-03-29
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
DeptMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
JobMapper
extends
Entity
Mapper
<
JobDTO
,
Job
>
{
public
interface
JobMapper
extends
Base
Mapper
<
JobDTO
,
Job
>
{
@Mapping
(
source
=
"deptSuperiorName"
,
target
=
"deptSuperiorName"
)
JobDTO
toDto
(
Job
job
,
String
deptSuperiorName
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobSmallMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.
mapper.Entity
Mapper
;
import
me.zhengjie.
base.Base
Mapper
;
import
me.zhengjie.modules.system.domain.Job
;
import
me.zhengjie.modules.system.service.dto.JobSmallDTO
;
import
org.mapstruct.Mapper
;
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-03-29
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
JobSmallMapper
extends
Entity
Mapper
<
JobSmallDTO
,
Job
>
{
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
JobSmallMapper
extends
Base
Mapper
<
JobSmallDTO
,
Job
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.modules.system.domain.Menu
;
import
me.zhengjie.mapper.EntityMapper
;
import
me.zhengjie.modules.system.service.dto.MenuDTO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2018-12-17
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
MenuMapper
extends
Entity
Mapper
<
MenuDTO
,
Menu
>
{
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
MenuMapper
extends
Base
Mapper
<
MenuDTO
,
Menu
>
{
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/PermissionMapper.java
deleted
100644 → 0
View file @
7895e547
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.modules.system.domain.Permission
;
import
me.zhengjie.mapper.EntityMapper
;
import
me.zhengjie.modules.system.service.dto.PermissionDTO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
/**
* @author Zheng Jie
* @date 2018-11-23
*/
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
PermissionMapper
extends
EntityMapper
<
PermissionDTO
,
Permission
>
{
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.mapper.EntityMapper
;
import
me.zhengjie.modules.system.service.dto.RoleDTO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2018-11-23
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
PermissionMapper
.
class
,
MenuMapper
.
class
,
DeptMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
RoleMapper
extends
Entity
Mapper
<
RoleDTO
,
Role
>
{
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
MenuMapper
.
class
,
DeptMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
RoleMapper
extends
Base
Mapper
<
RoleDTO
,
Role
>
{
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleSmallMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.
mapper.Entity
Mapper
;
import
me.zhengjie.
base.Base
Mapper
;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.modules.system.service.dto.RoleDTO
;
import
me.zhengjie.modules.system.service.dto.RoleSmallDTO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
...
...
@@ -11,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-5-23
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
RoleSmallMapper
extends
Entity
Mapper
<
RoleSmallDTO
,
Role
>
{
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
RoleSmallMapper
extends
Base
Mapper
<
RoleSmallDTO
,
Role
>
{
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/UserMapper.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.mapper
;
import
me.zhengjie.base.BaseMapper
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.mapper.EntityMapper
;
import
me.zhengjie.modules.system.service.dto.UserDTO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.Mapping
;
import
org.mapstruct.ReportingPolicy
;
import
java.util.List
;
/**
* @author Zheng Jie
* @date 2018-11-23
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
RoleMapper
.
class
,
DeptMapper
.
class
,
JobMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
UserMapper
extends
Entity
Mapper
<
UserDTO
,
User
>
{
public
interface
UserMapper
extends
Base
Mapper
<
UserDTO
,
User
>
{
@Mapping
(
source
=
"user.userAvatar.realName"
,
target
=
"avatar"
)
UserDTO
toDto
(
User
user
);
...
...
eladmin-system/src/main/resources/config/application-dev.yml
View file @
fd9fb2a6
...
...
@@ -45,13 +45,12 @@ spring:
jwt
:
header
:
Authorization
secret
:
mySecret
# token 过期时间 6个小时
expiration
:
21000000
auth
:
# 授权路径
path
:
/login
# 获取用户信息
account
:
/info
# token 过期时间/毫秒,6小时 1小时 = 3600000 毫秒
expiration
:
21600000
# 在线用户key
online
:
online-token
# 验证码
codeKey
:
code-key
#是否允许生成代码,生产环境设置为false
generator
:
...
...
eladmin-system/src/main/resources/config/application-prod.yml
View file @
fd9fb2a6
...
...
@@ -49,11 +49,10 @@ jwt:
secret
:
mySecret
# token 过期时间 2个小时
expiration
:
7200000
auth
:
# 授权路径
path
:
/login
# 获取用户信息
account
:
/info
# 在线用户key
online
:
online-token
# 验证码
codeKey
:
code-key
#是否允许生成代码,生产环境设置为false
generator
:
...
...
eladmin-system/src/main/resources/config/application.yml
View file @
fd9fb2a6
...
...
@@ -29,6 +29,17 @@ spring:
#连接超时时间
timeout
:
5000
task
:
pool
:
# 核心线程池大小
core-pool-size
:
10
# 最大线程数
max-pool-size
:
30
# 活跃时间
keep-alive-seconds
:
60
# 队列容量
queue-capacity
:
50
#七牛云
qiniu
:
# 文件大小 /M
...
...
eladmin-system/src/main/resources/template/generator/admin/Controller.ftl
View file @
fd9fb2a6
...
...
@@ -4,7 +4,6 @@ import me.zhengjie.aop.log.Log;
import
$
{
package
}
.domain.$
{
className
}
;
import
$
{
package
}
.service.$
{
className
}
Service;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
import
org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.domain.Pageable;
import
org.springframework.http.HttpStatus;
import
org.springframework.http.ResponseEntity;
...
...
@@ -12,6 +11,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import
org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.
*
;
import
io.swagger.annotations.
*
;
import
java.io.IOException;
import
javax.servlet.http.HttpServletResponse;
/**
*
@author $
{
author
}
...
...
@@ -19,41 +20,52 @@ import io.swagger.annotations.*;
*/
@
Api
(
tags
=
"$
{
className
}
管理")
@
RestController
@
RequestMapping
("
api
")
@
RequestMapping
("
/
api
/${
changeClassName
}
")
public
class $
{
className
}
Controller
{
@
A
utowired
private
$
{
className
}
S
ervice
$
{
changeClassName
}
S
ervice
;
private
final
$
{
className
}
S
ervice
$
{
changeClassName
}
S
ervice
;
public
$
{
className
}
C
ontroller
(
$
{
className
}
S
ervice
$
{
changeClassName
}
S
ervice
)
{
this
.$
{
changeClassName
}
S
ervice
=
$
{
changeClassName
}
S
ervice
;
}
@
L
og
(
"导出数据"
)
@
A
piOperation
(
"导出数据"
)
@
G
etMapping
(
value
=
"/download"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:list')"
)
public
void
download
(
H
ttpServletResponse
response
,
$
{
className
}
Q
ueryCriteria
criteria
)
throws
IOE
xception
{
$
{
changeClassName
}
S
ervice
.download
(
$
{
changeClassName
}
S
ervice
.queryAll
(
criteria
),
response
)
;
}
@
G
etMapping
@
L
og
(
"查询${className}"
)
@
A
piOperation
(
value
=
"查询${className}"
)
@
G
etMapping
(
value
=
"/${changeClassName}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_SELECT')"
)
@
A
piOperation
(
"查询${className}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:list')"
)
public
R
esponseEntity
get
$
{
className
}
s
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
return
new
R
esponseEntity
(
$
{
changeClassName
}
S
ervice
.queryAll
(
criteria
,
pageable
),
H
ttpStatus
.OK
)
;
return
new
R
esponseEntity
<>
(
$
{
changeClassName
}
S
ervice
.queryAll
(
criteria
,
pageable
),
H
ttpStatus
.OK
)
;
}
@
P
ostMapping
@
L
og
(
"新增${className}"
)
@
A
piOperation
(
value
=
"新增${className}"
)
@
P
ostMapping
(
value
=
"/${changeClassName}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_CREATE')"
)
@
A
piOperation
(
"新增${className}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:add')"
)
public
R
esponseEntity
create
(
@
V
alidated
@
R
equestBody
$
{
className
}
resources
){
return
new
R
esponseEntity
(
$
{
changeClassName
}
S
ervice
.create
(
resources
),
H
ttpStatus
.CREATED
)
;
return
new
R
esponseEntity
<>
(
$
{
changeClassName
}
S
ervice
.create
(
resources
),
H
ttpStatus
.CREATED
)
;
}
@
P
utMapping
@
L
og
(
"修改${className}"
)
@
A
piOperation
(
value
=
"修改${className}"
)
@
P
utMapping
(
value
=
"/${changeClassName}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT')"
)
@
A
piOperation
(
"修改${className}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:edit')"
)
public
R
esponseEntity
update
(
@
V
alidated
@
R
equestBody
$
{
className
}
resources
){
$
{
changeClassName
}
S
ervice
.update
(
resources
)
;
return
new
R
esponseEntity
(
H
ttpStatus
.NO_CONTENT
)
;
}
@
D
eleteMapping
(
value
=
"/{${pkChangeColName}}"
)
@
L
og
(
"删除${className}"
)
@
A
piOperation
(
value
=
"删除${className}"
)
@
D
eleteMapping
(
value
=
"/${changeClassName}/{${pkChangeColName}}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE')"
)
@
A
piOperation
(
"删除${className}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:del')"
)
public
R
esponseEntity
delete
(
@
P
athVariable
$
{
pkColumnType
}
$
{
pkChangeColName
}){
$
{
changeClassName
}
S
ervice
.delete
(
$
{
pkChangeColName
})
;
return
new
R
esponseEntity
(
H
ttpStatus
.OK
)
;
...
...
eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl
View file @
fd9fb2a6
package
$
{
package
}
.service.mapper;
import
me.zhengjie.
mapper.Entity
Mapper;
import
me.zhengjie.
base.Base
Mapper;
import
$
{
package
}
.domain.$
{
className
}
;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
org.mapstruct.Mapper;
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
*
@author $
{
author
}
*
@date $
{
date
}
*/
@
Mapper
(
componentModel
=
"spring",
uses =
{}
,
unmappedTargetPolicy = ReportingPolicy.IGNORE)
public
interface $
{
className
}
Mapper extends
Entity
Mapper<$
{
className
}
DTO, $
{
className
}
>
{
@
Mapper
(
componentModel
=
"spring",
unmappedTargetPolicy = ReportingPolicy.IGNORE)
public
interface $
{
className
}
Mapper extends
Base
Mapper<$
{
className
}
DTO, $
{
className
}
>
{
}
\ No newline at end of file
eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl
View file @
fd9fb2a6
package
$
{
package
}
.service.dto;
import
lombok.Data;
<#
if
h
asTimestamp>
<#
if
queryH
asTimestamp>
import
java.sql.Timestamp;
</#
if
>
<#
if
h
asBigDecimal>
<#
if
queryH
asBigDecimal>
import
java.math.BigDecimal;
</#
if
>
<#
if
queryColumns??>
...
...
eladmin-system/src/main/resources/template/generator/admin/Repository.ftl
View file @
fd9fb2a6
...
...
@@ -8,16 +8,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
*
@author $
{
author
}
*
@date $
{
date
}
*/
public
interface $
{
className
}
Repository extends JpaRepository<$
{
className
}
, $
{
pkColumnType
}
>, JpaSpecificationExecutor
{
public
interface $
{
className
}
Repository extends JpaRepository<$
{
className
}
, $
{
pkColumnType
}
>, JpaSpecificationExecutor
<$
{
className
}
>
{
<#
if
columns
??>
<#
list
columns
as
column
>
<#
if
column
.columnKey
=
'
UNI
'>
/
**
*
findBy
$
{
column
.capitalColumnName
}
*
@
param
$
{
column
.columnName
}
*
@
return
*
/
$
{
className
}
findBy
$
{
column
.capitalColumnName
}(
$
{
column
.columnType
}
$
{
column
.columnName
})
;
</#
if
>
</#
list
>
...
...
eladmin-system/src/main/resources/template/generator/admin/Service.ftl
View file @
fd9fb2a6
...
...
@@ -3,64 +3,45 @@ package ${package}.service;
import
$
{
package
}
.domain.$
{
className
}
;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
import
org.springframework.cache.annotation.CacheConfig;
import
org.springframework.cache.annotation.CacheEvict;
import
org.springframework.cache.annotation.Cacheable;
import
org.springframework.data.domain.Pageable;
import
java.util.Map;
import
java.util.List;
import
java.io.IOException;
import
javax.servlet.http.HttpServletResponse;
/**
*
@author $
{
author
}
*
@date $
{
date
}
*/
//@
CacheConfig
(
cacheNames
=
"$
{
changeClassName
}
")
public
interface $
{
className
}
Service
{
/
**
*
查询数据分页
*
@
param
criteria
*
@
param
pageable
*
@
return
*
@
param
criteria
条件参数
*
@
param
pageable
分页参数
*
@
return
M
ap
<
S
tring
,
O
bject
>
*
/
//@
C
acheable
M
ap
<
S
tring
,
O
bject
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
)
;
/
**
*
查询所有数据不分页
*
@
param
criteria
*
@
return
*
@
param
criteria
条件参数
*
@
return
L
ist
<$
{
className
}
DTO
>
*
/
//@
C
acheable
L
ist
<$
{
className
}
DTO
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
)
;
/
**
*
根据
ID
查询
*
@
param
$
{
pkChangeColName
}
*
@
return
*
@
param
$
{
pkChangeColName
}
ID
*
@
return
$
{
className
}
DTO
*
/
//@
C
acheable
(
key
=
"#p0"
)
$
{
className
}
DTO
findById
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
/
**
*
创建
*
@
param
resources
*
@
return
*
/
//@
C
acheEvict
(
allEntries
=
true
)
$
{
className
}
DTO
create
(
$
{
className
}
resources
)
;
/
**
*
编辑
*
@
param
resources
*
/
//@
C
acheEvict
(
allEntries
=
true
)
void
update
(
$
{
className
}
resources
)
;
/
**
*
删除
*
@
param
$
{
pkChangeColName
}
*
/
//@
C
acheEvict
(
allEntries
=
true
)
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
void
download
(
L
ist
<$
{
className
}
DTO
>
all
,
H
ttpServletResponse
response
)
throws
IOE
xception
;
}
\ No newline at end of file
eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl
View file @
fd9fb2a6
...
...
@@ -11,16 +11,15 @@ import me.zhengjie.exception.EntityExistException;
</#list>
</#
if
>
import
me.zhengjie.utils.ValidationUtil;
import
me.zhengjie.utils.FileUtil;
import
$
{
package
}
.repository.$
{
className
}
Repository;
import
$
{
package
}
.service.$
{
className
}
Service;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
import
$
{
package
}
.service.mapper.$
{
className
}
Mapper;
import
org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional;
import
java.util.Optional;
<#
if
!auto && pkColumnType = 'Long'>
import
cn.hutool.core.lang.Snowflake;
import
cn.hutool.core.util.IdUtil;
...
...
@@ -28,46 +27,61 @@ import cn.hutool.core.util.IdUtil;
<#
if
!auto && pkColumnType = 'String'>
import
cn.hutool.core.util.IdUtil;
</#
if
>
import
org.springframework.cache.annotation.CacheConfig;
import
org.springframework.cache.annotation.CacheEvict;
import
org.springframework.cache.annotation.Cacheable;
import
org.springframework.data.domain.Page;
import
org.springframework.data.domain.Pageable;
import
me.zhengjie.utils.PageUtil;
import
me.zhengjie.utils.QueryHelp;
import
java.util.List;
import
java.util.Map;
import
java.io.IOException;
import
javax.servlet.http.HttpServletResponse;
import
java.util.ArrayList;
import
java.util.LinkedHashMap;
/**
*
@author $
{
author
}
*
@date $
{
date
}
*/
@
Service
@
CacheConfig
(
cacheNames
=
"$
{
changeClassName
}
")
@
Transactional
(
propagation
=
Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public
class $
{
className
}
ServiceImpl implements $
{
className
}
Service
{
@
A
utowired
private
$
{
className
}
R
epository
$
{
changeClassName
}
R
epository
;
private
final
$
{
className
}
R
epository
$
{
changeClassName
}
R
epository
;
@
A
utowired
private
$
{
className
}
M
apper
$
{
changeClassName
}
M
apper
;
private
final
$
{
className
}
M
apper
$
{
changeClassName
}
M
apper
;
public
$
{
className
}
S
erviceImpl
(
$
{
className
}
R
epository
$
{
changeClassName
}
R
epository
,
$
{
className
}
M
apper
$
{
changeClassName
}
M
apper
)
{
this
.$
{
changeClassName
}
R
epository
=
$
{
changeClassName
}
R
epository
;
this
.$
{
changeClassName
}
M
apper
=
$
{
changeClassName
}
M
apper
;
}
@
O
verride
@
C
acheable
public
M
ap
<
S
tring
,
O
bject
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
P
age
<$
{
className
}
>
page
=
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
)
;
return
P
ageUtil
.toPage
(
page
.map
(
$
{
changeClassName
}
M
apper
::
toDto
))
;
}
@
O
verride
@
C
acheable
public
L
ist
<$
{
className
}
DTO
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
){
return
$
{
changeClassName
}
M
apper
.toDto
(
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
)))
;
}
@
O
verride
@
C
acheable
(
key
=
"#p0"
)
public
$
{
className
}
DTO
findById
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
{
O
ptional
<
$
{
className
}
>
$
{
changeClassName
}
=
$
{
changeClassName
}
R
epository
.findById
(
$
{
pkChangeColName
})
;
V
alidationUtil
.isNull
(
$
{
changeClassName
},
"${className}"
,
"${pkChangeColName}"
,
$
{
pkChangeColName
})
;
return
$
{
changeClassName
}
M
apper
.toDto
(
$
{
changeClassName
}
.get
()
)
;
$
{
className
}
$
{
changeClassName
}
=
$
{
changeClassName
}
R
epository
.findById
(
$
{
pkChangeColName
})
.orElseGet
(
$
{
className
}::
new
)
;
V
alidationUtil
.isNull
(
$
{
changeClassName
}
.get
$
{
pkCapitalColName
}()
,
"${className}"
,
"${pkChangeColName}"
,
$
{
pkChangeColName
})
;
return
$
{
changeClassName
}
M
apper
.toDto
(
$
{
changeClassName
})
;
}
@
O
verride
@
C
acheEvict
(
allEntries
=
true
)
@
T
ransactional
(
rollbackFor
=
E
xception
.class
)
public
$
{
className
}
DTO
create
(
$
{
className
}
resources
)
{
<#
if
!
auto
&&
pkColumnType
=
'
L
ong
'>
...
...
@@ -90,11 +104,11 @@ public class ${className}ServiceImpl implements ${className}Service {
}
@
O
verride
@
C
acheEvict
(
allEntries
=
true
)
@
T
ransactional
(
rollbackFor
=
E
xception
.class
)
public
void
update
(
$
{
className
}
resources
)
{
O
ptional
<$
{
className
}
>
optional
$
{
className
}
=
$
{
changeClassName
}
R
epository
.findById
(
resources
.get
$
{
pkCapitalColName
}())
;
V
alidationUtil
.isNull
(
optional
$
{
className
},
"${className}"
,
"id"
,
resources
.get
$
{
pkCapitalColName
}())
;
$
{
className
}
$
{
changeClassName
}
=
optional
$
{
className
}
.get
()
;
$
{
className
}
$
{
changeClassName
}
=
$
{
changeClassName
}
R
epository
.findById
(
resources
.get
$
{
pkCapitalColName
}())
.orElseGet
(
$
{
className
}::
new
)
;
V
alidationUtil
.isNull
(
$
{
changeClassName
}
.get
$
{
pkCapitalColName
}(),
"${className}"
,
"id"
,
resources
.get
$
{
pkCapitalColName
}())
;
<#
if
columns
??>
<#
list
columns
as
column
>
<#
if
column
.columnKey
=
'
UNI
'>
...
...
@@ -113,8 +127,29 @@ public class ${className}ServiceImpl implements ${className}Service {
}
@
O
verride
@
C
acheEvict
(
allEntries
=
true
)
@
T
ransactional
(
rollbackFor
=
E
xception
.class
)
public
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
{
$
{
changeClassName
}
R
epository
.deleteById
(
$
{
pkChangeColName
})
;
}
@
O
verride
public
void
download
(
L
ist
<$
{
className
}
DTO
>
all
,
H
ttpServletResponse
response
)
throws
IOE
xception
{
L
ist
<
M
ap
<
S
tring
,
O
bject
>>
list
=
new
A
rrayList
<>
()
;
for
(
$
{
className
}
DTO
$
{
changeClassName
}
:
all
)
{
M
ap
<
S
tring
,
O
bject
>
map
=
new
L
inkedHashMap
<>
()
;
<#
list
columns
as
column
>
<#
if
column
.columnKey
!=
'
PRI
'>
<#
if
column
.columnComment
!=
''>
map
.put
(
"${column.columnComment}"
,
$
{
changeClassName
}
.get
$
{
column
.capitalColumnName
}())
;
<#
else
>
map
.put
(
" ${column.changeColumnName}"
,
$
{
changeClassName
}
.get
$
{
column
.capitalColumnName
}())
;
</#
if
>
</#
if
>
</#
list
>
list
.add
(
map
)
;
}
F
ileUtil
.downloadExcel
(
list
,
response
)
;
}
}
\ No newline at end of file
Prev
1
…
5
6
7
8
9
10
11
12
Next
Write
Preview
Supports
Markdown
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