Commit e1366ee4 authored by dqjdda's avatar dqjdda
Browse files

菜单修改

parent cad0c08c
......@@ -42,14 +42,14 @@ import java.util.Map;
public class RedisConfig extends CachingConfigurerSupport {
/**
* 设置 redis 数据默认过期时间,默认1天
* 设置 redis 数据默认过期时间,默认6小时
* 设置@cacheable 序列化方式
*/
@Bean
public RedisCacheConfiguration redisCacheConfiguration(){
FastJsonRedisSerializer<Object> fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class);
RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig();
configuration = configuration.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer)).entryTtl(Duration.ofDays(1));
configuration = configuration.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer)).entryTtl(Duration.ofHours(6));
return configuration;
}
......
......@@ -31,7 +31,7 @@ public class LogController {
@GetMapping
@ApiOperation("日志查询")
@PreAuthorize("hasAnyRole('ADMIN')")
@PreAuthorize("hasAnyRole('admin')")
public ResponseEntity getLogs(LogQueryCriteria criteria, Pageable pageable){
criteria.setLogType("INFO");
return new ResponseEntity<>(logService.queryAll(criteria,pageable), HttpStatus.OK);
......@@ -47,7 +47,7 @@ public class LogController {
@GetMapping(value = "/error")
@ApiOperation("错误日志查询")
@PreAuthorize("hasAnyRole('ADMIN')")
@PreAuthorize("hasAnyRole('admin')")
public ResponseEntity getErrorLogs(LogQueryCriteria criteria, Pageable pageable){
criteria.setLogType("ERROR");
return new ResponseEntity<>(logService.queryAll(criteria,pageable), HttpStatus.OK);
......@@ -55,7 +55,7 @@ public class LogController {
@GetMapping(value = "/error/{id}")
@ApiOperation("日志异常详情查询")
@PreAuthorize("hasAnyRole('ADMIN')")
@PreAuthorize("hasAnyRole('admin')")
public ResponseEntity getErrorLogs(@PathVariable Long id){
return new ResponseEntity<>(logService.findByErrDetail(id), HttpStatus.OK);
}
......
......@@ -29,7 +29,7 @@ public class RedisController {
@Log("查询Redis缓存")
@GetMapping
@ApiOperation("查询Redis缓存")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_SELECT')")
@PreAuthorize("hasAnyRole('admin','REDIS_ALL','REDIS_SELECT')")
public ResponseEntity getRedis(String key, Pageable pageable){
return new ResponseEntity<>(redisService.findByKey(key,pageable), HttpStatus.OK);
}
......@@ -37,7 +37,7 @@ public class RedisController {
@Log("删除Redis缓存")
@DeleteMapping
@ApiOperation("删除Redis缓存")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_DELETE')")
@PreAuthorize("hasAnyRole('admin','REDIS_ALL','REDIS_DELETE')")
public ResponseEntity delete(@RequestBody RedisVo resources){
redisService.delete(resources.getKey());
return new ResponseEntity(HttpStatus.OK);
......@@ -46,7 +46,7 @@ public class RedisController {
@Log("清空Redis缓存")
@DeleteMapping(value = "/all")
@ApiOperation("清空Redis缓存")
@PreAuthorize("hasAnyRole('ADMIN','REDIS_ALL','REDIS_DELETE')")
@PreAuthorize("hasAnyRole('admin','REDIS_ALL','REDIS_DELETE')")
public ResponseEntity deleteAll(){
redisService.deleteAll();
return new ResponseEntity(HttpStatus.OK);
......
......@@ -36,14 +36,14 @@ public class QuartzJobController {
@Log("查询定时任务")
@ApiOperation("查询定时任务")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_SELECT')")
@PreAuthorize("hasAnyRole('admin','JOB_ALL','JOB_SELECT')")
public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(quartzJobService.queryAll(criteria,pageable), HttpStatus.OK);
}
@ApiOperation("查询任务执行日志")
@GetMapping(value = "/logs")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_SELECT')")
@PreAuthorize("hasAnyRole('admin','JOB_ALL','JOB_SELECT')")
public ResponseEntity getJobLogs(JobQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(quartzJobService.queryAllLog(criteria,pageable), HttpStatus.OK);
}
......@@ -51,7 +51,7 @@ public class QuartzJobController {
@Log("新增定时任务")
@ApiOperation("新增定时任务")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_CREATE')")
@PreAuthorize("hasAnyRole('admin','JOB_ALL','JOB_CREATE')")
public ResponseEntity create(@Validated @RequestBody QuartzJob resources){
if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
......@@ -62,7 +62,7 @@ public class QuartzJobController {
@Log("修改定时任务")
@ApiOperation("修改定时任务")
@PutMapping
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_EDIT')")
@PreAuthorize("hasAnyRole('admin','JOB_ALL','JOB_EDIT')")
public ResponseEntity update(@Validated(QuartzJob.Update.class) @RequestBody QuartzJob resources){
quartzJobService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -71,7 +71,7 @@ public class QuartzJobController {
@Log("更改定时任务状态")
@ApiOperation("更改定时任务状态")
@PutMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_EDIT')")
@PreAuthorize("hasAnyRole('admin','JOB_ALL','JOB_EDIT')")
public ResponseEntity updateIsPause(@PathVariable Long id){
quartzJobService.updateIsPause(quartzJobService.findById(id));
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -80,7 +80,7 @@ public class QuartzJobController {
@Log("执行定时任务")
@ApiOperation("执行定时任务")
@PutMapping(value = "/exec/{id}")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_EDIT')")
@PreAuthorize("hasAnyRole('admin','JOB_ALL','JOB_EDIT')")
public ResponseEntity execution(@PathVariable Long id){
quartzJobService.execution(quartzJobService.findById(id));
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -89,7 +89,7 @@ public class QuartzJobController {
@Log("删除定时任务")
@ApiOperation("删除定时任务")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','JOB_ALL','JOB_DELETE')")
@PreAuthorize("hasAnyRole('admin','JOB_ALL','JOB_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
quartzJobService.delete(quartzJobService.findById(id));
return new ResponseEntity(HttpStatus.OK);
......
......@@ -30,15 +30,21 @@ public class Menu{
private String name;
@Column(unique = true)
@NotNull
private Long sort;
private Long sort = 999L;
@NotBlank
@Column(name = "path")
private String path;
private String component;
// 类型
@Column(name = "type")
private Integer type;
// 权限
@Column(name = "permission")
private String permission;
@Column(unique = true,name = "component_name")
private String componentName;
......
......@@ -42,6 +42,10 @@ public class Role{
@Column
private String remark;
// 权限
@Column(name = "permission")
private String permission;
@JsonIgnore
@ManyToMany(mappedBy = "roles")
private Set<User> users;
......
......@@ -18,5 +18,5 @@ public interface MenuRepository extends JpaRepository<Menu, Long>, JpaSpecificat
List<Menu> findByPid(long pid);
LinkedHashSet<Menu> findByRoles_IdOrderBySortAsc(Long id);
LinkedHashSet<Menu> findByRoles_IdAndTypeIsNotInOrderBySortAsc(Long id, Integer type);
}
......@@ -40,7 +40,7 @@ public class DeptController {
@Log("查询部门")
@ApiOperation("查询部门")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT','DEPT_ALL','DEPT_SELECT')")
@PreAuthorize("hasAnyRole('admin','user:all','user:select','DEPT_ALL','DEPT_SELECT')")
public ResponseEntity getDepts(DeptQueryCriteria criteria){
// 数据权限
criteria.setIds(dataScope.getDeptIds());
......@@ -51,7 +51,7 @@ public class DeptController {
@Log("新增部门")
@ApiOperation("新增部门")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','DEPT_ALL','DEPT_CREATE')")
@PreAuthorize("hasAnyRole('admin','DEPT_ALL','DEPT_CREATE')")
public ResponseEntity create(@Validated @RequestBody Dept resources){
if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
......@@ -62,7 +62,7 @@ public class DeptController {
@Log("修改部门")
@ApiOperation("修改部门")
@PutMapping
@PreAuthorize("hasAnyRole('ADMIN','DEPT_ALL','DEPT_EDIT')")
@PreAuthorize("hasAnyRole('admin','DEPT_ALL','DEPT_EDIT')")
public ResponseEntity update(@Validated(Dept.Update.class) @RequestBody Dept resources){
deptService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -71,7 +71,7 @@ public class DeptController {
@Log("删除部门")
@ApiOperation("删除部门")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','DEPT_ALL','DEPT_DELETE')")
@PreAuthorize("hasAnyRole('admin','DEPT_ALL','DEPT_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
try {
deptService.delete(id);
......
......@@ -34,7 +34,7 @@ public class DictController {
@Log("查询字典")
@ApiOperation("查询字典")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_SELECT')")
@PreAuthorize("hasAnyRole('admin','DICT_ALL','DICT_SELECT')")
public ResponseEntity getDicts(DictQueryCriteria resources, Pageable pageable){
return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK);
}
......@@ -42,7 +42,7 @@ public class DictController {
@Log("新增字典")
@ApiOperation("新增字典")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_CREATE')")
@PreAuthorize("hasAnyRole('admin','DICT_ALL','DICT_CREATE')")
public ResponseEntity create(@Validated @RequestBody Dict resources){
if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
......@@ -53,7 +53,7 @@ public class DictController {
@Log("修改字典")
@ApiOperation("修改字典")
@PutMapping
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_EDIT')")
@PreAuthorize("hasAnyRole('admin','DICT_ALL','DICT_EDIT')")
public ResponseEntity update(@Validated(Dict.Update.class) @RequestBody Dict resources){
dictService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -62,7 +62,7 @@ public class DictController {
@Log("删除字典")
@ApiOperation("删除字典")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_DELETE')")
@PreAuthorize("hasAnyRole('admin','DICT_ALL','DICT_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
dictService.delete(id);
return new ResponseEntity(HttpStatus.OK);
......
......@@ -60,7 +60,7 @@ public class DictDetailController {
@Log("新增字典详情")
@ApiOperation("新增字典详情")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_CREATE')")
@PreAuthorize("hasAnyRole('admin','DICT_ALL','DICT_CREATE')")
public ResponseEntity create(@Validated @RequestBody DictDetail resources){
if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
......@@ -71,7 +71,7 @@ public class DictDetailController {
@Log("修改字典详情")
@ApiOperation("修改字典详情")
@PutMapping
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_EDIT')")
@PreAuthorize("hasAnyRole('admin','DICT_ALL','DICT_EDIT')")
public ResponseEntity update(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources){
dictDetailService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -80,7 +80,7 @@ public class DictDetailController {
@Log("删除字典详情")
@ApiOperation("删除字典详情")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_DELETE')")
@PreAuthorize("hasAnyRole('admin','DICT_ALL','DICT_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
dictDetailService.delete(id);
return new ResponseEntity(HttpStatus.OK);
......
......@@ -39,7 +39,7 @@ public class JobController {
@Log("查询岗位")
@ApiOperation("查询岗位")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_SELECT','USER_ALL','USER_SELECT')")
@PreAuthorize("hasAnyRole('admin','USERJOB_ALL','USERJOB_SELECT','user:all','user:select')")
public ResponseEntity getJobs(JobQueryCriteria criteria,
Pageable pageable){
// 数据权限
......@@ -50,7 +50,7 @@ public class JobController {
@Log("新增岗位")
@ApiOperation("新增岗位")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_CREATE')")
@PreAuthorize("hasAnyRole('admin','USERJOB_ALL','USERJOB_CREATE')")
public ResponseEntity create(@Validated @RequestBody Job resources){
if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
......@@ -61,7 +61,7 @@ public class JobController {
@Log("修改岗位")
@ApiOperation("修改岗位")
@PutMapping
@PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_EDIT')")
@PreAuthorize("hasAnyRole('admin','USERJOB_ALL','USERJOB_EDIT')")
public ResponseEntity update(@Validated(Job.Update.class) @RequestBody Job resources){
jobService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -70,7 +70,7 @@ public class JobController {
@Log("删除岗位")
@ApiOperation("删除岗位")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_DELETE')")
@PreAuthorize("hasAnyRole('admin','USERJOB_ALL','USERJOB_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
try {
jobService.delete(id);
......
......@@ -45,7 +45,7 @@ public class MenuController {
this.roleService = roleService;
}
@ApiOperation("获取菜单")
@ApiOperation("获取前端所需菜单")
@GetMapping(value = "/build")
public ResponseEntity buildMenus(){
UserDTO user = userService.findByName(SecurityUtils.getUsername());
......@@ -56,7 +56,7 @@ public class MenuController {
@ApiOperation("返回全部的菜单")
@GetMapping(value = "/tree")
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_CREATE','MENU_EDIT','ROLES_SELECT','ROLES_ALL')")
@PreAuthorize("hasAnyRole('admin','MENU_ALL','MENU_CREATE','MENU_EDIT','ROLES_SELECT','ROLES_ALL')")
public ResponseEntity getMenuTree(){
return new ResponseEntity<>(menuService.getMenuTree(menuService.findByPid(0L)),HttpStatus.OK);
}
......@@ -64,7 +64,7 @@ public class MenuController {
@Log("查询菜单")
@ApiOperation("查询菜单")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')")
@PreAuthorize("hasAnyRole('admin','MENU_ALL','MENU_SELECT')")
public ResponseEntity getMenus(MenuQueryCriteria criteria){
List<MenuDTO> menuDTOList = menuService.queryAll(criteria);
return new ResponseEntity<>(menuService.buildTree(menuDTOList),HttpStatus.OK);
......@@ -73,7 +73,7 @@ public class MenuController {
@Log("新增菜单")
@ApiOperation("新增菜单")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_CREATE')")
@PreAuthorize("hasAnyRole('admin','MENU_ALL','MENU_CREATE')")
public ResponseEntity create(@Validated @RequestBody Menu resources){
if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
......@@ -84,7 +84,7 @@ public class MenuController {
@Log("修改菜单")
@ApiOperation("修改菜单")
@PutMapping
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_EDIT')")
@PreAuthorize("hasAnyRole('admin','MENU_ALL','MENU_EDIT')")
public ResponseEntity update(@Validated(Menu.Update.class) @RequestBody Menu resources){
menuService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -93,7 +93,7 @@ public class MenuController {
@Log("删除菜单")
@ApiOperation("删除菜单")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_DELETE')")
@PreAuthorize("hasAnyRole('admin','MENU_ALL','MENU_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
List<Menu> menuList = menuService.findByPid(id);
Set<Menu> menuSet = new HashSet<>();
......
......@@ -40,7 +40,7 @@ public class PermissionController {
@ApiOperation("返回全部的权限,新增角色时下拉选择")
@GetMapping(value = "/tree")
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_CREATE','PERMISSION_EDIT','ROLES_SELECT','ROLES_ALL')")
@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);
}
......@@ -48,7 +48,7 @@ public class PermissionController {
@Log("查询权限")
@ApiOperation("查询权限")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')")
@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);
......@@ -57,7 +57,7 @@ public class PermissionController {
@Log("新增权限")
@ApiOperation("新增权限")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_CREATE')")
@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");
......@@ -68,7 +68,7 @@ public class PermissionController {
@Log("修改权限")
@ApiOperation("修改权限")
@PutMapping
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_EDIT')")
@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);
......@@ -77,7 +77,7 @@ public class PermissionController {
@Log("删除权限")
@ApiOperation("删除权限")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_DELETE')")
@PreAuthorize("hasAnyRole('admin','PERMISSION_ALL','PERMISSION_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
List<Permission> permissions = permissionService.findByPid(id);
Set<Permission> permissionSet = new HashSet<>();
......
......@@ -42,14 +42,14 @@ public class RoleController {
@ApiOperation("获取单个role")
@GetMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')")
@PreAuthorize("hasAnyRole('admin','ROLES_ALL','ROLES_SELECT')")
public ResponseEntity getRoles(@PathVariable Long id){
return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK);
}
@ApiOperation("返回全部的角色")
@GetMapping(value = "/all")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','USER_ALL','USER_CREATE','USER_EDIT')")
@PreAuthorize("hasAnyRole('admin','ROLES_ALL','user:all','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);
}
......@@ -57,7 +57,7 @@ public class RoleController {
@Log("查询角色")
@ApiOperation("查询角色")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')")
@PreAuthorize("hasAnyRole('admin','ROLES_ALL','ROLES_SELECT')")
public ResponseEntity getRoles(RoleQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(roleService.queryAll(criteria,pageable),HttpStatus.OK);
}
......@@ -72,7 +72,7 @@ public class RoleController {
@Log("新增角色")
@ApiOperation("新增角色")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_CREATE')")
@PreAuthorize("hasAnyRole('admin','ROLES_ALL','ROLES_CREATE')")
public ResponseEntity create(@Validated @RequestBody Role resources){
if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
......@@ -83,7 +83,7 @@ public class RoleController {
@Log("修改角色")
@ApiOperation("修改角色")
@PutMapping
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')")
@PreAuthorize("hasAnyRole('admin','ROLES_ALL','ROLES_EDIT')")
public ResponseEntity update(@Validated(Role.Update.class) @RequestBody Role resources){
roleService.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -92,7 +92,7 @@ public class RoleController {
@Log("修改角色权限")
@ApiOperation("修改角色权限")
@PutMapping(value = "/permission")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')")
@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);
......@@ -101,7 +101,7 @@ public class RoleController {
@Log("修改角色菜单")
@ApiOperation("修改角色菜单")
@PutMapping(value = "/menu")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')")
@PreAuthorize("hasAnyRole('admin','ROLES_ALL','ROLES_EDIT')")
public ResponseEntity updateMenu(@RequestBody Role resources){
roleService.updateMenu(resources,roleService.findById(resources.getId()));
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -110,7 +110,7 @@ public class RoleController {
@Log("删除角色")
@ApiOperation("删除角色")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_DELETE')")
@PreAuthorize("hasAnyRole('admin','ROLES_ALL','ROLES_DELETE')")
public ResponseEntity delete(@PathVariable Long id){
try {
roleService.delete(id);
......
......@@ -60,7 +60,7 @@ public class UserController {
@Log("导出用户数据")
@ApiOperation("导出用户数据")
@GetMapping(value = "/download")
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')")
@PreAuthorize("hasAnyRole('admin','user:all','user:select')")
public void update(HttpServletResponse response, UserQueryCriteria criteria) throws IOException {
userService.download(userService.queryAll(criteria), response);
}
......@@ -68,7 +68,7 @@ public class UserController {
@Log("查询用户")
@ApiOperation("查询用户")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')")
@PreAuthorize("hasAnyRole('admin','user:all','user:select')")
public ResponseEntity getUsers(UserQueryCriteria criteria, Pageable pageable){
Set<Long> deptSet = new HashSet<>();
Set<Long> result = new HashSet<>();
......@@ -105,7 +105,7 @@ public class UserController {
@Log("新增用户")
@ApiOperation("新增用户")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_CREATE')")
@PreAuthorize("hasAnyRole('admin','user:all','user:add')")
public ResponseEntity create(@Validated @RequestBody User resources){
checkLevel(resources);
return new ResponseEntity<>(userService.create(resources),HttpStatus.CREATED);
......@@ -114,7 +114,7 @@ public class UserController {
@Log("修改用户")
@ApiOperation("修改用户")
@PutMapping
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_EDIT')")
@PreAuthorize("hasAnyRole('admin','user:all','user:edit')")
public ResponseEntity update(@Validated(User.Update.class) @RequestBody User resources){
checkLevel(resources);
userService.update(resources);
......@@ -124,7 +124,7 @@ public class UserController {
@Log("删除用户")
@ApiOperation("删除用户")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_DELETE')")
@PreAuthorize("hasAnyRole('admin','user:all','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()));
......
......@@ -16,6 +16,10 @@ public class MenuDTO{
private Long id;
private Integer type;
private String permission;
private String name;
private Long sort;
......
......@@ -24,6 +24,8 @@ public class RoleDTO{
private String remark;
private String permission;
private Set<PermissionDTO> permissions;
private Set<MenuDTO> menus;
......
......@@ -47,8 +47,8 @@ public class MenuServiceImpl implements MenuService {
@Override
@Cacheable
public List<MenuDTO> queryAll(MenuQueryCriteria criteria){
Sort sort = new Sort(Sort.Direction.DESC,"id");
return menuMapper.toDto(menuRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),sort));
// Sort sort = new Sort(Sort.Direction.DESC,"id");
return menuMapper.toDto(menuRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
......@@ -63,7 +63,7 @@ public class MenuServiceImpl implements MenuService {
public List<MenuDTO> findByRoles(List<RoleSmallDTO> roles) {
Set<Menu> menus = new LinkedHashSet<>();
for (RoleSmallDTO role : roles) {
List<Menu> menus1 = new ArrayList<>(menuRepository.findByRoles_IdOrderBySortAsc(role.getId()));
List<Menu> menus1 = new ArrayList<>(menuRepository.findByRoles_IdAndTypeIsNotInOrderBySortAsc(role.getId(), 2));
menus.addAll(menus1);
}
return menus.stream().map(menuMapper::toDto).collect(Collectors.toList());
......@@ -124,6 +124,8 @@ public class MenuServiceImpl implements MenuService {
menu.setCache(resources.getCache());
menu.setHidden(resources.getHidden());
menu.setComponentName(resources.getComponentName());
menu.setPermission(resources.getPermission());
menu.setType(resources.getType());
menuRepository.save(menu);
}
......
......@@ -44,8 +44,8 @@ public class PermissionServiceImpl implements PermissionService {
@Override
@Cacheable
public List<PermissionDTO> queryAll(PermissionQueryCriteria criteria) {
Sort sort = new Sort(Sort.Direction.DESC,"id");
return permissionMapper.toDto(permissionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),sort));
// Sort sort = new Sort(Sort.Direction.DESC,"id");
return permissionMapper.toDto(permissionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
......
......@@ -30,7 +30,7 @@ public class ${className}Controller {
@GetMapping
@Log("查询${className}")
@ApiOperation("查询${className}")
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_SELECT')")
@PreAuthorize("hasAnyRole('admin','${upperCaseClassName}_ALL','${upperCaseClassName}_SELECT')")
public ResponseEntity get${className}s(${className}QueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK);
}
......@@ -38,7 +38,7 @@ public class ${className}Controller {
@PostMapping
@Log("新增${className}")
@ApiOperation("新增${className}")
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_CREATE')")
@PreAuthorize("hasAnyRole('admin','${upperCaseClassName}_ALL','${upperCaseClassName}_CREATE')")
public ResponseEntity create(@Validated @RequestBody ${className} resources){
return new ResponseEntity<>(${changeClassName}Service.create(resources),HttpStatus.CREATED);
}
......@@ -46,7 +46,7 @@ public class ${className}Controller {
@PutMapping
@Log("修改${className}")
@ApiOperation("修改${className}")
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT')")
@PreAuthorize("hasAnyRole('admin','${upperCaseClassName}_ALL','${upperCaseClassName}_EDIT')")
public ResponseEntity update(@Validated @RequestBody ${className} resources){
${changeClassName}Service.update(resources);
return new ResponseEntity(HttpStatus.NO_CONTENT);
......@@ -55,7 +55,7 @@ public class ${className}Controller {
@DeleteMapping(value = "/{${pkChangeColName}}")
@Log("删除${className}")
@ApiOperation("删除${className}")
@PreAuthorize("hasAnyRole('ADMIN','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE')")
@PreAuthorize("hasAnyRole('admin','${upperCaseClassName}_ALL','${upperCaseClassName}_DELETE')")
public ResponseEntity delete(@PathVariable ${pkColumnType} ${pkChangeColName}){
${changeClassName}Service.delete(${pkChangeColName});
return new ResponseEntity(HttpStatus.OK);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment