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
bf7c1eeb
"src/vscode:/vscode.git/clone" did not exist on "ee6887ac5af45ba18b610a102b655b4e0774afaf"
Commit
bf7c1eeb
authored
Oct 24, 2019
by
dqjdda
Browse files
代码优化完成,去除大量idea警告,代码生成器优化等
parent
e3c3ebb1
Changes
146
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java
View file @
bf7c1eeb
...
...
@@ -9,7 +9,9 @@ import me.zhengjie.modules.system.repository.DeptRepository;
import
me.zhengjie.modules.system.service.DeptService
;
import
me.zhengjie.modules.system.service.dto.DeptDTO
;
import
me.zhengjie.modules.system.service.mapper.DeptMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -22,28 +24,35 @@ import java.util.stream.Collectors;
* @date 2019-03-25
*/
@Service
@CacheConfig
(
cacheNames
=
"dept"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DeptServiceImpl
implements
DeptService
{
@Autowired
private
DeptRepository
deptRepository
;
private
final
DeptRepository
deptRepository
;
@Autowired
private
DeptMapper
deptMapper
;
private
final
DeptMapper
deptMapper
;
public
DeptServiceImpl
(
DeptRepository
deptRepository
,
DeptMapper
deptMapper
)
{
this
.
deptRepository
=
deptRepository
;
this
.
deptMapper
=
deptMapper
;
}
@Override
@Cacheable
public
List
<
DeptDTO
>
queryAll
(
DeptQueryCriteria
criteria
)
{
return
deptMapper
.
toDto
(
deptRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
)));
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
DeptDTO
findById
(
Long
id
)
{
Optional
<
Dept
>
dept
=
deptRepository
.
findById
(
id
);
ValidationUtil
.
isNull
(
dept
,
"Dept"
,
"id"
,
id
);
return
deptMapper
.
toDto
(
dept
.
get
()
);
Dept
dept
=
deptRepository
.
findById
(
id
)
.
orElseGet
(
Dept:
:
new
)
;
ValidationUtil
.
isNull
(
dept
.
getId
()
,
"Dept"
,
"id"
,
id
);
return
deptMapper
.
toDto
(
dept
);
}
@Override
@Cacheable
public
List
<
Dept
>
findByPid
(
long
pid
)
{
return
deptRepository
.
findByPid
(
pid
);
}
...
...
@@ -54,11 +63,12 @@ public class DeptServiceImpl implements DeptService {
}
@Override
@Cacheable
public
Object
buildTree
(
List
<
DeptDTO
>
deptDTOS
)
{
Set
<
DeptDTO
>
trees
=
new
LinkedHashSet
<>();
Set
<
DeptDTO
>
depts
=
new
LinkedHashSet
<>();
List
<
String
>
deptNames
=
deptDTOS
.
stream
().
map
(
DeptDTO:
:
getName
).
collect
(
Collectors
.
toList
());
B
oolean
isChild
;
b
oolean
isChild
;
for
(
DeptDTO
deptDTO
:
deptDTOS
)
{
isChild
=
false
;
if
(
"0"
.
equals
(
deptDTO
.
getPid
().
toString
()))
{
...
...
@@ -68,7 +78,7 @@ public class DeptServiceImpl implements DeptService {
if
(
it
.
getPid
().
equals
(
deptDTO
.
getId
()))
{
isChild
=
true
;
if
(
deptDTO
.
getChildren
()
==
null
)
{
deptDTO
.
setChildren
(
new
ArrayList
<
DeptDTO
>());
deptDTO
.
setChildren
(
new
ArrayList
<>());
}
deptDTO
.
getChildren
().
add
(
it
);
}
...
...
@@ -83,34 +93,36 @@ public class DeptServiceImpl implements DeptService {
trees
=
depts
;
}
Integer
totalElements
=
deptDTOS
!=
null
?
deptDTOS
.
size
()
:
0
;
Integer
totalElements
=
deptDTOS
.
size
();
Map
map
=
new
HashMap
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>
();
map
.
put
(
"totalElements"
,
totalElements
);
map
.
put
(
"content"
,
CollectionUtils
.
isEmpty
(
trees
)?
deptDTOS:
trees
);
return
map
;
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
DeptDTO
create
(
Dept
resources
)
{
return
deptMapper
.
toDto
(
deptRepository
.
save
(
resources
));
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
Dept
resources
)
{
if
(
resources
.
getId
().
equals
(
resources
.
getPid
()))
{
throw
new
BadRequestException
(
"上级不能为自己"
);
}
Optional
<
Dept
>
optionalDept
=
deptRepository
.
findById
(
resources
.
getId
());
ValidationUtil
.
isNull
(
optionalDept
,
"Dept"
,
"id"
,
resources
.
getId
());
Dept
dept
=
optionalDept
.
get
();
Dept
dept
=
deptRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
Dept:
:
new
);
ValidationUtil
.
isNull
(
dept
.
getId
(),
"Dept"
,
"id"
,
resources
.
getId
());
resources
.
setId
(
dept
.
getId
());
deptRepository
.
save
(
resources
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
deptRepository
.
deleteById
(
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java
View file @
bf7c1eeb
...
...
@@ -9,7 +9,9 @@ import me.zhengjie.modules.system.repository.DictDetailRepository;
import
me.zhengjie.modules.system.service.DictDetailService
;
import
me.zhengjie.modules.system.service.dto.DictDetailDTO
;
import
me.zhengjie.modules.system.service.mapper.DictDetailMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
org.springframework.stereotype.Service
;
...
...
@@ -24,45 +26,53 @@ import java.util.Optional;
* @date 2019-04-10
*/
@Service
@CacheConfig
(
cacheNames
=
"dictDetail"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DictDetailServiceImpl
implements
DictDetailService
{
@Autowired
private
DictDetailRepository
dictDetailRepository
;
private
final
DictDetailRepository
dictDetailRepository
;
@Autowired
private
DictDetailMapper
dictDetailMapper
;
private
final
DictDetailMapper
dictDetailMapper
;
public
DictDetailServiceImpl
(
DictDetailRepository
dictDetailRepository
,
DictDetailMapper
dictDetailMapper
)
{
this
.
dictDetailRepository
=
dictDetailRepository
;
this
.
dictDetailMapper
=
dictDetailMapper
;
}
@Override
@Cacheable
public
Map
queryAll
(
DictDetailQueryCriteria
criteria
,
Pageable
pageable
)
{
Page
<
DictDetail
>
page
=
dictDetailRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
);
return
PageUtil
.
toPage
(
page
.
map
(
dictDetailMapper:
:
toDto
));
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
DictDetailDTO
findById
(
Long
id
)
{
Optional
<
DictDetail
>
dictDetail
=
dictDetailRepository
.
findById
(
id
);
ValidationUtil
.
isNull
(
dictDetail
,
"DictDetail"
,
"id"
,
id
);
return
dictDetailMapper
.
toDto
(
dictDetail
.
get
()
);
DictDetail
dictDetail
=
dictDetailRepository
.
findById
(
id
)
.
orElseGet
(
DictDetail:
:
new
)
;
ValidationUtil
.
isNull
(
dictDetail
.
getId
()
,
"DictDetail"
,
"id"
,
id
);
return
dictDetailMapper
.
toDto
(
dictDetail
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
DictDetailDTO
create
(
DictDetail
resources
)
{
return
dictDetailMapper
.
toDto
(
dictDetailRepository
.
save
(
resources
));
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
DictDetail
resources
)
{
Optional
<
DictDetail
>
optionalDictDetail
=
dictDetailRepository
.
findById
(
resources
.
getId
());
ValidationUtil
.
isNull
(
optionalDictDetail
,
"DictDetail"
,
"id"
,
resources
.
getId
());
DictDetail
dictDetail
=
optionalDictDetail
.
get
();
DictDetail
dictDetail
=
dictDetailRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
DictDetail:
:
new
);
ValidationUtil
.
isNull
(
dictDetail
.
getId
(),
"DictDetail"
,
"id"
,
resources
.
getId
());
resources
.
setId
(
dictDetail
.
getId
());
dictDetailRepository
.
save
(
resources
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
dictDetailRepository
.
deleteById
(
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java
View file @
bf7c1eeb
...
...
@@ -9,58 +9,67 @@ import me.zhengjie.modules.system.repository.DictRepository;
import
me.zhengjie.modules.system.service.DictService
;
import
me.zhengjie.modules.system.service.dto.DictDTO
;
import
me.zhengjie.modules.system.service.mapper.DictMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Optional
;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Service
@CacheConfig
(
cacheNames
=
"dict"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
DictServiceImpl
implements
DictService
{
@Autowired
private
DictRepository
dictRepository
;
private
final
DictRepository
dictRepository
;
@Autowired
private
DictMapper
dictMapper
;
private
final
DictMapper
dictMapper
;
public
DictServiceImpl
(
DictRepository
dictRepository
,
DictMapper
dictMapper
)
{
this
.
dictRepository
=
dictRepository
;
this
.
dictMapper
=
dictMapper
;
}
@Override
@Cacheable
public
Object
queryAll
(
DictQueryCriteria
dict
,
Pageable
pageable
){
Page
<
Dict
>
page
=
dictRepository
.
findAll
((
root
,
query
,
cb
)
->
QueryHelp
.
getPredicate
(
root
,
dict
,
cb
),
pageable
);
return
PageUtil
.
toPage
(
page
.
map
(
dictMapper:
:
toDto
));
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
DictDTO
findById
(
Long
id
)
{
Optional
<
Dict
>
dict
=
dictRepository
.
findById
(
id
);
ValidationUtil
.
isNull
(
dict
,
"Dict"
,
"id"
,
id
);
return
dictMapper
.
toDto
(
dict
.
get
()
);
Dict
dict
=
dictRepository
.
findById
(
id
)
.
orElseGet
(
Dict:
:
new
)
;
ValidationUtil
.
isNull
(
dict
.
getId
()
,
"Dict"
,
"id"
,
id
);
return
dictMapper
.
toDto
(
dict
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
DictDTO
create
(
Dict
resources
)
{
return
dictMapper
.
toDto
(
dictRepository
.
save
(
resources
));
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
Dict
resources
)
{
Optional
<
Dict
>
optionalDict
=
dictRepository
.
findById
(
resources
.
getId
());
ValidationUtil
.
isNull
(
optionalDict
,
"Dict"
,
"id"
,
resources
.
getId
());
Dict
dict
=
optionalDict
.
get
();
Dict
dict
=
dictRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
Dict:
:
new
);
ValidationUtil
.
isNull
(
dict
.
getId
(),
"Dict"
,
"id"
,
resources
.
getId
());
resources
.
setId
(
dict
.
getId
());
dictRepository
.
save
(
resources
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
dictRepository
.
deleteById
(
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/JobServiceImpl.java
View file @
bf7c1eeb
...
...
@@ -10,7 +10,9 @@ import me.zhengjie.modules.system.repository.JobRepository;
import
me.zhengjie.modules.system.service.JobService
;
import
me.zhengjie.modules.system.service.dto.JobDTO
;
import
me.zhengjie.modules.system.service.mapper.JobMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
org.springframework.stereotype.Service
;
...
...
@@ -18,24 +20,27 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
/**
* @author Zheng Jie
* @date 2019-03-29
*/
@Service
@CacheConfig
(
cacheNames
=
"job"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
JobServiceImpl
implements
JobService
{
@Autowired
private
JobRepository
jobRepository
;
private
final
JobRepository
jobRepository
;
@Autowired
private
JobMapper
jobMapper
;
private
final
JobMapper
jobMapper
;
@Autowired
private
DeptRepository
deptRepository
;
private
final
DeptRepository
deptRepository
;
public
JobServiceImpl
(
JobRepository
jobRepository
,
JobMapper
jobMapper
,
DeptRepository
deptRepository
)
{
this
.
jobRepository
=
jobRepository
;
this
.
jobMapper
=
jobMapper
;
this
.
deptRepository
=
deptRepository
;
}
@Override
public
Object
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
)
{
...
...
@@ -48,30 +53,32 @@ public class JobServiceImpl implements JobService {
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
JobDTO
findById
(
Long
id
)
{
Optional
<
Job
>
job
=
jobRepository
.
findById
(
id
);
ValidationUtil
.
isNull
(
job
,
"Job"
,
"id"
,
id
);
return
jobMapper
.
toDto
(
job
.
get
()
);
Job
job
=
jobRepository
.
findById
(
id
)
.
orElseGet
(
Job:
:
new
)
;
ValidationUtil
.
isNull
(
job
.
getId
()
,
"Job"
,
"id"
,
id
);
return
jobMapper
.
toDto
(
job
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
JobDTO
create
(
Job
resources
)
{
return
jobMapper
.
toDto
(
jobRepository
.
save
(
resources
));
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
Job
resources
)
{
Optional
<
Job
>
optionalJob
=
jobRepository
.
findById
(
resources
.
getId
());
ValidationUtil
.
isNull
(
optionalJob
,
"Job"
,
"id"
,
resources
.
getId
());
Job
job
=
optionalJob
.
get
();
Job
job
=
jobRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
Job:
:
new
);
ValidationUtil
.
isNull
(
job
.
getId
(),
"Job"
,
"id"
,
resources
.
getId
());
resources
.
setId
(
job
.
getId
());
jobRepository
.
save
(
resources
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
jobRepository
.
deleteById
(
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java
View file @
bf7c1eeb
package
me.zhengjie.modules.system.service.impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.core.util.StrUtil
;
import
me.zhengjie.modules.system.domain.Menu
;
import
me.zhengjie.modules.system.domain.vo.MenuMetaVo
;
...
...
@@ -18,7 +17,9 @@ import me.zhengjie.modules.system.service.mapper.MenuMapper;
import
me.zhengjie.utils.QueryHelp
;
import
me.zhengjie.utils.StringUtils
;
import
me.zhengjie.utils.ValidationUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -26,41 +27,48 @@ import java.util.*;
import
java.util.stream.Collectors
;
@Service
@CacheConfig
(
cacheNames
=
"menu"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
MenuServiceImpl
implements
MenuService
{
@Autowired
private
MenuRepository
menuRepository
;
private
final
MenuRepository
menuRepository
;
@Autowired
private
MenuMapper
menuMapper
;
private
final
MenuMapper
menuMapper
;
@Autowired
private
RoleService
roleService
;
private
final
RoleService
roleService
;
public
MenuServiceImpl
(
MenuRepository
menuRepository
,
MenuMapper
menuMapper
,
RoleService
roleService
)
{
this
.
menuRepository
=
menuRepository
;
this
.
menuMapper
=
menuMapper
;
this
.
roleService
=
roleService
;
}
@Override
public
List
queryAll
(
MenuQueryCriteria
criteria
){
@Cacheable
public
List
<
MenuDTO
>
queryAll
(
MenuQueryCriteria
criteria
){
return
menuMapper
.
toDto
(
menuRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
)));
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
MenuDTO
findById
(
long
id
)
{
Optional
<
Menu
>
menu
=
menuRepository
.
findById
(
id
);
ValidationUtil
.
isNull
(
menu
,
"Menu"
,
"id"
,
id
);
return
menuMapper
.
toDto
(
menu
.
get
()
);
Menu
menu
=
menuRepository
.
findById
(
id
)
.
orElseGet
(
Menu:
:
new
)
;
ValidationUtil
.
isNull
(
menu
.
getId
()
,
"Menu"
,
"id"
,
id
);
return
menuMapper
.
toDto
(
menu
);
}
@Override
public
List
<
MenuDTO
>
findByRoles
(
List
<
RoleSmallDTO
>
roles
)
{
Set
<
Menu
>
menus
=
new
LinkedHashSet
<>();
for
(
RoleSmallDTO
role
:
roles
)
{
List
<
Menu
>
menus1
=
menuRepository
.
findByRoles_IdOrderBySortAsc
(
role
.
getId
())
.
stream
().
collect
(
Collectors
.
toList
()
);
List
<
Menu
>
menus1
=
new
ArrayList
<>(
menuRepository
.
findByRoles_IdOrderBySortAsc
(
role
.
getId
()));
menus
.
addAll
(
menus1
);
}
return
menus
.
stream
().
map
(
menuMapper:
:
toDto
).
collect
(
Collectors
.
toList
());
}
@Override
@CacheEvict
(
allEntries
=
true
)
public
MenuDTO
create
(
Menu
resources
)
{
if
(
menuRepository
.
findByName
(
resources
.
getName
())
!=
null
){
throw
new
EntityExistException
(
Menu
.
class
,
"name"
,
resources
.
getName
());
...
...
@@ -79,19 +87,19 @@ public class MenuServiceImpl implements MenuService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
public
void
update
(
Menu
resources
)
{
if
(
resources
.
getId
().
equals
(
resources
.
getPid
()))
{
throw
new
BadRequestException
(
"上级不能为自己"
);
}
Optional
<
Menu
>
optionalPermission
=
menuRepository
.
findById
(
resources
.
getId
());
ValidationUtil
.
isNull
(
optionalPermission
,
"Permission"
,
"id"
,
resources
.
getId
());
Menu
menu
=
menuRepository
.
findById
(
resources
.
getId
())
.
orElseGet
(
Menu:
:
new
)
;
ValidationUtil
.
isNull
(
menu
.
getId
()
,
"Permission"
,
"id"
,
resources
.
getId
());
if
(
resources
.
getIFrame
()){
if
(!(
resources
.
getPath
().
toLowerCase
().
startsWith
(
"http://"
)||
resources
.
getPath
().
toLowerCase
().
startsWith
(
"https://"
)))
{
throw
new
BadRequestException
(
"外链必须以http://或者https://开头"
);
}
}
Menu
menu
=
optionalPermission
.
get
();
Menu
menu1
=
menuRepository
.
findByName
(
resources
.
getName
());
if
(
menu1
!=
null
&&
!
menu1
.
getId
().
equals
(
menu
.
getId
())){
...
...
@@ -131,6 +139,7 @@ public class MenuServiceImpl implements MenuService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Set
<
Menu
>
menuSet
)
{
for
(
Menu
menu
:
menuSet
)
{
...
...
@@ -140,6 +149,7 @@ public class MenuServiceImpl implements MenuService {
}
@Override
@Cacheable
(
key
=
"'tree'"
)
public
Object
getMenuTree
(
List
<
Menu
>
menus
)
{
List
<
Map
<
String
,
Object
>>
list
=
new
LinkedList
<>();
menus
.
forEach
(
menu
->
{
...
...
@@ -159,13 +169,14 @@ public class MenuServiceImpl implements MenuService {
}
@Override
@Cacheable
(
key
=
"'pid:'+#p0"
)
public
List
<
Menu
>
findByPid
(
long
pid
)
{
return
menuRepository
.
findByPid
(
pid
);
}
@Override
public
Map
buildTree
(
List
<
MenuDTO
>
menuDTOS
)
{
List
<
MenuDTO
>
trees
=
new
ArrayList
<
MenuDTO
>();
public
Map
<
String
,
Object
>
buildTree
(
List
<
MenuDTO
>
menuDTOS
)
{
List
<
MenuDTO
>
trees
=
new
ArrayList
<>();
Set
<
Long
>
ids
=
new
HashSet
<>();
for
(
MenuDTO
menuDTO
:
menuDTOS
)
{
if
(
menuDTO
.
getPid
()
==
0
)
{
...
...
@@ -174,19 +185,19 @@ public class MenuServiceImpl implements MenuService {
for
(
MenuDTO
it
:
menuDTOS
)
{
if
(
it
.
getPid
().
equals
(
menuDTO
.
getId
()))
{
if
(
menuDTO
.
getChildren
()
==
null
)
{
menuDTO
.
setChildren
(
new
ArrayList
<
MenuDTO
>());
menuDTO
.
setChildren
(
new
ArrayList
<>());
}
menuDTO
.
getChildren
().
add
(
it
);
ids
.
add
(
it
.
getId
());
}
}
}
Map
map
=
new
HashMap
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>
();
if
(
trees
.
size
()
==
0
){
trees
=
menuDTOS
.
stream
().
filter
(
s
->
!
ids
.
contains
(
s
.
getId
())).
collect
(
Collectors
.
toList
());
}
map
.
put
(
"content"
,
trees
);
map
.
put
(
"totalElements"
,
menuDTOS
!=
null
?
menuDTOS
.
size
()
:
0
);
map
.
put
(
"totalElements"
,
menuDTOS
.
size
());
return
map
;
}
...
...
@@ -229,7 +240,7 @@ public class MenuServiceImpl implements MenuService {
menuVo
.
setName
(
null
);
menuVo
.
setMeta
(
null
);
menuVo
.
setComponent
(
"Layout"
);
List
<
MenuVo
>
list1
=
new
ArrayList
<
MenuVo
>();
List
<
MenuVo
>
list1
=
new
ArrayList
<>();
list1
.
add
(
menuVo1
);
menuVo
.
setChildren
(
list1
);
}
...
...
@@ -242,8 +253,8 @@ public class MenuServiceImpl implements MenuService {
@Override
public
Menu
findOne
(
Long
id
)
{
Optional
<
Menu
>
menu
=
menuRepository
.
findById
(
id
);
ValidationUtil
.
isNull
(
menu
,
"Menu"
,
"id"
,
id
);
return
menu
.
get
()
;
Menu
menu
=
menuRepository
.
findById
(
id
)
.
orElseGet
(
Menu:
:
new
)
;
ValidationUtil
.
isNull
(
menu
.
getId
()
,
"Menu"
,
"id"
,
id
);
return
menu
;
}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/PermissionServiceImpl.java
View file @
bf7c1eeb
...
...
@@ -11,7 +11,9 @@ import me.zhengjie.modules.system.service.dto.PermissionQueryCriteria;
import
me.zhengjie.modules.system.service.mapper.PermissionMapper
;
import
me.zhengjie.utils.QueryHelp
;
import
me.zhengjie.utils.ValidationUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -22,31 +24,38 @@ import java.util.*;
* @date 2018-12-03
*/
@Service
@CacheConfig
(
cacheNames
=
"permission"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
PermissionServiceImpl
implements
PermissionService
{
@Autowired
private
PermissionRepository
permissionRepository
;
private
final
PermissionRepository
permissionRepository
;
@Autowired
private
PermissionMapper
permissionMapper
;
private
final
PermissionMapper
permissionMapper
;
@Autowired
private
RoleService
roleService
;
private
final
RoleService
roleService
;
public
PermissionServiceImpl
(
PermissionRepository
permissionRepository
,
PermissionMapper
permissionMapper
,
RoleService
roleService
)
{
this
.
permissionRepository
=
permissionRepository
;
this
.
permissionMapper
=
permissionMapper
;
this
.
roleService
=
roleService
;
}
@Override
@Cacheable
public
List
<
PermissionDTO
>
queryAll
(
PermissionQueryCriteria
criteria
)
{
return
permissionMapper
.
toDto
(
permissionRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
)));
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
PermissionDTO
findById
(
long
id
)
{
Optional
<
Permission
>
permission
=
permissionRepository
.
findById
(
id
);
ValidationUtil
.
isNull
(
permission
,
"Permission"
,
"id"
,
id
);
return
permissionMapper
.
toDto
(
permission
.
get
()
);
Permission
permission
=
permissionRepository
.
findById
(
id
)
.
orElseGet
(
Permission:
:
new
)
;
ValidationUtil
.
isNull
(
permission
.
getId
()
,
"Permission"
,
"id"
,
id
);
return
permissionMapper
.
toDto
(
permission
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
PermissionDTO
create
(
Permission
resources
)
{
if
(
permissionRepository
.
findByName
(
resources
.
getName
())
!=
null
){
...
...
@@ -56,15 +65,14 @@ public class PermissionServiceImpl implements PermissionService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
Permission
resources
)
{
Optional
<
Permission
>
optionalP
ermission
=
permissionRepository
.
findById
(
resources
.
getId
());
Permission
p
ermission
=
permissionRepository
.
findById
(
resources
.
getId
())
.
orElseGet
(
Permission:
:
new
)
;
if
(
resources
.
getId
().
equals
(
resources
.
getPid
()))
{
throw
new
BadRequestException
(
"上级不能为自己"
);
}
ValidationUtil
.
isNull
(
optionalPermission
,
"Permission"
,
"id"
,
resources
.
getId
());
Permission
permission
=
optionalPermission
.
get
();
ValidationUtil
.
isNull
(
permission
.
getId
(),
"Permission"
,
"id"
,
resources
.
getId
());
Permission
permission1
=
permissionRepository
.
findByName
(
resources
.
getName
());
...
...
@@ -92,6 +100,7 @@ public class PermissionServiceImpl implements PermissionService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Set
<
Permission
>
permissions
)
{
for
(
Permission
permission
:
permissions
)
{
...
...
@@ -101,6 +110,7 @@ public class PermissionServiceImpl implements PermissionService {
}
@Override
@Cacheable
(
key
=
"'tree'"
)
public
Object
getPermissionTree
(
List
<
Permission
>
permissions
)
{
List
<
Map
<
String
,
Object
>>
list
=
new
LinkedList
<>();
permissions
.
forEach
(
permission
->
{
...
...
@@ -120,14 +130,16 @@ public class PermissionServiceImpl implements PermissionService {
}
@Override
@Cacheable
(
key
=
"'pid:'+#p0"
)
public
List
<
Permission
>
findByPid
(
long
pid
)
{
return
permissionRepository
.
findByPid
(
pid
);
}
@Override
@Cacheable
public
Object
buildTree
(
List
<
PermissionDTO
>
permissionDTOS
)
{
List
<
PermissionDTO
>
trees
=
new
ArrayList
<
PermissionDTO
>();
List
<
PermissionDTO
>
trees
=
new
ArrayList
<>();
for
(
PermissionDTO
permissionDTO
:
permissionDTOS
)
{
...
...
@@ -138,16 +150,16 @@ public class PermissionServiceImpl implements PermissionService {
for
(
PermissionDTO
it
:
permissionDTOS
)
{
if
(
it
.
getPid
().
equals
(
permissionDTO
.
getId
()))
{
if
(
permissionDTO
.
getChildren
()
==
null
)
{
permissionDTO
.
setChildren
(
new
ArrayList
<
PermissionDTO
>());
permissionDTO
.
setChildren
(
new
ArrayList
<>());
}
permissionDTO
.
getChildren
().
add
(
it
);
}
}
}
Integer
totalElements
=
permissionDTOS
!=
null
?
permissionDTOS
.
size
()
:
0
;
Integer
totalElements
=
permissionDTOS
.
size
();
Map
map
=
new
HashMap
();
Map
<
String
,
Object
>
map
=
new
HashMap
<>
();
map
.
put
(
"content"
,
trees
.
size
()
==
0
?
permissionDTOS:
trees
);
map
.
put
(
"totalElements"
,
totalElements
);
return
map
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java
View file @
bf7c1eeb
...
...
@@ -12,7 +12,9 @@ import me.zhengjie.modules.system.service.mapper.RoleSmallMapper;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.QueryHelp
;
import
me.zhengjie.utils.ValidationUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
org.springframework.stereotype.Service
;
...
...
@@ -26,42 +28,51 @@ import java.util.stream.Collectors;
* @date 2018-12-03
*/
@Service
@CacheConfig
(
cacheNames
=
"role"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
RoleServiceImpl
implements
RoleService
{
@Autowired
private
RoleRepository
roleRepository
;
private
final
RoleRepository
roleRepository
;
@Autowired
private
RoleMapper
roleMapper
;
private
final
RoleMapper
roleMapper
;
@Autowired
private
RoleSmallMapper
roleSmallMapper
;
private
final
RoleSmallMapper
roleSmallMapper
;
public
RoleServiceImpl
(
RoleRepository
roleRepository
,
RoleMapper
roleMapper
,
RoleSmallMapper
roleSmallMapper
)
{
this
.
roleRepository
=
roleRepository
;
this
.
roleMapper
=
roleMapper
;
this
.
roleSmallMapper
=
roleSmallMapper
;
}
@Override
@Cacheable
public
Object
queryAll
(
Pageable
pageable
)
{
return
roleMapper
.
toDto
(
roleRepository
.
findAll
(
pageable
).
getContent
());
}
@Override
@Cacheable
public
List
<
RoleDTO
>
queryAll
(
RoleQueryCriteria
criteria
)
{
return
roleMapper
.
toDto
(
roleRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
)));
}
@Override
@Cacheable
public
Object
queryAll
(
RoleQueryCriteria
criteria
,
Pageable
pageable
)
{
Page
<
Role
>
page
=
roleRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
);
return
PageUtil
.
toPage
(
page
.
map
(
roleMapper:
:
toDto
));
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
RoleDTO
findById
(
long
id
)
{
Optional
<
Role
>
role
=
roleRepository
.
findById
(
id
);
ValidationUtil
.
isNull
(
role
,
"Role"
,
"id"
,
id
);
return
roleMapper
.
toDto
(
role
.
get
()
);
Role
role
=
roleRepository
.
findById
(
id
)
.
orElseGet
(
Role:
:
new
)
;
ValidationUtil
.
isNull
(
role
.
getId
()
,
"Role"
,
"id"
,
id
);
return
roleMapper
.
toDto
(
role
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
RoleDTO
create
(
Role
resources
)
{
if
(
roleRepository
.
findByName
(
resources
.
getName
())
!=
null
){
...
...
@@ -71,13 +82,11 @@ public class RoleServiceImpl implements RoleService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
Role
resources
)
{
Optional
<
Role
>
optionalRole
=
roleRepository
.
findById
(
resources
.
getId
());
ValidationUtil
.
isNull
(
optionalRole
,
"Role"
,
"id"
,
resources
.
getId
());
Role
role
=
optionalRole
.
get
();
Role
role
=
roleRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
Role:
:
new
);
ValidationUtil
.
isNull
(
role
.
getId
(),
"Role"
,
"id"
,
resources
.
getId
());
Role
role1
=
roleRepository
.
findByName
(
resources
.
getName
());
...
...
@@ -94,6 +103,7 @@ public class RoleServiceImpl implements RoleService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
public
void
updatePermission
(
Role
resources
,
RoleDTO
roleDTO
)
{
Role
role
=
roleMapper
.
toEntity
(
roleDTO
);
role
.
setPermissions
(
resources
.
getPermissions
());
...
...
@@ -101,6 +111,7 @@ public class RoleServiceImpl implements RoleService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
public
void
updateMenu
(
Role
resources
,
RoleDTO
roleDTO
)
{
Role
role
=
roleMapper
.
toEntity
(
roleDTO
);
role
.
setMenus
(
resources
.
getMenus
());
...
...
@@ -108,29 +119,34 @@ public class RoleServiceImpl implements RoleService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
untiedMenu
(
Long
id
)
{
roleRepository
.
untiedMenu
(
id
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
untiedPermission
(
Long
id
)
{
roleRepository
.
untiedPermission
(
id
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
roleRepository
.
deleteById
(
id
);
}
@Override
@Cacheable
(
key
=
"'findByUsers_Id:' + #p0"
)
public
List
<
RoleSmallDTO
>
findByUsers_Id
(
Long
id
)
{
return
roleSmallMapper
.
toDto
(
roleRepository
.
findByUsers_Id
(
id
)
.
stream
().
collect
(
Collectors
.
toList
()
));
return
roleSmallMapper
.
toDto
(
new
ArrayList
<>(
roleRepository
.
findByUsers_Id
(
id
)));
}
@Override
@Cacheable
public
Integer
findByRoles
(
Set
<
Role
>
roles
)
{
Set
<
RoleDTO
>
roleDTOS
=
new
HashSet
<>();
for
(
Role
role
:
roles
)
{
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
View file @
bf7c1eeb
package
me.zhengjie.modules.system.service.impl
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.poi.excel.ExcelUtil
;
import
cn.hutool.poi.excel.ExcelWriter
;
import
me.zhengjie.modules.monitor.service.RedisService
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.exception.EntityExistException
;
...
...
@@ -16,16 +13,16 @@ import me.zhengjie.modules.system.service.dto.UserDTO;
import
me.zhengjie.modules.system.service.dto.UserQueryCriteria
;
import
me.zhengjie.modules.system.service.mapper.UserMapper
;
import
me.zhengjie.utils.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
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
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.File
;
import
java.io.IOException
;
...
...
@@ -37,44 +34,52 @@ import java.util.stream.Collectors;
* @date 2018-11-23
*/
@Service
@CacheConfig
(
cacheNames
=
"user"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
UserServiceImpl
implements
UserService
{
@Autowired
private
UserRepository
userRepository
;
private
final
UserRepository
userRepository
;
@Autowired
private
UserMapper
userMapper
;
private
final
UserMapper
userMapper
;
@Autowired
private
RedisService
redisService
;
private
final
RedisService
redisService
;
@Autowired
private
UserAvatarRepository
userAvatarRepository
;
private
final
UserAvatarRepository
userAvatarRepository
;
@Value
(
"${file.avatar}"
)
private
String
avatar
;
public
UserServiceImpl
(
UserRepository
userRepository
,
UserMapper
userMapper
,
RedisService
redisService
,
UserAvatarRepository
userAvatarRepository
)
{
this
.
userRepository
=
userRepository
;
this
.
userMapper
=
userMapper
;
this
.
redisService
=
redisService
;
this
.
userAvatarRepository
=
userAvatarRepository
;
}
@Override
@Cacheable
public
Object
queryAll
(
UserQueryCriteria
criteria
,
Pageable
pageable
)
{
Page
<
User
>
page
=
userRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
);
return
PageUtil
.
toPage
(
page
.
map
(
userMapper:
:
toDto
));
}
@Override
@Cacheable
public
List
<
UserDTO
>
queryAll
(
UserQueryCriteria
criteria
)
{
List
<
User
>
users
=
userRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
));
return
userMapper
.
toDto
(
users
);
}
@Override
@Cacheable
(
key
=
"#p0"
)
public
UserDTO
findById
(
long
id
)
{
Optional
<
User
>
user
=
userRepository
.
findById
(
id
);
ValidationUtil
.
isNull
(
user
,
"User"
,
"id"
,
id
);
return
userMapper
.
toDto
(
user
.
get
()
);
User
user
=
userRepository
.
findById
(
id
)
.
orElseGet
(
User:
:
new
)
;
ValidationUtil
.
isNull
(
user
.
getId
()
,
"User"
,
"id"
,
id
);
return
userMapper
.
toDto
(
user
);
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
UserDTO
create
(
User
resources
)
{
...
...
@@ -92,13 +97,11 @@ public class UserServiceImpl implements UserService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
update
(
User
resources
)
{
Optional
<
User
>
userOptional
=
userRepository
.
findById
(
resources
.
getId
());
ValidationUtil
.
isNull
(
userOptional
,
"User"
,
"id"
,
resources
.
getId
());
User
user
=
userOptional
.
get
();
User
user
=
userRepository
.
findById
(
resources
.
getId
()).
orElseGet
(
User:
:
new
);
ValidationUtil
.
isNull
(
user
.
getId
(),
"User"
,
"id"
,
resources
.
getId
());
User
user1
=
userRepository
.
findByUsername
(
user
.
getUsername
());
User
user2
=
userRepository
.
findByEmail
(
user
.
getEmail
());
...
...
@@ -129,14 +132,16 @@ public class UserServiceImpl implements UserService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Long
id
)
{
userRepository
.
deleteById
(
id
);
}
@Override
@Cacheable
(
key
=
"'loadUserByUsername:'+#p0"
)
public
UserDTO
findByName
(
String
userName
)
{
User
user
=
null
;
User
user
;
if
(
ValidationUtil
.
isEmail
(
userName
)){
user
=
userRepository
.
findByEmail
(
userName
);
}
else
{
...
...
@@ -150,12 +155,14 @@ public class UserServiceImpl implements UserService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updatePass
(
String
username
,
String
pass
)
{
userRepository
.
updatePass
(
username
,
pass
,
new
Date
());
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateAvatar
(
MultipartFile
multipartFile
)
{
User
user
=
userRepository
.
findByUsername
(
SecurityUtils
.
getUsername
());
...
...
@@ -165,6 +172,7 @@ public class UserServiceImpl implements UserService {
oldPath
=
userAvatar
.
getPath
();
}
File
file
=
FileUtil
.
upload
(
multipartFile
,
avatar
);
assert
file
!=
null
;
userAvatar
=
userAvatarRepository
.
save
(
new
UserAvatar
(
userAvatar
,
file
.
getName
(),
file
.
getPath
(),
FileUtil
.
getSize
(
multipartFile
.
getSize
())));
user
.
setUserAvatar
(
userAvatar
);
userRepository
.
save
(
user
);
...
...
@@ -174,6 +182,7 @@ public class UserServiceImpl implements UserService {
}
@Override
@CacheEvict
(
allEntries
=
true
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateEmail
(
String
username
,
String
email
)
{
userRepository
.
updateEmail
(
username
,
email
);
...
...
@@ -184,7 +193,7 @@ public class UserServiceImpl implements UserService {
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
UserDTO
userDTO
:
queryAll
)
{
List
roles
=
userDTO
.
getRoles
().
stream
().
map
(
RoleSmallDTO:
:
getName
).
collect
(
Collectors
.
toList
());
Map
map
=
new
LinkedHashMap
();
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>
();
map
.
put
(
"用户名"
,
userDTO
.
getUsername
());
map
.
put
(
"头像"
,
userDTO
.
getAvatar
());
map
.
put
(
"邮箱"
,
userDTO
.
getEmail
());
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptMapper.java
View file @
bf7c1eeb
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-03-25
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DeptMapper
extends
EntityMapper
<
DeptDTO
,
Dept
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptSmallMapper.java
View file @
bf7c1eeb
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-03-25
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DeptSmallMapper
extends
EntityMapper
<
DeptSmallDTO
,
Dept
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictDetailMapper.java
View file @
bf7c1eeb
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-04-10
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DictDetailMapper
extends
EntityMapper
<
DictDetailDTO
,
DictDetail
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictMapper.java
View file @
bf7c1eeb
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-04-10
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
DictMapper
extends
EntityMapper
<
DictDTO
,
Dict
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobSmallMapper.java
View file @
bf7c1eeb
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-03-29
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
JobSmallMapper
extends
EntityMapper
<
JobSmallDTO
,
Job
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java
View file @
bf7c1eeb
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2018-12-17
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
MenuMapper
extends
EntityMapper
<
MenuDTO
,
Menu
>
{
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleSmallMapper.java
View file @
bf7c1eeb
...
...
@@ -11,7 +11,7 @@ import org.mapstruct.ReportingPolicy;
* @author Zheng Jie
* @date 2019-5-23
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
RoleSmallMapper
extends
EntityMapper
<
RoleSmallDTO
,
Role
>
{
}
eladmin-system/src/main/resources/config/application-dev.yml
View file @
bf7c1eeb
...
...
@@ -47,11 +47,6 @@ jwt:
secret
:
mySecret
# token 过期时间 6个小时
expiration
:
21000000
auth
:
# 授权路径
path
:
/login
# 获取用户信息
account
:
/info
#是否允许生成代码,生产环境设置为false
generator
:
...
...
eladmin-system/src/main/resources/config/application-prod.yml
View file @
bf7c1eeb
...
...
@@ -49,11 +49,6 @@ jwt:
secret
:
mySecret
# token 过期时间 2个小时
expiration
:
7200000
auth
:
# 授权路径
path
:
/login
# 获取用户信息
account
:
/info
#是否允许生成代码,生产环境设置为false
generator
:
...
...
eladmin-system/src/main/resources/template/generator/admin/Controller.ftl
View file @
bf7c1eeb
...
...
@@ -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;
...
...
@@ -19,40 +18,43 @@ 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
;
}
@
G
etMapping
@
L
og
(
"查询${className}"
)
@
A
piOperation
(
value
=
"查询${className}"
)
@
G
etMapping
(
value
=
"/${changeClassName}"
)
@
A
piOperation
(
"查询${className}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_SELECT')"
)
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}"
)
@
A
piOperation
(
"新增${className}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_CREATE')"
)
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}"
)
@
A
piOperation
(
"修改${className}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_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}}"
)
@
A
piOperation
(
"删除${className}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE')"
)
public
R
esponseEntity
delete
(
@
P
athVariable
$
{
pkColumnType
}
$
{
pkChangeColName
}){
$
{
changeClassName
}
S
ervice
.delete
(
$
{
pkChangeColName
})
;
...
...
eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl
View file @
bf7c1eeb
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
*
@author $
{
author
}
*
@date $
{
date
}
*/
@
Mapper
(
componentModel
=
"spring",
uses =
{}
,
unmappedTargetPolicy = ReportingPolicy.IGNORE)
@
Mapper
(
componentModel
=
"spring",
unmappedTargetPolicy = ReportingPolicy.IGNORE)
public
interface $
{
className
}
Mapper extends EntityMapper<$
{
className
}
DTO, $
{
className
}
>
{
}
\ No newline at end of file
eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl
View file @
bf7c1eeb
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??>
...
...
Prev
1
2
3
4
5
6
7
8
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