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
"vscode:/vscode.git/clone" did not exist on "4afc188b7364c62fa6922aaa5676d399b791f1c0"
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/rest/DictController.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.aop.log.Log
;
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.DictQueryCriteria
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -13,47 +14,66 @@ import org.springframework.security.access.prepost.PreAuthorize;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Api
(
tags
=
"系统:字典管理"
)
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"
/
api
/dict
"
)
public
class
DictController
{
@Autowired
private
DictService
dictService
;
private
final
DictService
dictService
;
private
static
final
String
ENTITY_NAME
=
"dict"
;
public
DictController
(
DictService
dictService
)
{
this
.
dictService
=
dictService
;
}
@Log
(
"导出字典数据"
)
@ApiOperation
(
"导出字典数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check('dict:list')"
)
public
void
download
(
HttpServletResponse
response
,
DictQueryCriteria
criteria
)
throws
IOException
{
dictService
.
download
(
dictService
.
queryAll
(
criteria
),
response
);
}
@Log
(
"查询字典"
)
@GetMapping
(
value
=
"/dict"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DICT_ALL','DICT_SELECT')"
)
@ApiOperation
(
"查询字典"
)
@GetMapping
@PreAuthorize
(
"@el.check('dict:list')"
)
public
ResponseEntity
getDicts
(
DictQueryCriteria
resources
,
Pageable
pageable
){
return
new
ResponseEntity
(
dictService
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
dictService
.
queryAll
(
resources
,
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"新增字典"
)
@PostMapping
(
value
=
"/dict"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DICT_ALL','DICT_CREATE')"
)
@ApiOperation
(
"新增字典"
)
@PostMapping
@PreAuthorize
(
"@el.check('dict:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Dict
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
return
new
ResponseEntity
(
dictService
.
create
(
resources
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
dictService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
@Log
(
"修改字典"
)
@PutMapping
(
value
=
"/dict"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DICT_ALL','DICT_EDIT')"
)
@ApiOperation
(
"修改字典"
)
@PutMapping
@PreAuthorize
(
"@el.check('dict:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Dict
.
Update
.
class
)
@RequestBody
Dict
resources
){
dictService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除字典"
)
@DeleteMapping
(
value
=
"/dict/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DICT_ALL','DICT_DELETE')"
)
@ApiOperation
(
"删除字典"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('dict:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
dictService
.
delete
(
id
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
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.DictDetailQueryCriteria
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.web.PageableDefault
;
...
...
@@ -14,67 +15,72 @@ 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.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@RestController
@RequestMapping
(
"api"
)
@Api
(
tags
=
"系统:字典详情管理"
)
@RequestMapping
(
"/api/dictDetail"
)
public
class
DictDetailController
{
@Autowired
private
DictDetailService
dictDetailService
;
private
final
DictDetailService
dictDetailService
;
private
static
final
String
ENTITY_NAME
=
"dictDetail"
;
public
DictDetailController
(
DictDetailService
dictDetailService
)
{
this
.
dictDetailService
=
dictDetailService
;
}
@Log
(
"查询字典详情"
)
@GetMapping
(
value
=
"/dictDetail"
)
@ApiOperation
(
"查询字典详情"
)
@GetMapping
public
ResponseEntity
getDictDetails
(
DictDetailQueryCriteria
criteria
,
@PageableDefault
(
value
=
10
,
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
String
[]
names
=
criteria
.
getDictName
().
split
(
","
);
return
new
ResponseEntity
(
dictDetailService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
@PageableDefault
(
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
return
new
ResponseEntity
<>(
dictDetailService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"查询多个字典详情"
)
@GetMapping
(
value
=
"/dictDetail/map"
)
@ApiOperation
(
"查询多个字典详情"
)
@GetMapping
(
value
=
"/map"
)
public
ResponseEntity
getDictDetailMaps
(
DictDetailQueryCriteria
criteria
,
@PageableDefault
(
value
=
10
,
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
@PageableDefault
(
sort
=
{
"sort"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
String
[]
names
=
criteria
.
getDictName
().
split
(
","
);
Map
map
=
new
HashMap
(
names
.
length
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>
(
names
.
length
);
for
(
String
name
:
names
)
{
criteria
.
setDictName
(
name
);
map
.
put
(
name
,
dictDetailService
.
queryAll
(
criteria
,
pageable
).
get
(
"content"
));
}
return
new
ResponseEntity
(
map
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
map
,
HttpStatus
.
OK
);
}
@Log
(
"新增字典详情"
)
@PostMapping
(
value
=
"/dictDetail"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DICT_ALL','DICT_CREATE')"
)
@ApiOperation
(
"新增字典详情"
)
@PostMapping
@PreAuthorize
(
"@el.check('dict:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
DictDetail
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
return
new
ResponseEntity
(
dictDetailService
.
create
(
resources
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
dictDetailService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
@Log
(
"修改字典详情"
)
@PutMapping
(
value
=
"/dictDetail"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DICT_ALL','DICT_EDIT')"
)
@ApiOperation
(
"修改字典详情"
)
@PutMapping
@PreAuthorize
(
"@el.check('dict:edit')"
)
public
ResponseEntity
update
(
@Validated
(
DictDetail
.
Update
.
class
)
@RequestBody
DictDetail
resources
){
dictDetailService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除字典详情"
)
@DeleteMapping
(
value
=
"/dictDetail/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DICT_ALL','DICT_DELETE')"
)
@ApiOperation
(
"删除字典详情"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('dict:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
dictDetailService
.
delete
(
id
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.config.DataScope
;
import
me.zhengjie.exception.BadRequestException
;
...
...
@@ -7,7 +9,6 @@ import me.zhengjie.modules.system.domain.Job;
import
me.zhengjie.modules.system.service.JobService
;
import
me.zhengjie.modules.system.service.dto.JobQueryCriteria
;
import
me.zhengjie.utils.ThrowableUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -15,55 +16,72 @@ import org.springframework.security.access.prepost.PreAuthorize;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
* @author Zheng Jie
* @date 2019-03-29
*/
@Api
(
tags
=
"系统:岗位管理"
)
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"
/
api
/job
"
)
public
class
JobController
{
@Autowired
private
JobService
jobService
;
private
final
JobService
jobService
;
@Autowired
private
DataScope
dataScope
;
private
final
DataScope
dataScope
;
private
static
final
String
ENTITY_NAME
=
"job"
;
public
JobController
(
JobService
jobService
,
DataScope
dataScope
)
{
this
.
jobService
=
jobService
;
this
.
dataScope
=
dataScope
;
}
@Log
(
"导出岗位数据"
)
@ApiOperation
(
"导出岗位数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check('job:list')"
)
public
void
download
(
HttpServletResponse
response
,
JobQueryCriteria
criteria
)
throws
IOException
{
jobService
.
download
(
jobService
.
queryAll
(
criteria
),
response
);
}
@Log
(
"查询岗位"
)
@GetMapping
(
value
=
"/job"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_SELECT','USER_ALL','USER_SELECT')"
)
@ApiOperation
(
"查询岗位"
)
@GetMapping
@PreAuthorize
(
"@el.check('job:list','user:list')"
)
public
ResponseEntity
getJobs
(
JobQueryCriteria
criteria
,
Pageable
pageable
){
// 数据权限
criteria
.
setDeptIds
(
dataScope
.
getDeptIds
());
return
new
ResponseEntity
(
jobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
jobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"新增岗位"
)
@PostMapping
(
value
=
"/job"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_CREATE')"
)
@ApiOperation
(
"新增岗位"
)
@PostMapping
@PreAuthorize
(
"@el.check('job:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Job
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
return
new
ResponseEntity
(
jobService
.
create
(
resources
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
jobService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
@Log
(
"修改岗位"
)
@PutMapping
(
value
=
"/job"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_EDIT')"
)
@ApiOperation
(
"修改岗位"
)
@PutMapping
@PreAuthorize
(
"@el.check('job:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Job
.
Update
.
class
)
@RequestBody
Job
resources
){
jobService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除岗位"
)
@DeleteMapping
(
value
=
"/job/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_DELETE')"
)
@ApiOperation
(
"删除岗位"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('job:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
try
{
jobService
.
delete
(
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.modules.system.domain.Menu
;
import
me.zhengjie.exception.BadRequestException
;
...
...
@@ -10,12 +12,14 @@ import me.zhengjie.modules.system.service.dto.MenuDTO;
import
me.zhengjie.modules.system.service.dto.MenuQueryCriteria
;
import
me.zhengjie.modules.system.service.dto.UserDTO
;
import
me.zhengjie.utils.SecurityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
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
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -24,72 +28,83 @@ import java.util.Set;
* @author Zheng Jie
* @date 2018-12-03
*/
@Api
(
tags
=
"系统:菜单管理"
)
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"/api/menus"
)
@SuppressWarnings
(
"unchecked"
)
public
class
MenuController
{
@Autowired
private
MenuService
menuService
;
private
final
MenuService
menuService
;
@Autowired
private
UserService
userService
;
private
final
UserService
userService
;
@Autowired
private
RoleService
roleService
;
private
final
RoleService
roleService
;
private
static
final
String
ENTITY_NAME
=
"menu"
;
/**
* 构建前端路由所需要的菜单
* @return
*/
@GetMapping
(
value
=
"/menus/build"
)
public
MenuController
(
MenuService
menuService
,
UserService
userService
,
RoleService
roleService
)
{
this
.
menuService
=
menuService
;
this
.
userService
=
userService
;
this
.
roleService
=
roleService
;
}
@Log
(
"导出菜单数据"
)
@ApiOperation
(
"导出菜单数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check('menu:list')"
)
public
void
download
(
HttpServletResponse
response
,
MenuQueryCriteria
criteria
)
throws
IOException
{
menuService
.
download
(
menuService
.
queryAll
(
criteria
),
response
);
}
@ApiOperation
(
"获取前端所需菜单"
)
@GetMapping
(
value
=
"/build"
)
public
ResponseEntity
buildMenus
(){
UserDTO
user
=
userService
.
findByName
(
SecurityUtils
.
getUsername
());
List
<
MenuDTO
>
menuDTOList
=
menuService
.
findByRoles
(
roleService
.
findByUsers_Id
(
user
.
getId
()));
List
<
MenuDTO
>
menuDTO
Tree
=
(
List
<
MenuDTO
>)
menuService
.
buildTree
(
menuDTOList
).
get
(
"content"
);
return
new
ResponseEntity
(
menuService
.
buildMenus
(
menuDTO
Tree
),
HttpStatus
.
OK
);
List
<
MenuDTO
>
menuDTO
S
=
(
List
<
MenuDTO
>)
menuService
.
buildTree
(
menuDTOList
).
get
(
"content"
);
return
new
ResponseEntity
<>
(
menuService
.
buildMenus
(
menuDTO
S
),
HttpStatus
.
OK
);
}
/**
* 返回全部的菜单
* @return
*/
@GetMapping
(
value
=
"/menus/tree"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','MENU_ALL','MENU_CREATE','MENU_EDIT','ROLES_SELECT','ROLES_ALL')"
)
@ApiOperation
(
"返回全部的菜单"
)
@GetMapping
(
value
=
"/tree"
)
@PreAuthorize
(
"@el.check('menu:list','roles:list')"
)
public
ResponseEntity
getMenuTree
(){
return
new
ResponseEntity
(
menuService
.
getMenuTree
(
menuService
.
findByPid
(
0L
)),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
menuService
.
getMenuTree
(
menuService
.
findByPid
(
0L
)),
HttpStatus
.
OK
);
}
@Log
(
"查询菜单"
)
@GetMapping
(
value
=
"/menus"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')"
)
@ApiOperation
(
"查询菜单"
)
@GetMapping
@PreAuthorize
(
"@el.check('menu:list')"
)
public
ResponseEntity
getMenus
(
MenuQueryCriteria
criteria
){
List
<
MenuDTO
>
menuDTOList
=
menuService
.
queryAll
(
criteria
);
return
new
ResponseEntity
(
menuService
.
buildTree
(
menuDTOList
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
menuService
.
buildTree
(
menuDTOList
),
HttpStatus
.
OK
);
}
@Log
(
"新增菜单"
)
@PostMapping
(
value
=
"/menus"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','MENU_ALL','MENU_CREATE')"
)
@ApiOperation
(
"新增菜单"
)
@PostMapping
@PreAuthorize
(
"@el.check('menu:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Menu
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
return
new
ResponseEntity
(
menuService
.
create
(
resources
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
menuService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
@Log
(
"修改菜单"
)
@PutMapping
(
value
=
"/menus"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','MENU_ALL','MENU_EDIT')"
)
@ApiOperation
(
"修改菜单"
)
@PutMapping
@PreAuthorize
(
"@el.check('menu:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Menu
.
Update
.
class
)
@RequestBody
Menu
resources
){
menuService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除菜单"
)
@DeleteMapping
(
value
=
"/menus/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','MENU_ALL','MENU_DELETE')"
)
@ApiOperation
(
"删除菜单"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('menu:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
List
<
Menu
>
menuList
=
menuService
.
findByPid
(
id
);
Set
<
Menu
>
menuSet
=
new
HashSet
<>();
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/PermissionController.java
deleted
100644 → 0
View file @
7895e547
package
me.zhengjie.modules.system.rest
;
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.PermissionDTO
;
import
me.zhengjie.modules.system.service.dto.PermissionQueryCriteria
;
import
me.zhengjie.modules.system.service.mapper.PermissionMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
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.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* @author Zheng Jie
* @date 2018-12-03
*/
@RestController
@RequestMapping
(
"api"
)
public
class
PermissionController
{
@Autowired
private
PermissionService
permissionService
;
@Autowired
private
PermissionMapper
permissionMapper
;
private
static
final
String
ENTITY_NAME
=
"permission"
;
/**
* 返回全部的权限,新增角色时下拉选择
* @return
*/
@GetMapping
(
value
=
"/permissions/tree"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_CREATE','PERMISSION_EDIT','ROLES_SELECT','ROLES_ALL')"
)
public
ResponseEntity
getTree
(){
return
new
ResponseEntity
(
permissionService
.
getPermissionTree
(
permissionService
.
findByPid
(
0L
)),
HttpStatus
.
OK
);
}
@Log
(
"查询权限"
)
@GetMapping
(
value
=
"/permissions"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')"
)
public
ResponseEntity
getPermissions
(
PermissionQueryCriteria
criteria
){
List
<
PermissionDTO
>
permissionDTOS
=
permissionService
.
queryAll
(
criteria
);
return
new
ResponseEntity
(
permissionService
.
buildTree
(
permissionDTOS
),
HttpStatus
.
OK
);
}
@Log
(
"新增权限"
)
@PostMapping
(
value
=
"/permissions"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_CREATE')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Permission
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
return
new
ResponseEntity
(
permissionService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
@Log
(
"修改权限"
)
@PutMapping
(
value
=
"/permissions"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_EDIT')"
)
public
ResponseEntity
update
(
@Validated
(
Permission
.
Update
.
class
)
@RequestBody
Permission
resources
){
permissionService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除权限"
)
@DeleteMapping
(
value
=
"/permissions/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_DELETE')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
List
<
Permission
>
permissions
=
permissionService
.
findByPid
(
id
);
Set
<
Permission
>
permissionSet
=
new
HashSet
<>();
permissionSet
.
add
(
permissionMapper
.
toEntity
(
permissionService
.
findById
(
id
)));
permissionSet
=
permissionService
.
getDeletePermission
(
permissions
,
permissionSet
);
permissionService
.
delete
(
permissionSet
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.rest
;
import
cn.hutool.core.lang.Dict
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.modules.system.domain.Role
;
import
me.zhengjie.exception.BadRequestException
;
...
...
@@ -9,17 +11,17 @@ import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
import
me.zhengjie.modules.system.service.dto.RoleSmallDTO
;
import
me.zhengjie.utils.SecurityUtils
;
import
me.zhengjie.utils.ThrowableUtil
;
import
org.hibernate.exception.ConstraintViolationException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.web.PageableDefault
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.transaction.TransactionSystemException
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -28,86 +30,89 @@ import java.util.stream.Collectors;
* @author Zheng Jie
* @date 2018-12-03
*/
@Api
(
tags
=
"系统:角色管理"
)
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"
/
api
/roles
"
)
public
class
RoleController
{
@Autowired
private
RoleService
roleService
;
private
final
RoleService
roleService
;
private
static
final
String
ENTITY_NAME
=
"role"
;
/**
* 获取单个role
* @param id
* @return
*/
@GetMapping
(
value
=
"/
roles/
{id}"
)
@PreAuthorize
(
"
hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT
')"
)
public
RoleController
(
RoleService
roleService
)
{
this
.
roleService
=
roleService
;
}
@ApiOperation
(
"获取单个role"
)
@GetMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"
@el.check('roles:list
')"
)
public
ResponseEntity
getRoles
(
@PathVariable
Long
id
){
return
new
ResponseEntity
(
roleService
.
findById
(
id
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
roleService
.
findById
(
id
),
HttpStatus
.
OK
);
}
@Log
(
"导出角色数据"
)
@ApiOperation
(
"导出角色数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check('role:list')"
)
public
void
download
(
HttpServletResponse
response
,
RoleQueryCriteria
criteria
)
throws
IOException
{
roleService
.
download
(
roleService
.
queryAll
(
criteria
),
response
);
}
/**
* 返回全部的角色,新增用户时下拉选择
* @return
*/
@GetMapping
(
value
=
"/roles/all"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','USER_ALL','USER_CREATE','USER_EDIT')"
)
@ApiOperation
(
"返回全部的角色"
)
@GetMapping
(
value
=
"/all"
)
@PreAuthorize
(
"@el.check('roles:list','user:add','user:edit')"
)
public
ResponseEntity
getAll
(
@PageableDefault
(
value
=
2000
,
sort
=
{
"level"
},
direction
=
Sort
.
Direction
.
ASC
)
Pageable
pageable
){
return
new
ResponseEntity
(
roleService
.
queryAll
(
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
roleService
.
queryAll
(
pageable
),
HttpStatus
.
OK
);
}
@Log
(
"查询角色"
)
@GetMapping
(
value
=
"/roles"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')"
)
@ApiOperation
(
"查询角色"
)
@GetMapping
@PreAuthorize
(
"@el.check('roles:list')"
)
public
ResponseEntity
getRoles
(
RoleQueryCriteria
criteria
,
Pageable
pageable
){
return
new
ResponseEntity
(
roleService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
roleService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
@GetMapping
(
value
=
"/roles/level"
)
@ApiOperation
(
"获取用户级别"
)
@GetMapping
(
value
=
"/level"
)
public
ResponseEntity
getLevel
(){
List
<
Integer
>
levels
=
roleService
.
findByUsers_Id
(
SecurityUtils
.
getUserId
()).
stream
().
map
(
RoleSmallDTO:
:
getLevel
).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
(
Dict
.
create
().
set
(
"level"
,
Collections
.
min
(
levels
)),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
Dict
.
create
().
set
(
"level"
,
Collections
.
min
(
levels
)),
HttpStatus
.
OK
);
}
@Log
(
"新增角色"
)
@PostMapping
(
value
=
"/roles"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_CREATE')"
)
@ApiOperation
(
"新增角色"
)
@PostMapping
@PreAuthorize
(
"@el.check('roles:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Role
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
return
new
ResponseEntity
(
roleService
.
create
(
resources
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
roleService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
@Log
(
"修改角色"
)
@PutMapping
(
value
=
"/roles"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')"
)
@ApiOperation
(
"修改角色"
)
@PutMapping
@PreAuthorize
(
"@el.check('roles:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Role
.
Update
.
class
)
@RequestBody
Role
resources
){
roleService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"修改角色权限"
)
@PutMapping
(
value
=
"/roles/permission"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')"
)
public
ResponseEntity
updatePermission
(
@RequestBody
Role
resources
){
roleService
.
updatePermission
(
resources
,
roleService
.
findById
(
resources
.
getId
()));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"修改角色菜单"
)
@PutMapping
(
value
=
"/roles/menu"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')"
)
@ApiOperation
(
"修改角色菜单"
)
@PutMapping
(
value
=
"/menu"
)
@PreAuthorize
(
"@el.check('roles:edit')"
)
public
ResponseEntity
updateMenu
(
@RequestBody
Role
resources
){
roleService
.
updateMenu
(
resources
,
roleService
.
findById
(
resources
.
getId
()));
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除角色"
)
@DeleteMapping
(
value
=
"/roles/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','ROLES_ALL','ROLES_DELETE')"
)
@ApiOperation
(
"删除角色"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('roles:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
try
{
roleService
.
delete
(
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
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.User
;
import
me.zhengjie.exception.BadRequestException
;
...
...
@@ -11,11 +12,9 @@ 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
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -35,82 +34,82 @@ import java.util.stream.Collectors;
* @author Zheng Jie
* @date 2018-11-23
*/
@Api
(
tags
=
"系统:用户管理"
)
@RestController
@RequestMapping
(
"api"
)
@RequestMapping
(
"
/
api
/users
"
)
public
class
UserController
{
@Autowired
private
UserService
userService
;
private
final
UserService
userService
;
@Autowired
private
PictureService
pictureService
;
private
final
DataScope
dataScope
;
@Autowired
private
DataScope
dataScope
;
private
final
DeptService
deptService
;
@Autowired
private
DeptService
deptService
;
private
final
RoleService
roleService
;
@Autowired
private
RoleService
roleService
;
private
final
VerificationCodeService
verificationCodeService
;
@Autowired
private
VerificationCodeService
verificationCodeService
;
public
UserController
(
UserService
userService
,
DataScope
dataScope
,
DeptService
deptService
,
RoleService
roleService
,
VerificationCodeService
verificationCodeService
)
{
this
.
userService
=
userService
;
this
.
dataScope
=
dataScope
;
this
.
deptService
=
deptService
;
this
.
roleService
=
roleService
;
this
.
verificationCodeService
=
verificationCodeService
;
}
@Log
(
"导出用户数据"
)
@GetMapping
(
value
=
"/users/download"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_SELECT')"
)
public
void
update
(
HttpServletResponse
response
,
UserQueryCriteria
criteria
)
throws
IOException
{
@ApiOperation
(
"导出用户数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check('user:list')"
)
public
void
download
(
HttpServletResponse
response
,
UserQueryCriteria
criteria
)
throws
IOException
{
userService
.
download
(
userService
.
queryAll
(
criteria
),
response
);
}
@Log
(
"查询用户"
)
@GetMapping
(
value
=
"/users"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_SELECT')"
)
@ApiOperation
(
"查询用户"
)
@GetMapping
@PreAuthorize
(
"@el.check('user:list')"
)
public
ResponseEntity
getUsers
(
UserQueryCriteria
criteria
,
Pageable
pageable
){
Set
<
Long
>
deptSet
=
new
HashSet
<>();
Set
<
Long
>
result
=
new
HashSet
<>();
if
(!
ObjectUtils
.
isEmpty
(
criteria
.
getDeptId
()))
{
deptSet
.
add
(
criteria
.
getDeptId
());
deptSet
.
addAll
(
dataScope
.
getDeptChildren
(
deptService
.
findByPid
(
criteria
.
getDeptId
())));
}
// 数据权限
Set
<
Long
>
deptIds
=
dataScope
.
getDeptIds
();
// 查询条件不为空并且数据权限不为空则取交集
if
(!
CollectionUtils
.
isEmpty
(
deptIds
)
&&
!
CollectionUtils
.
isEmpty
(
deptSet
)){
// 取交集
result
.
addAll
(
deptSet
);
result
.
retainAll
(
deptIds
);
// 若无交集,则代表无数据权限
criteria
.
setDeptIds
(
result
);
if
(
result
.
size
()
==
0
){
return
new
ResponseEntity
(
PageUtil
.
toPage
(
null
,
0
),
HttpStatus
.
OK
);
}
else
return
new
ResponseEntity
(
userService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
PageUtil
.
toPage
(
null
,
0
),
HttpStatus
.
OK
);
}
else
return
new
ResponseEntity
<>
(
userService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
// 否则取并集
}
else
{
result
.
addAll
(
deptSet
);
result
.
addAll
(
deptIds
);
criteria
.
setDeptIds
(
result
);
return
new
ResponseEntity
(
userService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
userService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
@Log
(
"新增用户"
)
@PostMapping
(
value
=
"/users"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_CREATE')"
)
@ApiOperation
(
"新增用户"
)
@PostMapping
@PreAuthorize
(
"@el.check('user:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
User
resources
){
checkLevel
(
resources
);
return
new
ResponseEntity
(
userService
.
create
(
resources
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
userService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
@Log
(
"修改用户"
)
@PutMapping
(
value
=
"/users"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_EDIT')"
)
@ApiOperation
(
"修改用户"
)
@PutMapping
@PreAuthorize
(
"@el.check('user:edit')"
)
public
ResponseEntity
update
(
@Validated
(
User
.
Update
.
class
)
@RequestBody
User
resources
){
checkLevel
(
resources
);
userService
.
update
(
resources
);
...
...
@@ -118,8 +117,9 @@ public class UserController {
}
@Log
(
"删除用户"
)
@DeleteMapping
(
value
=
"/users/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_DELETE')"
)
@ApiOperation
(
"删除用户"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('user:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
Integer
currentLevel
=
Collections
.
min
(
roleService
.
findByUsers_Id
(
SecurityUtils
.
getUserId
()).
stream
().
map
(
RoleSmallDTO:
:
getLevel
).
collect
(
Collectors
.
toList
()));
Integer
optLevel
=
Collections
.
min
(
roleService
.
findByUsers_Id
(
id
).
stream
().
map
(
RoleSmallDTO:
:
getLevel
).
collect
(
Collectors
.
toList
()));
...
...
@@ -131,12 +131,8 @@ public class UserController {
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
/**
* 修改密码
* @param user
* @return
*/
@PostMapping
(
value
=
"/users/updatePass"
)
@ApiOperation
(
"修改密码"
)
@PostMapping
(
value
=
"/updatePass"
)
public
ResponseEntity
updatePass
(
@RequestBody
UserPassVo
user
){
UserDetails
userDetails
=
SecurityUtils
.
getUserDetails
();
if
(!
userDetails
.
getPassword
().
equals
(
EncryptUtils
.
encryptPassword
(
user
.
getOldPass
()))){
...
...
@@ -149,25 +145,16 @@ public class UserController {
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
/**
* 修改头像
* @param file
* @return
*/
@PostMapping
(
value
=
"/users/updateAvatar"
)
@ApiOperation
(
"修改头像"
)
@PostMapping
(
value
=
"/updateAvatar"
)
public
ResponseEntity
updateAvatar
(
@RequestParam
MultipartFile
file
){
userService
.
updateAvatar
(
file
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
/**
* 修改邮箱
* @param user
* @param user
* @return
*/
@Log
(
"修改邮箱"
)
@PostMapping
(
value
=
"/users/updateEmail/{code}"
)
@ApiOperation
(
"修改邮箱"
)
@PostMapping
(
value
=
"/updateEmail/{code}"
)
public
ResponseEntity
updateEmail
(
@PathVariable
String
code
,
@RequestBody
User
user
){
UserDetails
userDetails
=
SecurityUtils
.
getUserDetails
();
if
(!
userDetails
.
getPassword
().
equals
(
EncryptUtils
.
encryptPassword
(
user
.
getPassword
()))){
...
...
@@ -179,11 +166,9 @@ public class UserController {
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
/**
* 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误
* @param resources
* @param resources
/
*/
private
void
checkLevel
(
User
resources
)
{
Integer
currentLevel
=
Collections
.
min
(
roleService
.
findByUsers_Id
(
SecurityUtils
.
getUserId
()).
stream
().
map
(
RoleSmallDTO:
:
getLevel
).
collect
(
Collectors
.
toList
()));
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/DeptService.java
View file @
fd9fb2a6
...
...
@@ -3,10 +3,9 @@ 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
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -14,62 +13,23 @@ import java.util.Set;
* @author Zheng Jie
* @date 2019-03-25
*/
@CacheConfig
(
cacheNames
=
"dept"
)
public
interface
DeptService
{
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
List
<
DeptDTO
>
queryAll
(
DeptQueryCriteria
criteria
);
/**
* findById
* @param id
* @return
*/
@Cacheable
(
key
=
"#p0"
)
DeptDTO
findById
(
Long
id
);
/**
* create
* @param resources
* @return
*/
@CacheEvict
(
allEntries
=
true
)
DeptDTO
create
(
Dept
resources
);
/**
* update
* @param resources
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
Dept
resources
);
/**
* delete
* @param id
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
/**
* buildTree
* @param deptDTOS
* @return
*/
@Cacheable
Object
buildTree
(
List
<
DeptDTO
>
deptDTOS
);
/**
* findByPid
* @param pid
* @return
*/
@Cacheable
List
<
Dept
>
findByPid
(
long
pid
);
Set
<
Dept
>
findByRoleIds
(
Long
id
);
void
download
(
List
<
DeptDTO
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
;
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java
View file @
fd9fb2a6
...
...
@@ -3,50 +3,22 @@ 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
;
import
java.util.Map
;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@CacheConfig
(
cacheNames
=
"dictDetail"
)
public
interface
DictDetailService
{
/**
* findById
* @param id
* @return
*/
@Cacheable
(
key
=
"#p0"
)
DictDetailDTO
findById
(
Long
id
);
/**
* create
* @param resources
* @return
*/
@CacheEvict
(
allEntries
=
true
)
DictDetailDTO
create
(
DictDetail
resources
);
/**
* update
* @param resources
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
DictDetail
resources
);
/**
* delete
* @param id
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
@Cacheable
Map
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 @
fd9fb2a6
...
...
@@ -3,54 +3,30 @@ package me.zhengjie.modules.system.service;
import
me.zhengjie.modules.system.domain.Dict
;
import
me.zhengjie.modules.system.service.dto.DictDTO
;
import
me.zhengjie.modules.system.service.dto.DictQueryCriteria
;
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
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@CacheConfig
(
cacheNames
=
"dict"
)
public
interface
DictService
{
/**
* 查询
* @param dict
* @param pageable
* @return
*/
@Cacheable
Object
queryAll
(
DictQueryCriteria
dict
,
Pageable
pageable
);
/**
* findById
* @param id
* @return
*/
@Cacheable
(
key
=
"#p0"
)
Map
<
String
,
Object
>
queryAll
(
DictQueryCriteria
dict
,
Pageable
pageable
);
List
<
DictDTO
>
queryAll
(
DictQueryCriteria
dict
);
DictDTO
findById
(
Long
id
);
/**
* create
* @param resources
* @return
*/
@CacheEvict
(
allEntries
=
true
)
DictDTO
create
(
Dict
resources
);
/**
* update
* @param resources
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
Dict
resources
);
/**
* delete
* @param id
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
void
download
(
List
<
DictDTO
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
;
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/JobService.java
View file @
fd9fb2a6
...
...
@@ -3,53 +3,30 @@ 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
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author Zheng Jie
* @date 2019-03-29
*/
@CacheConfig
(
cacheNames
=
"job"
)
public
interface
JobService
{
/**
* findById
* @param id
* @return
*/
@Cacheable
(
key
=
"#p0"
)
JobDTO
findById
(
Long
id
);
/**
* create
* @param resources
* @return
*/
@CacheEvict
(
allEntries
=
true
)
JobDTO
create
(
Job
resources
);
/**
* update
* @param resources
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
Job
resources
);
/**
* delete
* @param id
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
/**
* queryAll
* @param criteria
* @param pageable
* @return
*/
Object
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
Map
<
String
,
Object
>
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
List
<
JobDTO
>
queryAll
(
JobQueryCriteria
criteria
);
void
download
(
List
<
JobDTO
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
;
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java
View file @
fd9fb2a6
...
...
@@ -4,9 +4,9 @@ import me.zhengjie.modules.system.domain.Menu;
import
me.zhengjie.modules.system.service.dto.MenuDTO
;
import
me.zhengjie.modules.system.service.dto.MenuQueryCriteria
;
import
me.zhengjie.modules.system.service.dto.RoleSmallDTO
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -15,90 +15,31 @@ import java.util.Set;
* @author Zheng Jie
* @date 2018-12-17
*/
@CacheConfig
(
cacheNames
=
"menu"
)
public
interface
MenuService
{
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
List
<
MenuDTO
>
queryAll
(
MenuQueryCriteria
criteria
);
/**
* get
* @param id
* @return
*/
@Cacheable
(
key
=
"#p0"
)
MenuDTO
findById
(
long
id
);
/**
* create
* @param resources
* @return
*/
@CacheEvict
(
allEntries
=
true
)
MenuDTO
create
(
Menu
resources
);
/**
* update
* @param resources
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
Menu
resources
);
/**
* getDeleteMenus
* @param menuList
* @param menuSet
* @return
*/
Set
<
Menu
>
getDeleteMenus
(
List
<
Menu
>
menuList
,
Set
<
Menu
>
menuSet
);
/**
* permission tree
* @return
*/
@Cacheable
(
key
=
"'tree'"
)
Object
getMenuTree
(
List
<
Menu
>
menus
);
/**
* findByPid
* @param pid
* @return
*/
@Cacheable
(
key
=
"'pid:'+#p0"
)
List
<
Menu
>
findByPid
(
long
pid
);
/**
* build Tree
* @param menuDTOS
* @return
*/
Map
buildTree
(
List
<
MenuDTO
>
menuDTOS
);
/**
* findByRoles
* @param roles
* @return
*/
Map
<
String
,
Object
>
buildTree
(
List
<
MenuDTO
>
menuDTOS
);
List
<
MenuDTO
>
findByRoles
(
List
<
RoleSmallDTO
>
roles
);
/**
* buildMenus
* @param byRoles
* @return
*/
Object
buildMenus
(
List
<
MenuDTO
>
byRoles
);
Menu
findOne
(
Long
id
);
/**
* delete
* @param menuSet
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Set
<
Menu
>
menuSet
);
void
download
(
List
<
MenuDTO
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
;
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/PermissionService.java
deleted
100644 → 0
View file @
7895e547
package
me.zhengjie.modules.system.service
;
import
me.zhengjie.modules.system.domain.Permission
;
import
me.zhengjie.modules.system.service.dto.PermissionDTO
;
import
me.zhengjie.modules.system.service.dto.PermissionQueryCriteria
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
java.util.List
;
import
java.util.Set
;
/**
* @author Zheng Jie
* @date 2018-12-08
*/
@CacheConfig
(
cacheNames
=
"permission"
)
public
interface
PermissionService
{
/**
* get
* @param id
* @return
*/
@Cacheable
(
key
=
"#p0"
)
PermissionDTO
findById
(
long
id
);
/**
* create
* @param resources
* @return
*/
@CacheEvict
(
allEntries
=
true
)
PermissionDTO
create
(
Permission
resources
);
/**
* update
* @param resources
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
Permission
resources
);
/**
* delete
* @param permissions
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Set
<
Permission
>
permissions
);
/**
* permission tree
* @return
*/
@Cacheable
(
key
=
"'tree'"
)
Object
getPermissionTree
(
List
<
Permission
>
permissions
);
/**
* findByPid
* @param pid
* @return
*/
@Cacheable
(
key
=
"'pid:'+#p0"
)
List
<
Permission
>
findByPid
(
long
pid
);
/**
* build Tree
* @param permissionDTOS
* @return
*/
@Cacheable
Object
buildTree
(
List
<
PermissionDTO
>
permissionDTOS
);
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
List
<
PermissionDTO
>
queryAll
(
PermissionQueryCriteria
criteria
);
Set
<
Permission
>
getDeletePermission
(
List
<
Permission
>
permissions
,
Set
<
Permission
>
permissionSet
);
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java
View file @
fd9fb2a6
...
...
@@ -4,11 +4,10 @@ import me.zhengjie.modules.system.domain.Role;
import
me.zhengjie.modules.system.service.dto.RoleDTO
;
import
me.zhengjie.modules.system.service.dto.RoleQueryCriteria
;
import
me.zhengjie.modules.system.service.dto.RoleSmallDTO
;
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
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -16,95 +15,29 @@ import java.util.Set;
* @author Zheng Jie
* @date 2018-12-03
*/
@CacheConfig
(
cacheNames
=
"role"
)
public
interface
RoleService
{
/**
* get
* @param id
* @return
*/
@Cacheable
(
key
=
"#p0"
)
RoleDTO
findById
(
long
id
);
/**
* create
* @param resources
* @return
*/
@CacheEvict
(
allEntries
=
true
)
RoleDTO
create
(
Role
resources
);
/**
* update
* @param resources
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
Role
resources
);
/**
* delete
* @param id
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
/**
* key的名称如有修改,请同步修改 UserServiceImpl 中的 update 方法
* findByUsers_Id
* @param id
* @return
*/
@Cacheable
(
key
=
"'findByUsers_Id:' + #p0"
)
List
<
RoleSmallDTO
>
findByUsers_Id
(
Long
id
);
@Cacheable
Integer
findByRoles
(
Set
<
Role
>
roles
);
/**
* updatePermission
* @param resources
* @param roleDTO
*/
@CacheEvict
(
allEntries
=
true
)
void
updatePermission
(
Role
resources
,
RoleDTO
roleDTO
);
/**
* updateMenu
* @param resources
* @param roleDTO
*/
@CacheEvict
(
allEntries
=
true
)
void
updateMenu
(
Role
resources
,
RoleDTO
roleDTO
);
@CacheEvict
(
allEntries
=
true
)
void
untiedMenu
(
Long
id
);
/**
* queryAll
* @param pageable
* @return
*/
@Cacheable
Object
queryAll
(
Pageable
pageable
);
/**
* queryAll
* @param pageable
* @param criteria
* @return
*/
@Cacheable
Object
queryAll
(
RoleQueryCriteria
criteria
,
Pageable
pageable
);
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
List
<
RoleDTO
>
queryAll
(
RoleQueryCriteria
criteria
);
@CacheEvict
(
allEntries
=
true
)
void
untiedPermission
(
Long
id
);
void
download
(
List
<
RoleDTO
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
;
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service
;
import
me.zhengjie.modules.system.domain.User
;
import
me.zhengjie.modules.security.security.JwtUser
;
import
me.zhengjie.modules.system.service.dto.UserDTO
;
import
me.zhengjie.modules.system.service.dto.UserQueryCriteria
;
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
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
...
...
@@ -18,74 +13,26 @@ import java.util.List;
* @author Zheng Jie
* @date 2018-11-23
*/
@CacheConfig
(
cacheNames
=
"user"
)
public
interface
UserService
{
/**
* get
* @param id
* @return
*/
@Cacheable
(
key
=
"#p0"
)
UserDTO
findById
(
long
id
);
/**
* create
* @param resources
* @return
*/
@CacheEvict
(
allEntries
=
true
)
UserDTO
create
(
User
resources
);
/**
* update
* @param resources
*/
@CacheEvict
(
allEntries
=
true
)
void
update
(
User
resources
);
/**
* delete
* @param id
*/
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
/**
* findByName
* @param userName
* @return
*/
@Cacheable
(
key
=
"'loadUserByUsername:'+#p0"
)
UserDTO
findByName
(
String
userName
);
/**
* 修改密码
* @param username
* @param encryptPassword
*/
@CacheEvict
(
allEntries
=
true
)
void
updatePass
(
String
username
,
String
encryptPassword
);
/**
* 修改头像
* @param file
*/
@CacheEvict
(
allEntries
=
true
)
void
updateAvatar
(
MultipartFile
file
);
/**
* 修改邮箱
* @param username
* @param email
*/
@CacheEvict
(
allEntries
=
true
)
void
updateEmail
(
String
username
,
String
email
);
@Cacheable
Object
queryAll
(
UserQueryCriteria
criteria
,
Pageable
pageable
);
@Cacheable
List
<
UserDTO
>
queryAll
(
UserQueryCriteria
criteria
);
void
download
(
List
<
UserDTO
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptDTO.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.dto
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.
Data
;
import
lombok.
Getter
;
import
lombok.Setter
;
import
javax.validation.constraints.NotNull
;
import
java.sql.Timestamp
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.List
;
/**
* @author Zheng Jie
* @date 2019-03-25
*/
@Data
@Getter
@Setter
public
class
DeptDTO
implements
Serializable
{
/**
* ID
*/
// ID
private
Long
id
;
/**
* 名称
*/
// 名称
private
String
name
;
@NotNull
private
Boolean
enabled
;
/**
* 上级部门
*/
// 上级部门
private
Long
pid
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptQueryCriteria.java
View file @
fd9fb2a6
...
...
@@ -2,6 +2,8 @@ package me.zhengjie.modules.system.service.dto;
import
lombok.Data
;
import
me.zhengjie.annotation.Query
;
import
java.sql.Timestamp
;
import
java.util.Set
;
/**
...
...
@@ -22,4 +24,10 @@ public class DeptQueryCriteria{
@Query
private
Long
pid
;
@Query
(
type
=
Query
.
Type
.
GREATER_THAN
,
propName
=
"createTime"
)
private
Timestamp
startTime
;
@Query
(
type
=
Query
.
Type
.
LESS_THAN
,
propName
=
"createTime"
)
private
Timestamp
endTime
;
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptSmallDTO.java
View file @
fd9fb2a6
...
...
@@ -10,13 +10,7 @@ import java.io.Serializable;
@Data
public
class
DeptSmallDTO
implements
Serializable
{
/**
* ID
*/
private
Long
id
;
/**
* 名称
*/
private
String
name
;
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDTO.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.dto
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.List
;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Data
@Getter
@Setter
public
class
DictDTO
implements
Serializable
{
private
Long
id
;
/**
* 字典名称
*/
private
String
name
;
/**
* 描述
*/
private
String
remark
;
private
List
<
DictDetailDTO
>
dictDetails
;
private
Timestamp
createTime
;
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDetailDTO.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.service.dto
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Data
@Getter
@Setter
public
class
DictDetailDTO
implements
Serializable
{
private
Long
id
;
/**
* 字典标签
*/
private
String
label
;
/**
* 字典值
*/
private
String
value
;
/**
* 排序
*/
private
String
sort
;
private
Timestamp
createTime
;
}
\ No newline at end of file
Prev
1
…
3
4
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