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
7eba9641
Commit
7eba9641
authored
Jun 04, 2019
by
zhengjie
Browse files
去除实时控制台功能,查询方式修改成注解方式
parent
e6c23f81
Changes
76
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java
View file @
7eba9641
...
...
@@ -4,10 +4,8 @@ import lombok.extern.slf4j.Slf4j;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
import
me.zhengjie.modules.quartz.domain.QuartzLog
;
import
me.zhengjie.modules.quartz.service.QuartzJobService
;
import
me.zhengjie.modules.quartz.service.query.QuartzJobQueryService
;
import
me.zhengjie.modules.quartz.service.query.QuartzLogQueryService
;
import
me.zhengjie.modules.quartz.service.dto.JobQueryCriteria
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -30,29 +28,17 @@ public class QuartzJobController {
@Autowired
private
QuartzJobService
quartzJobService
;
@Autowired
private
QuartzJobQueryService
quartzJobQueryService
;
@Autowired
private
QuartzLogQueryService
quartzLogQueryService
;
@Log
(
"查询定时任务"
)
@GetMapping
(
value
=
"/jobs"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','JOB_ALL','JOB_SELECT')"
)
public
ResponseEntity
getJobs
(
QuartzJob
resources
,
Pageable
pageable
){
return
new
ResponseEntity
(
quartzJob
Query
Service
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
public
ResponseEntity
getJobs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
(
quartzJobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
/**
* 查询定时任务日志
* @param resources
* @param pageable
* @return
*/
@GetMapping
(
value
=
"/jobLogs"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','JOB_ALL','JOB_SELECT')"
)
public
ResponseEntity
getJobLogs
(
QuartzLog
resources
,
Pageable
pageable
){
return
new
ResponseEntity
(
quartz
LogQuery
Service
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
public
ResponseEntity
getJobLogs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
(
quartz
Job
Service
.
queryAll
Log
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"新增定时任务"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/QuartzJobService.java
View file @
7eba9641
package
me.zhengjie.modules.quartz.service
;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
import
me.zhengjie.modules.quartz.domain.QuartzLog
;
import
me.zhengjie.modules.quartz.service.dto.JobQueryCriteria
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Pageable
;
/**
* @author jie
...
...
@@ -12,6 +15,23 @@ import org.springframework.cache.annotation.Cacheable;
@CacheConfig
(
cacheNames
=
"quartzJob"
)
public
interface
QuartzJobService
{
/**
* queryAll quartzJob
* @param criteria
* @param pageable
* @return
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
Object
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
/**
* queryAll quartzLog
* @param criteria
* @param pageable
* @return
*/
Object
queryAllLog
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
/**
* create
* @param resources
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/dto/JobQueryCriteria.java
0 → 100644
View file @
7eba9641
package
me.zhengjie.modules.quartz.service.dto
;
import
lombok.Data
;
import
me.zhengjie.annotation.Query
;
/**
* @author jie
* @date 2019-6-4 10:33:02
*/
@Data
public
class
JobQueryCriteria
{
@Query
(
type
=
Query
.
Type
.
INNER_LIKE
)
private
String
jobName
;
@Query
private
Boolean
isSuccess
;
}
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java
View file @
7eba9641
...
...
@@ -3,11 +3,16 @@ package me.zhengjie.modules.quartz.service.impl;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
import
me.zhengjie.modules.quartz.repository.QuartzJobRepository
;
import
me.zhengjie.modules.quartz.repository.QuartzLogRepository
;
import
me.zhengjie.modules.quartz.service.QuartzJobService
;
import
me.zhengjie.modules.quartz.service.dto.JobQueryCriteria
;
import
me.zhengjie.modules.quartz.utils.QuartzManage
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.QueryHelp
;
import
me.zhengjie.utils.ValidationUtil
;
import
org.quartz.CronExpression
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -24,9 +29,21 @@ public class QuartzJobServiceImpl implements QuartzJobService {
@Autowired
private
QuartzJobRepository
quartzJobRepository
;
@Autowired
private
QuartzLogRepository
quartzLogRepository
;
@Autowired
private
QuartzManage
quartzManage
;
@Override
public
Object
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
return
PageUtil
.
toPage
(
quartzJobRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
));
}
public
Object
queryAllLog
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
return
PageUtil
.
toPage
(
quartzLogRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
));
}
@Override
public
QuartzJob
findById
(
Long
id
)
{
Optional
<
QuartzJob
>
quartzJob
=
quartzJobRepository
.
findById
(
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/query/QuartzJobQueryService.java
deleted
100644 → 0
View file @
e6c23f81
package
me.zhengjie.modules.quartz.service.query
;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
import
me.zhengjie.modules.quartz.repository.QuartzJobRepository
;
import
me.zhengjie.utils.PageUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ObjectUtils
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author jie
* @date 2019-01-07
*/
@Service
@CacheConfig
(
cacheNames
=
"quartzJob"
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
QuartzJobQueryService
{
@Autowired
private
QuartzJobRepository
quartzJobRepository
;
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
public
Object
queryAll
(
QuartzJob
quartzJob
,
Pageable
pageable
){
return
PageUtil
.
toPage
(
quartzJobRepository
.
findAll
(
new
Spec
(
quartzJob
),
pageable
));
}
class
Spec
implements
Specification
<
QuartzJob
>
{
private
QuartzJob
quartzJob
;
public
Spec
(
QuartzJob
quartzJob
){
this
.
quartzJob
=
quartzJob
;
}
@Override
public
Predicate
toPredicate
(
Root
<
QuartzJob
>
root
,
CriteriaQuery
<?>
criteriaQuery
,
CriteriaBuilder
cb
)
{
List
<
Predicate
>
list
=
new
ArrayList
<
Predicate
>();
if
(!
ObjectUtils
.
isEmpty
(
quartzJob
.
getJobName
())){
/**
* 模糊
*/
list
.
add
(
cb
.
like
(
root
.
get
(
"jobName"
).
as
(
String
.
class
),
"%"
+
quartzJob
.
getJobName
()+
"%"
));
}
Predicate
[]
p
=
new
Predicate
[
list
.
size
()];
return
cb
.
and
(
list
.
toArray
(
p
));
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/query/QuartzLogQueryService.java
deleted
100644 → 0
View file @
e6c23f81
package
me.zhengjie.modules.quartz.service.query
;
import
me.zhengjie.modules.quartz.domain.QuartzLog
;
import
me.zhengjie.modules.quartz.repository.QuartzLogRepository
;
import
me.zhengjie.utils.PageUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ObjectUtils
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author jie
* @date 2019-01-07
*/
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
QuartzLogQueryService
{
@Autowired
private
QuartzLogRepository
quartzLogRepository
;
public
Object
queryAll
(
QuartzLog
quartzLog
,
Pageable
pageable
){
return
PageUtil
.
toPage
(
quartzLogRepository
.
findAll
(
new
Spec
(
quartzLog
),
pageable
));
}
class
Spec
implements
Specification
<
QuartzLog
>
{
private
QuartzLog
quartzLog
;
public
Spec
(
QuartzLog
quartzLog
){
this
.
quartzLog
=
quartzLog
;
}
@Override
public
Predicate
toPredicate
(
Root
<
QuartzLog
>
root
,
CriteriaQuery
<?>
criteriaQuery
,
CriteriaBuilder
cb
)
{
List
<
Predicate
>
list
=
new
ArrayList
<
Predicate
>();
if
(!
ObjectUtils
.
isEmpty
(
quartzLog
.
getJobName
())){
/**
* 模糊
*/
list
.
add
(
cb
.
like
(
root
.
get
(
"jobName"
).
as
(
String
.
class
),
"%"
+
quartzLog
.
getJobName
()+
"%"
));
}
if
(!
ObjectUtils
.
isEmpty
(
quartzLog
.
getIsSuccess
()))
{
list
.
add
(
cb
.
equal
(
root
.
get
(
"isSuccess"
).
as
(
Boolean
.
class
),
quartzLog
.
getIsSuccess
()));
}
Predicate
[]
p
=
new
Predicate
[
list
.
size
()];
return
cb
.
and
(
list
.
toArray
(
p
));
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java
View file @
7eba9641
...
...
@@ -6,7 +6,7 @@ import me.zhengjie.exception.BadRequestException;
import
me.zhengjie.modules.system.domain.Dept
;
import
me.zhengjie.modules.system.service.DeptService
;
import
me.zhengjie.modules.system.service.dto.DeptDTO
;
import
me.zhengjie.modules.system.service.
query
.DeptQuery
Service
;
import
me.zhengjie.modules.system.service.
dto
.DeptQuery
Criteria
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -14,7 +14,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Set
;
/**
* @author jie
...
...
@@ -27,9 +26,6 @@ public class DeptController {
@Autowired
private
DeptService
deptService
;
@Autowired
private
DeptQueryService
deptQueryService
;
@Autowired
private
DataScope
dataScope
;
...
...
@@ -38,10 +34,10 @@ public class DeptController {
@Log
(
"查询部门"
)
@GetMapping
(
value
=
"/dept"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_SELECT','DEPT_ALL','DEPT_SELECT')"
)
public
ResponseEntity
getDepts
(
Dept
DTO
resources
){
public
ResponseEntity
getDepts
(
Dept
QueryCriteria
criteria
){
// 数据权限
Set
<
Long
>
dep
tIds
=
dataScope
.
getDeptIds
();
List
<
DeptDTO
>
deptDTOS
=
dept
Query
Service
.
queryAll
(
resources
,
deptIds
);
criteria
.
se
tIds
(
dataScope
.
getDeptIds
()
)
;
List
<
DeptDTO
>
deptDTOS
=
deptService
.
queryAll
(
criteria
);
return
new
ResponseEntity
(
deptService
.
buildTree
(
deptDTOS
),
HttpStatus
.
OK
);
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java
View file @
7eba9641
...
...
@@ -5,7 +5,6 @@ import me.zhengjie.exception.BadRequestException;
import
me.zhengjie.modules.system.domain.Dict
;
import
me.zhengjie.modules.system.service.DictService
;
import
me.zhengjie.modules.system.service.dto.DictDTO
;
import
me.zhengjie.modules.system.service.query.DictQueryService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -25,16 +24,13 @@ public class DictController {
@Autowired
private
DictService
dictService
;
@Autowired
private
DictQueryService
dictQueryService
;
private
static
final
String
ENTITY_NAME
=
"dict"
;
@Log
(
"查询字典"
)
@GetMapping
(
value
=
"/dict"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DICT_ALL','DICT_SELECT')"
)
public
ResponseEntity
getDicts
(
DictDTO
resources
,
Pageable
pageable
){
return
new
ResponseEntity
(
dict
Query
Service
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
(
dictService
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"新增字典"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java
View file @
7eba9641
...
...
@@ -4,8 +4,7 @@ import me.zhengjie.aop.log.Log;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.system.domain.DictDetail
;
import
me.zhengjie.modules.system.service.DictDetailService
;
import
me.zhengjie.modules.system.service.dto.DictDetailDTO
;
import
me.zhengjie.modules.system.service.query.DictDetailQueryService
;
import
me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
...
...
@@ -27,16 +26,13 @@ public class DictDetailController {
@Autowired
private
DictDetailService
dictDetailService
;
@Autowired
private
DictDetailQueryService
dictDetailQueryService
;
private
static
final
String
ENTITY_NAME
=
"dictDetail"
;
@Log
(
"查询字典详情"
)
@GetMapping
(
value
=
"/dictDetail"
)
public
ResponseEntity
getDictDetails
(
DictDetail
DTO
resources
,
public
ResponseEntity
getDictDetails
(
DictDetail
QueryCriteria
criteria
,
@PageableDefault
(
value
=
10
,
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
return
new
ResponseEntity
(
dictDetail
Query
Service
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
(
dictDetailService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"新增字典详情"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java
View file @
7eba9641
...
...
@@ -5,7 +5,7 @@ import me.zhengjie.config.DataScope;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.system.domain.Job
;
import
me.zhengjie.modules.system.service.JobService
;
import
me.zhengjie.modules.system.service.
query
.JobQuery
Service
;
import
me.zhengjie.modules.system.service.
dto
.JobQuery
Criteria
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -27,9 +27,6 @@ public class JobController {
@Autowired
private
JobService
jobService
;
@Autowired
private
JobQueryService
jobQueryService
;
@Autowired
private
DataScope
dataScope
;
...
...
@@ -38,13 +35,11 @@ public class JobController {
@Log
(
"查询岗位"
)
@GetMapping
(
value
=
"/job"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_SELECT','USER_ALL','USER_SELECT')"
)
public
ResponseEntity
getJobs
(
@RequestParam
(
required
=
false
)
String
name
,
@RequestParam
(
required
=
false
)
Long
deptId
,
@RequestParam
(
required
=
false
)
Boolean
enabled
,
public
ResponseEntity
getJobs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
// 数据权限
Set
<
Long
>
d
eptIds
=
dataScope
.
getDeptIds
();
return
new
ResponseEntity
(
job
Query
Service
.
queryAll
(
name
,
enabled
,
deptIds
,
deptId
,
pageable
),
HttpStatus
.
OK
);
criteria
.
setD
eptIds
(
dataScope
.
getDeptIds
()
)
;
return
new
ResponseEntity
(
jobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"新增岗位"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java
View file @
7eba9641
...
...
@@ -2,15 +2,13 @@ package me.zhengjie.modules.system.rest;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.modules.system.domain.Menu
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.system.service.MenuService
;
import
me.zhengjie.modules.system.service.RoleService
;
import
me.zhengjie.modules.system.service.UserService
;
import
me.zhengjie.modules.system.service.dto.CommonQueryCriteria
;
import
me.zhengjie.modules.system.service.dto.MenuDTO
;
import
me.zhengjie.modules.system.service.dto.UserDTO
;
import
me.zhengjie.modules.system.service.mapper.MenuMapper
;
import
me.zhengjie.modules.system.service.query.MenuQueryService
;
import
me.zhengjie.utils.SecurityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -31,18 +29,12 @@ public class MenuController {
@Autowired
private
MenuService
menuService
;
@Autowired
private
MenuQueryService
menuQueryService
;
@Autowired
private
UserService
userService
;
@Autowired
private
RoleService
roleService
;
@Autowired
private
MenuMapper
menuMapper
;
private
static
final
String
ENTITY_NAME
=
"menu"
;
/**
...
...
@@ -70,8 +62,8 @@ public class MenuController {
@Log
(
"查询菜单"
)
@GetMapping
(
value
=
"/menus"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')"
)
public
ResponseEntity
getMenus
(
@RequestParam
(
required
=
false
)
String
name
){
List
<
MenuDTO
>
menuDTOList
=
menu
Query
Service
.
queryAll
(
name
);
public
ResponseEntity
getMenus
(
CommonQueryCriteria
criteria
){
List
<
MenuDTO
>
menuDTOList
=
menuService
.
queryAll
(
criteria
);
return
new
ResponseEntity
(
menuService
.
buildTree
(
menuDTOList
),
HttpStatus
.
OK
);
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/PermissionController.java
View file @
7eba9641
...
...
@@ -4,8 +4,8 @@ import me.zhengjie.aop.log.Log;
import
me.zhengjie.modules.system.domain.Permission
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.system.service.PermissionService
;
import
me.zhengjie.modules.system.service.dto.CommonQueryCriteria
;
import
me.zhengjie.modules.system.service.dto.PermissionDTO
;
import
me.zhengjie.modules.system.service.query.PermissionQueryService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -26,9 +26,6 @@ public class PermissionController {
@Autowired
private
PermissionService
permissionService
;
@Autowired
private
PermissionQueryService
permissionQueryService
;
private
static
final
String
ENTITY_NAME
=
"permission"
;
/**
...
...
@@ -44,8 +41,8 @@ public class PermissionController {
@Log
(
"查询权限"
)
@GetMapping
(
value
=
"/permissions"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')"
)
public
ResponseEntity
getPermissions
(
@RequestParam
(
required
=
false
)
String
name
){
List
<
PermissionDTO
>
permissionDTOS
=
permission
Query
Service
.
queryAll
(
name
);
public
ResponseEntity
getPermissions
(
CommonQueryCriteria
criteria
){
List
<
PermissionDTO
>
permissionDTOS
=
permissionService
.
queryAll
(
criteria
);
return
new
ResponseEntity
(
permissionService
.
buildTree
(
permissionDTOS
),
HttpStatus
.
OK
);
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java
View file @
7eba9641
...
...
@@ -4,11 +4,9 @@ import cn.hutool.core.lang.Dict;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.modules.system.service.RoleService
;
import
me.zhengjie.modules.system.service.dto.
RoleDTO
;
import
me.zhengjie.modules.system.service.dto.
CommonQueryCriteria
;
import
me.zhengjie.modules.system.service.dto.RoleSmallDTO
;
import
me.zhengjie.modules.system.service.query.RoleQueryService
;
import
me.zhengjie.utils.SecurityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
...
...
@@ -19,10 +17,8 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -36,9 +32,6 @@ public class RoleController {
@Autowired
private
RoleService
roleService
;
@Autowired
private
RoleQueryService
roleQueryService
;
private
static
final
String
ENTITY_NAME
=
"role"
;
/**
...
...
@@ -59,15 +52,14 @@ public class RoleController {
@GetMapping
(
value
=
"/roles/all"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','USER_ALL','USER_CREATE','USER_EDIT')"
)
public
ResponseEntity
getAll
(
@PageableDefault
(
value
=
2000
,
sort
=
{
"level"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
return
new
ResponseEntity
(
roleQueryService
.
queryAll
(
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
(
roleService
.
queryAll
(
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"查询角色"
)
@GetMapping
(
value
=
"/roles"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')"
)
public
ResponseEntity
getRoles
(
@RequestParam
(
required
=
false
)
String
name
,
Pageable
pageable
){
return
new
ResponseEntity
(
role
Query
Service
.
queryAll
(
name
,
pageable
),
HttpStatus
.
OK
);
public
ResponseEntity
getRoles
(
CommonQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
(
roleService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
@GetMapping
(
value
=
"/roles/level"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java
View file @
7eba9641
...
...
@@ -4,18 +4,16 @@ import me.zhengjie.aop.log.Log;
import
me.zhengjie.config.DataScope
;
import
me.zhengjie.domain.Picture
;
import
me.zhengjie.domain.VerificationCode
;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.system.service.DeptService
;
import
me.zhengjie.modules.system.service.RoleService
;
import
me.zhengjie.modules.system.service.dto.RoleSmallDTO
;
import
me.zhengjie.modules.system.service.dto.UserQueryCriteria
;
import
me.zhengjie.service.PictureService
;
import
me.zhengjie.service.VerificationCodeService
;
import
me.zhengjie.utils.*
;
import
me.zhengjie.modules.system.service.UserService
;
import
me.zhengjie.modules.system.service.dto.UserDTO
;
import
me.zhengjie.modules.system.service.query.UserQueryService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -41,9 +39,6 @@ public class UserController {
@Autowired
private
UserService
userService
;
@Autowired
private
UserQueryService
userQueryService
;
@Autowired
private
PictureService
pictureService
;
...
...
@@ -59,19 +54,16 @@ public class UserController {
@Autowired
private
VerificationCodeService
verificationCodeService
;
private
static
final
String
ENTITY_NAME
=
"user"
;
@Log
(
"查询用户"
)
@GetMapping
(
value
=
"/users"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_SELECT')"
)
public
ResponseEntity
getUsers
(
User
DTO
userDTO
,
Pageable
pageable
){
public
ResponseEntity
getUsers
(
User
QueryCriteria
criteria
,
Pageable
pageable
){
Set
<
Long
>
deptSet
=
new
HashSet
<>();
Set
<
Long
>
result
=
new
HashSet
<>();
if
(!
ObjectUtils
.
isEmpty
(
userDTO
.
getDeptId
()))
{
deptSet
.
add
(
userDTO
.
getDeptId
());
deptSet
.
addAll
(
dataScope
.
getDeptChildren
(
deptService
.
findByPid
(
userDTO
.
getDeptId
())));
if
(!
ObjectUtils
.
isEmpty
(
criteria
.
getDeptId
()))
{
deptSet
.
add
(
criteria
.
getDeptId
());
deptSet
.
addAll
(
dataScope
.
getDeptChildren
(
deptService
.
findByPid
(
criteria
.
getDeptId
())));
}
// 数据权限
...
...
@@ -85,14 +77,16 @@ public class UserController {
result
.
retainAll
(
deptIds
);
// 若无交集,则代表无数据权限
criteria
.
setDeptIds
(
result
);
if
(
result
.
size
()
==
0
){
return
new
ResponseEntity
(
PageUtil
.
toPage
(
null
,
0
),
HttpStatus
.
OK
);
}
else
return
new
ResponseEntity
(
user
Query
Service
.
queryAll
(
userDTO
,
result
,
pageable
),
HttpStatus
.
OK
);
}
else
return
new
ResponseEntity
(
userService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
// 否则取并集
}
else
{
result
.
addAll
(
deptSet
);
result
.
addAll
(
deptIds
);
return
new
ResponseEntity
(
userQueryService
.
queryAll
(
userDTO
,
result
,
pageable
),
HttpStatus
.
OK
);
criteria
.
setDeptIds
(
result
);
return
new
ResponseEntity
(
userService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/DeptService.java
View file @
7eba9641
...
...
@@ -2,6 +2,7 @@ package me.zhengjie.modules.system.service;
import
me.zhengjie.modules.system.domain.Dept
;
import
me.zhengjie.modules.system.service.dto.DeptDTO
;
import
me.zhengjie.modules.system.service.dto.DeptQueryCriteria
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
...
...
@@ -16,6 +17,14 @@ import java.util.Set;
@CacheConfig
(
cacheNames
=
"dept"
)
public
interface
DeptService
{
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
List
<
DeptDTO
>
queryAll
(
DeptQueryCriteria
criteria
);
/**
* findById
* @param id
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java
View file @
7eba9641
...
...
@@ -2,9 +2,11 @@ package me.zhengjie.modules.system.service;
import
me.zhengjie.modules.system.domain.DictDetail
;
import
me.zhengjie.modules.system.service.dto.DictDetailDTO
;
import
me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Pageable
;
/**
* @author jie
...
...
@@ -42,4 +44,7 @@ public interface DictDetailService {
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
Object
queryAll
(
DictDetailQueryCriteria
criteria
,
Pageable
pageable
);
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictService.java
View file @
7eba9641
...
...
@@ -5,6 +5,7 @@ import me.zhengjie.modules.system.service.dto.DictDTO;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Pageable
;
/**
* @author jie
...
...
@@ -13,6 +14,15 @@ import org.springframework.cache.annotation.Cacheable;
@CacheConfig
(
cacheNames
=
"dict"
)
public
interface
DictService
{
/**
* 查询
* @param dict
* @param pageable
* @return
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
Object
queryAll
(
DictDTO
dict
,
Pageable
pageable
);
/**
* findById
* @param id
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/JobService.java
View file @
7eba9641
...
...
@@ -2,9 +2,11 @@ package me.zhengjie.modules.system.service;
import
me.zhengjie.modules.system.domain.Job
;
import
me.zhengjie.modules.system.service.dto.JobDTO
;
import
me.zhengjie.modules.system.service.dto.JobQueryCriteria
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Pageable
;
/**
* @author jie
...
...
@@ -42,4 +44,12 @@ public interface JobService {
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
/**
* queryAll
* @param criteria
* @param pageable
* @return
*/
Object
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java
View file @
7eba9641
...
...
@@ -2,6 +2,7 @@ package me.zhengjie.modules.system.service;
import
me.zhengjie.modules.system.domain.Menu
;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.modules.system.service.dto.CommonQueryCriteria
;
import
me.zhengjie.modules.system.service.dto.MenuDTO
;
import
me.zhengjie.modules.system.service.dto.RoleSmallDTO
;
import
org.springframework.cache.annotation.CacheConfig
;
...
...
@@ -18,6 +19,14 @@ import java.util.Set;
@CacheConfig
(
cacheNames
=
"menu"
)
public
interface
MenuService
{
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
List
<
MenuDTO
>
queryAll
(
CommonQueryCriteria
criteria
);
/**
* get
* @param id
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/PermissionService.java
View file @
7eba9641
package
me.zhengjie.modules.system.service
;
import
me.zhengjie.modules.system.domain.Permission
;
import
me.zhengjie.modules.system.service.dto.CommonQueryCriteria
;
import
me.zhengjie.modules.system.service.dto.PermissionDTO
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
...
...
@@ -68,4 +69,12 @@ public interface PermissionService {
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
Object
buildTree
(
List
<
PermissionDTO
>
permissionDTOS
);
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
List
<
PermissionDTO
>
queryAll
(
CommonQueryCriteria
criteria
);
}
Prev
1
2
3
4
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