Commit bf7c1eeb authored by dqjdda's avatar dqjdda
Browse files

代码优化完成,去除大量idea警告,代码生成器优化等

parent e3c3ebb1
package me.zhengjie.modules.system.rest; 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.aop.log.Log;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.DictDetail; import me.zhengjie.modules.system.domain.DictDetail;
...@@ -25,47 +27,55 @@ import java.util.stream.Collectors; ...@@ -25,47 +27,55 @@ import java.util.stream.Collectors;
* @date 2019-04-10 * @date 2019-04-10
*/ */
@RestController @RestController
@RequestMapping("api") @Api(tags = "系统:字典详情管理")
@RequestMapping("/api/dictDetail")
public class DictDetailController { public class DictDetailController {
@Autowired private final DictDetailService dictDetailService;
private DictDetailService dictDetailService;
private static final String ENTITY_NAME = "dictDetail"; private static final String ENTITY_NAME = "dictDetail";
public DictDetailController(DictDetailService dictDetailService) {
this.dictDetailService = dictDetailService;
}
@Log("查询字典详情") @Log("查询字典详情")
@GetMapping(value = "/dictDetail") @ApiOperation("查询字典详情")
@GetMapping
public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria, public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria,
@PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){ @PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
String[] names = criteria.getDictName().split(","); String[] names = criteria.getDictName().split(",");
return new ResponseEntity(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
} }
@Log("查询多个字典详情") @Log("查询多个字典详情")
@GetMapping(value = "/dictDetail/map") @ApiOperation("查询多个字典详情")
@GetMapping(value = "/map")
public ResponseEntity getDictDetailMaps(DictDetailQueryCriteria criteria, public ResponseEntity getDictDetailMaps(DictDetailQueryCriteria criteria,
@PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){ @PageableDefault(value = 10, sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
String[] names = criteria.getDictName().split(","); String[] names = criteria.getDictName().split(",");
Map map = new HashMap(names.length); Map<String,Object> map = new HashMap<>(names.length);
for (String name : names) { for (String name : names) {
criteria.setDictName(name); criteria.setDictName(name);
map.put(name,dictDetailService.queryAll(criteria,pageable).get("content")); map.put(name,dictDetailService.queryAll(criteria,pageable).get("content"));
} }
return new ResponseEntity(map,HttpStatus.OK); return new ResponseEntity<>(map,HttpStatus.OK);
} }
@Log("新增字典详情") @Log("新增字典详情")
@PostMapping(value = "/dictDetail") @ApiOperation("新增字典详情")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_CREATE')") @PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_CREATE')")
public ResponseEntity create(@Validated @RequestBody DictDetail resources){ public ResponseEntity create(@Validated @RequestBody DictDetail resources){
if (resources.getId() != null) { if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); 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("修改字典详情") @Log("修改字典详情")
@PutMapping(value = "/dictDetail") @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){ public ResponseEntity update(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources){
dictDetailService.update(resources); dictDetailService.update(resources);
...@@ -73,7 +83,8 @@ public class DictDetailController { ...@@ -73,7 +83,8 @@ public class DictDetailController {
} }
@Log("删除字典详情") @Log("删除字典详情")
@DeleteMapping(value = "/dictDetail/{id}") @ApiOperation("删除字典详情")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_DELETE')") @PreAuthorize("hasAnyRole('ADMIN','DICT_ALL','DICT_DELETE')")
public ResponseEntity delete(@PathVariable Long id){ public ResponseEntity delete(@PathVariable Long id){
dictDetailService.delete(id); dictDetailService.delete(id);
......
package me.zhengjie.modules.system.rest; 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.aop.log.Log;
import me.zhengjie.config.DataScope; import me.zhengjie.config.DataScope;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
...@@ -21,40 +23,47 @@ import java.util.Set; ...@@ -21,40 +23,47 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2019-03-29 * @date 2019-03-29
*/ */
@Api(tags = "系统:岗位管理")
@RestController @RestController
@RequestMapping("api") @RequestMapping("/api/job")
public class JobController { public class JobController {
@Autowired private final JobService jobService;
private JobService jobService;
@Autowired private final DataScope dataScope;
private DataScope dataScope;
private static final String ENTITY_NAME = "job"; private static final String ENTITY_NAME = "job";
public JobController(JobService jobService, DataScope dataScope) {
this.jobService = jobService;
this.dataScope = dataScope;
}
@Log("查询岗位") @Log("查询岗位")
@GetMapping(value = "/job") @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, public ResponseEntity getJobs(JobQueryCriteria criteria,
Pageable pageable){ Pageable pageable){
// 数据权限 // 数据权限
criteria.setDeptIds(dataScope.getDeptIds()); criteria.setDeptIds(dataScope.getDeptIds());
return new ResponseEntity(jobService.queryAll(criteria, pageable),HttpStatus.OK); return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK);
} }
@Log("新增岗位") @Log("新增岗位")
@PostMapping(value = "/job") @ApiOperation("新增岗位")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_CREATE')") @PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_CREATE')")
public ResponseEntity create(@Validated @RequestBody Job resources){ public ResponseEntity create(@Validated @RequestBody Job resources){
if (resources.getId() != null) { if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); 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("修改岗位") @Log("修改岗位")
@PutMapping(value = "/job") @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){ public ResponseEntity update(@Validated(Job.Update.class) @RequestBody Job resources){
jobService.update(resources); jobService.update(resources);
...@@ -62,7 +71,8 @@ public class JobController { ...@@ -62,7 +71,8 @@ public class JobController {
} }
@Log("删除岗位") @Log("删除岗位")
@DeleteMapping(value = "/job/{id}") @ApiOperation("删除岗位")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_DELETE')") @PreAuthorize("hasAnyRole('ADMIN','USERJOB_ALL','USERJOB_DELETE')")
public ResponseEntity delete(@PathVariable Long id){ public ResponseEntity delete(@PathVariable Long id){
try { try {
......
package me.zhengjie.modules.system.rest; 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.aop.log.Log;
import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
...@@ -10,7 +12,6 @@ import me.zhengjie.modules.system.service.dto.MenuDTO; ...@@ -10,7 +12,6 @@ import me.zhengjie.modules.system.service.dto.MenuDTO;
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria; import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
import me.zhengjie.modules.system.service.dto.UserDTO; import me.zhengjie.modules.system.service.dto.UserDTO;
import me.zhengjie.utils.SecurityUtils; import me.zhengjie.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -24,63 +25,63 @@ import java.util.Set; ...@@ -24,63 +25,63 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-03 * @date 2018-12-03
*/ */
@Api(tags = "系统:菜单管理")
@RestController @RestController
@RequestMapping("api") @RequestMapping("/api/menus")
public class MenuController { public class MenuController {
@Autowired private final MenuService menuService;
private MenuService menuService;
@Autowired private final UserService userService;
private UserService userService;
@Autowired private final RoleService roleService;
private RoleService roleService;
private static final String ENTITY_NAME = "menu"; private static final String ENTITY_NAME = "menu";
/** public MenuController(MenuService menuService, UserService userService, RoleService roleService) {
* 构建前端路由所需要的菜单 this.menuService = menuService;
* @return this.userService = userService;
*/ this.roleService = roleService;
@GetMapping(value = "/menus/build") }
@ApiOperation("获取菜单树")
@GetMapping(value = "/build")
public ResponseEntity buildMenus(){ public ResponseEntity buildMenus(){
UserDTO user = userService.findByName(SecurityUtils.getUsername()); UserDTO user = userService.findByName(SecurityUtils.getUsername());
List<MenuDTO> menuDTOList = menuService.findByRoles(roleService.findByUsers_Id(user.getId())); List<MenuDTO> menuDTOList = menuService.findByRoles(roleService.findByUsers_Id(user.getId()));
List<MenuDTO> menuDTOTree = (List<MenuDTO>)menuService.buildTree(menuDTOList).get("content"); return new ResponseEntity<>(menuService.buildMenus((List<MenuDTO>) menuService.buildTree(menuDTOList).get("content")),HttpStatus.OK);
return new ResponseEntity(menuService.buildMenus(menuDTOTree),HttpStatus.OK);
} }
/** @ApiOperation("返回全部的菜单")
* 返回全部的菜单 @GetMapping(value = "/tree")
* @return
*/
@GetMapping(value = "/menus/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(){ public ResponseEntity getMenuTree(){
return new ResponseEntity(menuService.getMenuTree(menuService.findByPid(0L)),HttpStatus.OK); return new ResponseEntity<>(menuService.getMenuTree(menuService.findByPid(0L)),HttpStatus.OK);
} }
@Log("查询菜单") @Log("查询菜单")
@GetMapping(value = "/menus") @ApiOperation("查询菜单")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_SELECT')")
public ResponseEntity getMenus(MenuQueryCriteria criteria){ public ResponseEntity getMenus(MenuQueryCriteria criteria){
List<MenuDTO> menuDTOList = menuService.queryAll(criteria); List<MenuDTO> menuDTOList = menuService.queryAll(criteria);
return new ResponseEntity(menuService.buildTree(menuDTOList),HttpStatus.OK); return new ResponseEntity<>(menuService.buildTree(menuDTOList),HttpStatus.OK);
} }
@Log("新增菜单") @Log("新增菜单")
@PostMapping(value = "/menus") @ApiOperation("新增菜单")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_CREATE')") @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_CREATE')")
public ResponseEntity create(@Validated @RequestBody Menu resources){ public ResponseEntity create(@Validated @RequestBody Menu resources){
if (resources.getId() != null) { if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); 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("修改菜单") @Log("修改菜单")
@PutMapping(value = "/menus") @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){ public ResponseEntity update(@Validated(Menu.Update.class) @RequestBody Menu resources){
menuService.update(resources); menuService.update(resources);
...@@ -88,7 +89,8 @@ public class MenuController { ...@@ -88,7 +89,8 @@ public class MenuController {
} }
@Log("删除菜单") @Log("删除菜单")
@DeleteMapping(value = "/menus/{id}") @ApiOperation("删除菜单")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_DELETE')") @PreAuthorize("hasAnyRole('ADMIN','MENU_ALL','MENU_DELETE')")
public ResponseEntity delete(@PathVariable Long id){ public ResponseEntity delete(@PathVariable Long id){
List<Menu> menuList = menuService.findByPid(id); List<Menu> menuList = menuService.findByPid(id);
......
package me.zhengjie.modules.system.rest; 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.aop.log.Log;
import me.zhengjie.modules.system.domain.Permission; import me.zhengjie.modules.system.domain.Permission;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
...@@ -7,13 +9,11 @@ import me.zhengjie.modules.system.service.PermissionService; ...@@ -7,13 +9,11 @@ import me.zhengjie.modules.system.service.PermissionService;
import me.zhengjie.modules.system.service.dto.PermissionDTO; import me.zhengjie.modules.system.service.dto.PermissionDTO;
import me.zhengjie.modules.system.service.dto.PermissionQueryCriteria; import me.zhengjie.modules.system.service.dto.PermissionQueryCriteria;
import me.zhengjie.modules.system.service.mapper.PermissionMapper; import me.zhengjie.modules.system.service.mapper.PermissionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -22,48 +22,52 @@ import java.util.Set; ...@@ -22,48 +22,52 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-03 * @date 2018-12-03
*/ */
@Api(tags = "系统:权限管理")
@RestController @RestController
@RequestMapping("api") @RequestMapping("/api/permissions")
public class PermissionController { public class PermissionController {
@Autowired private final PermissionService permissionService;
private PermissionService permissionService;
@Autowired private final PermissionMapper permissionMapper;
private PermissionMapper permissionMapper;
private static final String ENTITY_NAME = "permission"; private static final String ENTITY_NAME = "permission";
/** public PermissionController(PermissionService permissionService, PermissionMapper permissionMapper) {
* 返回全部的权限,新增角色时下拉选择 this.permissionService = permissionService;
* @return this.permissionMapper = permissionMapper;
*/ }
@GetMapping(value = "/permissions/tree")
@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(){ public ResponseEntity getTree(){
return new ResponseEntity(permissionService.getPermissionTree(permissionService.findByPid(0L)),HttpStatus.OK); return new ResponseEntity<>(permissionService.getPermissionTree(permissionService.findByPid(0L)),HttpStatus.OK);
} }
@Log("查询权限") @Log("查询权限")
@GetMapping(value = "/permissions") @ApiOperation("查询权限")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_SELECT')")
public ResponseEntity getPermissions(PermissionQueryCriteria criteria){ public ResponseEntity getPermissions(PermissionQueryCriteria criteria){
List<PermissionDTO> permissionDTOS = permissionService.queryAll(criteria); List<PermissionDTO> permissionDTOS = permissionService.queryAll(criteria);
return new ResponseEntity(permissionService.buildTree(permissionDTOS),HttpStatus.OK); return new ResponseEntity<>(permissionService.buildTree(permissionDTOS),HttpStatus.OK);
} }
@Log("新增权限") @Log("新增权限")
@PostMapping(value = "/permissions") @ApiOperation("新增权限")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_CREATE')") @PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_CREATE')")
public ResponseEntity create(@Validated @RequestBody Permission resources){ public ResponseEntity create(@Validated @RequestBody Permission resources){
if (resources.getId() != null) { if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
} }
return new ResponseEntity(permissionService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(permissionService.create(resources),HttpStatus.CREATED);
} }
@Log("修改权限") @Log("修改权限")
@PutMapping(value = "/permissions") @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){ public ResponseEntity update(@Validated(Permission.Update.class) @RequestBody Permission resources){
permissionService.update(resources); permissionService.update(resources);
...@@ -71,7 +75,8 @@ public class PermissionController { ...@@ -71,7 +75,8 @@ public class PermissionController {
} }
@Log("删除权限") @Log("删除权限")
@DeleteMapping(value = "/permissions/{id}") @ApiOperation("删除权限")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_DELETE')") @PreAuthorize("hasAnyRole('ADMIN','PERMISSION_ALL','PERMISSION_DELETE')")
public ResponseEntity delete(@PathVariable Long id){ public ResponseEntity delete(@PathVariable Long id){
List<Permission> permissions = permissionService.findByPid(id); List<Permission> permissions = permissionService.findByPid(id);
......
package me.zhengjie.modules.system.rest; package me.zhengjie.modules.system.rest;
import cn.hutool.core.lang.Dict; 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.aop.log.Log;
import me.zhengjie.modules.system.domain.Role; import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
...@@ -9,15 +11,12 @@ import me.zhengjie.modules.system.service.dto.RoleQueryCriteria; ...@@ -9,15 +11,12 @@ import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
import me.zhengjie.modules.system.service.dto.RoleSmallDTO; import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
import me.zhengjie.utils.SecurityUtils; import me.zhengjie.utils.SecurityUtils;
import me.zhengjie.utils.ThrowableUtil; 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.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.TransactionSystemException;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Collections; import java.util.Collections;
...@@ -28,61 +27,62 @@ import java.util.stream.Collectors; ...@@ -28,61 +27,62 @@ import java.util.stream.Collectors;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-03 * @date 2018-12-03
*/ */
@Api(tags = "系统:角色管理")
@RestController @RestController
@RequestMapping("api") @RequestMapping("/api/roles")
public class RoleController { public class RoleController {
@Autowired private final RoleService roleService;
private RoleService roleService;
private static final String ENTITY_NAME = "role"; private static final String ENTITY_NAME = "role";
/** public RoleController(RoleService roleService) {
* 获取单个role this.roleService = roleService;
* @param id }
* @return
*/ @ApiOperation("获取单个role")
@GetMapping(value = "/roles/{id}") @GetMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')")
public ResponseEntity getRoles(@PathVariable Long id){ public ResponseEntity getRoles(@PathVariable Long id){
return new ResponseEntity(roleService.findById(id), HttpStatus.OK); return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK);
} }
/** @ApiOperation("返回全部的角色")
* 返回全部的角色,新增用户时下拉选择 @GetMapping(value = "/all")
* @return
*/
@GetMapping(value = "/roles/all")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','USER_ALL','USER_CREATE','USER_EDIT')") @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){ 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("查询角色") @Log("查询角色")
@GetMapping(value = "/roles") @ApiOperation("查询角色")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_SELECT')")
public ResponseEntity getRoles(RoleQueryCriteria criteria, Pageable pageable){ 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(){ public ResponseEntity getLevel(){
List<Integer> levels = roleService.findByUsers_Id(SecurityUtils.getUserId()).stream().map(RoleSmallDTO::getLevel).collect(Collectors.toList()); 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("新增角色") @Log("新增角色")
@PostMapping(value = "/roles") @ApiOperation("新增角色")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_CREATE')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_CREATE')")
public ResponseEntity create(@Validated @RequestBody Role resources){ public ResponseEntity create(@Validated @RequestBody Role resources){
if (resources.getId() != null) { if (resources.getId() != null) {
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); 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("修改角色") @Log("修改角色")
@PutMapping(value = "/roles") @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){ public ResponseEntity update(@Validated(Role.Update.class) @RequestBody Role resources){
roleService.update(resources); roleService.update(resources);
...@@ -90,7 +90,8 @@ public class RoleController { ...@@ -90,7 +90,8 @@ public class RoleController {
} }
@Log("修改角色权限") @Log("修改角色权限")
@PutMapping(value = "/roles/permission") @ApiOperation("修改角色权限")
@PutMapping(value = "/permission")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')")
public ResponseEntity updatePermission(@RequestBody Role resources){ public ResponseEntity updatePermission(@RequestBody Role resources){
roleService.updatePermission(resources,roleService.findById(resources.getId())); roleService.updatePermission(resources,roleService.findById(resources.getId()));
...@@ -98,7 +99,8 @@ public class RoleController { ...@@ -98,7 +99,8 @@ public class RoleController {
} }
@Log("修改角色菜单") @Log("修改角色菜单")
@PutMapping(value = "/roles/menu") @ApiOperation("修改角色菜单")
@PutMapping(value = "/menu")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_EDIT')")
public ResponseEntity updateMenu(@RequestBody Role resources){ public ResponseEntity updateMenu(@RequestBody Role resources){
roleService.updateMenu(resources,roleService.findById(resources.getId())); roleService.updateMenu(resources,roleService.findById(resources.getId()));
...@@ -106,7 +108,8 @@ public class RoleController { ...@@ -106,7 +108,8 @@ public class RoleController {
} }
@Log("删除角色") @Log("删除角色")
@DeleteMapping(value = "/roles/{id}") @ApiOperation("删除角色")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_DELETE')") @PreAuthorize("hasAnyRole('ADMIN','ROLES_ALL','ROLES_DELETE')")
public ResponseEntity delete(@PathVariable Long id){ public ResponseEntity delete(@PathVariable Long id){
try { try {
......
package me.zhengjie.modules.system.rest; 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.aop.log.Log;
import me.zhengjie.config.DataScope; import me.zhengjie.config.DataScope;
import me.zhengjie.domain.Picture;
import me.zhengjie.domain.VerificationCode; import me.zhengjie.domain.VerificationCode;
import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.domain.User;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
...@@ -11,11 +12,9 @@ import me.zhengjie.modules.system.service.DeptService; ...@@ -11,11 +12,9 @@ import me.zhengjie.modules.system.service.DeptService;
import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.dto.RoleSmallDTO; import me.zhengjie.modules.system.service.dto.RoleSmallDTO;
import me.zhengjie.modules.system.service.dto.UserQueryCriteria; import me.zhengjie.modules.system.service.dto.UserQueryCriteria;
import me.zhengjie.service.PictureService;
import me.zhengjie.service.VerificationCodeService; import me.zhengjie.service.VerificationCodeService;
import me.zhengjie.utils.*; import me.zhengjie.utils.*;
import me.zhengjie.modules.system.service.UserService; import me.zhengjie.modules.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -35,37 +34,40 @@ import java.util.stream.Collectors; ...@@ -35,37 +34,40 @@ import java.util.stream.Collectors;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-11-23 * @date 2018-11-23
*/ */
@Api(tags = "系统:用户管理")
@RestController @RestController
@RequestMapping("api") @RequestMapping("/api/users")
public class UserController { public class UserController {
@Autowired private final UserService userService;
private UserService userService;
@Autowired private final DataScope dataScope;
private PictureService pictureService;
@Autowired private final DeptService deptService;
private DataScope dataScope;
@Autowired private final RoleService roleService;
private DeptService deptService;
@Autowired private final VerificationCodeService verificationCodeService;
private RoleService roleService;
@Autowired public UserController(UserService userService, DataScope dataScope, DeptService deptService, RoleService roleService, VerificationCodeService verificationCodeService) {
private VerificationCodeService verificationCodeService; this.userService = userService;
this.dataScope = dataScope;
this.deptService = deptService;
this.roleService = roleService;
this.verificationCodeService = verificationCodeService;
}
@Log("导出用户数据") @Log("导出用户数据")
@GetMapping(value = "/users/download") @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 { public void update(HttpServletResponse response, UserQueryCriteria criteria) throws IOException {
userService.download(userService.queryAll(criteria), response); userService.download(userService.queryAll(criteria), response);
} }
@Log("查询用户") @Log("查询用户")
@GetMapping(value = "/users") @ApiOperation("查询用户")
@GetMapping
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_SELECT')")
public ResponseEntity getUsers(UserQueryCriteria criteria, Pageable pageable){ public ResponseEntity getUsers(UserQueryCriteria criteria, Pageable pageable){
Set<Long> deptSet = new HashSet<>(); Set<Long> deptSet = new HashSet<>();
...@@ -89,27 +91,29 @@ public class UserController { ...@@ -89,27 +91,29 @@ public class UserController {
// 若无交集,则代表无数据权限 // 若无交集,则代表无数据权限
criteria.setDeptIds(result); criteria.setDeptIds(result);
if(result.size() == 0){ if(result.size() == 0){
return new ResponseEntity(PageUtil.toPage(null,0),HttpStatus.OK); return new ResponseEntity<>(PageUtil.toPage(null,0),HttpStatus.OK);
} else return new ResponseEntity(userService.queryAll(criteria,pageable),HttpStatus.OK); } else return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK);
// 否则取并集 // 否则取并集
} else { } else {
result.addAll(deptSet); result.addAll(deptSet);
result.addAll(deptIds); result.addAll(deptIds);
criteria.setDeptIds(result); criteria.setDeptIds(result);
return new ResponseEntity(userService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(userService.queryAll(criteria,pageable),HttpStatus.OK);
} }
} }
@Log("新增用户") @Log("新增用户")
@PostMapping(value = "/users") @ApiOperation("新增用户")
@PostMapping
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_CREATE')") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_CREATE')")
public ResponseEntity create(@Validated @RequestBody User resources){ public ResponseEntity create(@Validated @RequestBody User resources){
checkLevel(resources); checkLevel(resources);
return new ResponseEntity(userService.create(resources),HttpStatus.CREATED); return new ResponseEntity<>(userService.create(resources),HttpStatus.CREATED);
} }
@Log("修改用户") @Log("修改用户")
@PutMapping(value = "/users") @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){ public ResponseEntity update(@Validated(User.Update.class) @RequestBody User resources){
checkLevel(resources); checkLevel(resources);
...@@ -118,7 +122,8 @@ public class UserController { ...@@ -118,7 +122,8 @@ public class UserController {
} }
@Log("删除用户") @Log("删除用户")
@DeleteMapping(value = "/users/{id}") @ApiOperation("删除用户")
@DeleteMapping(value = "/{id}")
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_DELETE')") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_DELETE')")
public ResponseEntity delete(@PathVariable Long id){ public ResponseEntity delete(@PathVariable Long id){
Integer currentLevel = Collections.min(roleService.findByUsers_Id(SecurityUtils.getUserId()).stream().map(RoleSmallDTO::getLevel).collect(Collectors.toList())); Integer currentLevel = Collections.min(roleService.findByUsers_Id(SecurityUtils.getUserId()).stream().map(RoleSmallDTO::getLevel).collect(Collectors.toList()));
...@@ -131,12 +136,8 @@ public class UserController { ...@@ -131,12 +136,8 @@ public class UserController {
return new ResponseEntity(HttpStatus.OK); return new ResponseEntity(HttpStatus.OK);
} }
/** @ApiOperation("修改密码")
* 修改密码 @PostMapping(value = "/updatePass")
* @param user
* @return
*/
@PostMapping(value = "/users/updatePass")
public ResponseEntity updatePass(@RequestBody UserPassVo user){ public ResponseEntity updatePass(@RequestBody UserPassVo user){
UserDetails userDetails = SecurityUtils.getUserDetails(); UserDetails userDetails = SecurityUtils.getUserDetails();
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getOldPass()))){ if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getOldPass()))){
...@@ -149,25 +150,16 @@ public class UserController { ...@@ -149,25 +150,16 @@ public class UserController {
return new ResponseEntity(HttpStatus.OK); return new ResponseEntity(HttpStatus.OK);
} }
/** @ApiOperation("修改头像")
* 修改头像 @PostMapping(value = "/updateAvatar")
* @param file
* @return
*/
@PostMapping(value = "/users/updateAvatar")
public ResponseEntity updateAvatar(@RequestParam MultipartFile file){ public ResponseEntity updateAvatar(@RequestParam MultipartFile file){
userService.updateAvatar(file); userService.updateAvatar(file);
return new ResponseEntity(HttpStatus.OK); return new ResponseEntity(HttpStatus.OK);
} }
/**
* 修改邮箱
* @param user
* @param user
* @return
*/
@Log("修改邮箱") @Log("修改邮箱")
@PostMapping(value = "/users/updateEmail/{code}") @ApiOperation("修改邮箱")
@PostMapping(value = "/updateEmail/{code}")
public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user){ public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user){
UserDetails userDetails = SecurityUtils.getUserDetails(); UserDetails userDetails = SecurityUtils.getUserDetails();
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){ if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
...@@ -183,7 +175,7 @@ public class UserController { ...@@ -183,7 +175,7 @@ public class UserController {
/** /**
* 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误
* @param resources * @param resources /
*/ */
private void checkLevel(User resources) { private void checkLevel(User resources) {
Integer currentLevel = Collections.min(roleService.findByUsers_Id(SecurityUtils.getUserId()).stream().map(RoleSmallDTO::getLevel).collect(Collectors.toList())); Integer currentLevel = Collections.min(roleService.findByUsers_Id(SecurityUtils.getUserId()).stream().map(RoleSmallDTO::getLevel).collect(Collectors.toList()));
......
...@@ -3,10 +3,6 @@ package me.zhengjie.modules.system.service; ...@@ -3,10 +3,6 @@ package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Dept; import me.zhengjie.modules.system.domain.Dept;
import me.zhengjie.modules.system.service.dto.DeptDTO; import me.zhengjie.modules.system.service.dto.DeptDTO;
import me.zhengjie.modules.system.service.dto.DeptQueryCriteria; 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 java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -14,61 +10,20 @@ import java.util.Set; ...@@ -14,61 +10,20 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2019-03-25 * @date 2019-03-25
*/ */
@CacheConfig(cacheNames = "dept")
public interface DeptService { public interface DeptService {
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
List<DeptDTO> queryAll(DeptQueryCriteria criteria); List<DeptDTO> queryAll(DeptQueryCriteria criteria);
/**
* findById
* @param id
* @return
*/
@Cacheable(key = "#p0")
DeptDTO findById(Long id); DeptDTO findById(Long id);
/**
* create
* @param resources
* @return
*/
@CacheEvict(allEntries = true)
DeptDTO create(Dept resources); DeptDTO create(Dept resources);
/**
* update
* @param resources
*/
@CacheEvict(allEntries = true)
void update(Dept resources); void update(Dept resources);
/**
* delete
* @param id
*/
@CacheEvict(allEntries = true)
void delete(Long id); void delete(Long id);
/**
* buildTree
* @param deptDTOS
* @return
*/
@Cacheable
Object buildTree(List<DeptDTO> deptDTOS); Object buildTree(List<DeptDTO> deptDTOS);
/**
* findByPid
* @param pid
* @return
*/
@Cacheable
List<Dept> findByPid(long pid); List<Dept> findByPid(long pid);
Set<Dept> findByRoleIds(Long id); Set<Dept> findByRoleIds(Long id);
......
...@@ -3,50 +3,22 @@ package me.zhengjie.modules.system.service; ...@@ -3,50 +3,22 @@ package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.DictDetail; import me.zhengjie.modules.system.domain.DictDetail;
import me.zhengjie.modules.system.service.dto.DictDetailDTO; import me.zhengjie.modules.system.service.dto.DictDetailDTO;
import me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria; 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 org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2019-04-10 * @date 2019-04-10
*/ */
@CacheConfig(cacheNames = "dictDetail")
public interface DictDetailService { public interface DictDetailService {
/**
* findById
* @param id
* @return
*/
@Cacheable(key = "#p0")
DictDetailDTO findById(Long id); DictDetailDTO findById(Long id);
/**
* create
* @param resources
* @return
*/
@CacheEvict(allEntries = true)
DictDetailDTO create(DictDetail resources); DictDetailDTO create(DictDetail resources);
/**
* update
* @param resources
*/
@CacheEvict(allEntries = true)
void update(DictDetail resources); void update(DictDetail resources);
/**
* delete
* @param id
*/
@CacheEvict(allEntries = true)
void delete(Long id); void delete(Long id);
@Cacheable
Map queryAll(DictDetailQueryCriteria criteria, Pageable pageable); Map queryAll(DictDetailQueryCriteria criteria, Pageable pageable);
} }
\ No newline at end of file
...@@ -3,54 +3,21 @@ package me.zhengjie.modules.system.service; ...@@ -3,54 +3,21 @@ package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Dict; import me.zhengjie.modules.system.domain.Dict;
import me.zhengjie.modules.system.service.dto.DictDTO; import me.zhengjie.modules.system.service.dto.DictDTO;
import me.zhengjie.modules.system.service.dto.DictQueryCriteria; 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 org.springframework.data.domain.Pageable;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2019-04-10 * @date 2019-04-10
*/ */
@CacheConfig(cacheNames = "dict")
public interface DictService { public interface DictService {
/**
* 查询
* @param dict
* @param pageable
* @return
*/
@Cacheable
Object queryAll(DictQueryCriteria dict, Pageable pageable); Object queryAll(DictQueryCriteria dict, Pageable pageable);
/**
* findById
* @param id
* @return
*/
@Cacheable(key = "#p0")
DictDTO findById(Long id); DictDTO findById(Long id);
/**
* create
* @param resources
* @return
*/
@CacheEvict(allEntries = true)
DictDTO create(Dict resources); DictDTO create(Dict resources);
/**
* update
* @param resources
*/
@CacheEvict(allEntries = true)
void update(Dict resources); void update(Dict resources);
/**
* delete
* @param id
*/
@CacheEvict(allEntries = true)
void delete(Long id); void delete(Long id);
} }
\ No newline at end of file
...@@ -3,53 +3,21 @@ package me.zhengjie.modules.system.service; ...@@ -3,53 +3,21 @@ package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Job; import me.zhengjie.modules.system.domain.Job;
import me.zhengjie.modules.system.service.dto.JobDTO; import me.zhengjie.modules.system.service.dto.JobDTO;
import me.zhengjie.modules.system.service.dto.JobQueryCriteria; 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 org.springframework.data.domain.Pageable;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2019-03-29 * @date 2019-03-29
*/ */
@CacheConfig(cacheNames = "job")
public interface JobService { public interface JobService {
/**
* findById
* @param id
* @return
*/
@Cacheable(key = "#p0")
JobDTO findById(Long id); JobDTO findById(Long id);
/**
* create
* @param resources
* @return
*/
@CacheEvict(allEntries = true)
JobDTO create(Job resources); JobDTO create(Job resources);
/**
* update
* @param resources
*/
@CacheEvict(allEntries = true)
void update(Job resources); void update(Job resources);
/**
* delete
* @param id
*/
@CacheEvict(allEntries = true)
void delete(Long id); void delete(Long id);
/**
* queryAll
* @param criteria
* @param pageable
* @return
*/
Object queryAll(JobQueryCriteria criteria, Pageable pageable); Object queryAll(JobQueryCriteria criteria, Pageable pageable);
} }
\ No newline at end of file
...@@ -4,9 +4,6 @@ import me.zhengjie.modules.system.domain.Menu; ...@@ -4,9 +4,6 @@ import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.modules.system.service.dto.MenuDTO; import me.zhengjie.modules.system.service.dto.MenuDTO;
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria; import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
import me.zhengjie.modules.system.service.dto.RoleSmallDTO; 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 java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
...@@ -15,90 +12,29 @@ import java.util.Set; ...@@ -15,90 +12,29 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-17 * @date 2018-12-17
*/ */
@CacheConfig(cacheNames = "menu")
public interface MenuService { public interface MenuService {
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
List<MenuDTO> queryAll(MenuQueryCriteria criteria); List<MenuDTO> queryAll(MenuQueryCriteria criteria);
/**
* get
* @param id
* @return
*/
@Cacheable(key = "#p0")
MenuDTO findById(long id); MenuDTO findById(long id);
/**
* create
* @param resources
* @return
*/
@CacheEvict(allEntries = true)
MenuDTO create(Menu resources); MenuDTO create(Menu resources);
/**
* update
* @param resources
*/
@CacheEvict(allEntries = true)
void update(Menu resources); void update(Menu resources);
/**
* getDeleteMenus
* @param menuList
* @param menuSet
* @return
*/
Set<Menu> getDeleteMenus(List<Menu> menuList, Set<Menu> menuSet); Set<Menu> getDeleteMenus(List<Menu> menuList, Set<Menu> menuSet);
/**
* permission tree
* @return
*/
@Cacheable(key = "'tree'")
Object getMenuTree(List<Menu> menus); Object getMenuTree(List<Menu> menus);
/**
* findByPid
* @param pid
* @return
*/
@Cacheable(key = "'pid:'+#p0")
List<Menu> findByPid(long pid); List<Menu> findByPid(long pid);
/** Map<String,Object> buildTree(List<MenuDTO> menuDTOS);
* build Tree
* @param menuDTOS
* @return
*/
Map buildTree(List<MenuDTO> menuDTOS);
/**
* findByRoles
* @param roles
* @return
*/
List<MenuDTO> findByRoles(List<RoleSmallDTO> roles); List<MenuDTO> findByRoles(List<RoleSmallDTO> roles);
/**
* buildMenus
* @param byRoles
* @return
*/
Object buildMenus(List<MenuDTO> byRoles); Object buildMenus(List<MenuDTO> byRoles);
Menu findOne(Long id); Menu findOne(Long id);
/**
* delete
* @param menuSet
*/
@CacheEvict(allEntries = true)
void delete(Set<Menu> menuSet); void delete(Set<Menu> menuSet);
} }
...@@ -3,10 +3,6 @@ package me.zhengjie.modules.system.service; ...@@ -3,10 +3,6 @@ package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Permission; import me.zhengjie.modules.system.domain.Permission;
import me.zhengjie.modules.system.service.dto.PermissionDTO; import me.zhengjie.modules.system.service.dto.PermissionDTO;
import me.zhengjie.modules.system.service.dto.PermissionQueryCriteria; 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.List;
import java.util.Set; import java.util.Set;
...@@ -14,68 +10,22 @@ import java.util.Set; ...@@ -14,68 +10,22 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-08 * @date 2018-12-08
*/ */
@CacheConfig(cacheNames = "permission")
public interface PermissionService { public interface PermissionService {
/**
* get
* @param id
* @return
*/
@Cacheable(key = "#p0")
PermissionDTO findById(long id); PermissionDTO findById(long id);
/**
* create
* @param resources
* @return
*/
@CacheEvict(allEntries = true)
PermissionDTO create(Permission resources); PermissionDTO create(Permission resources);
/**
* update
* @param resources
*/
@CacheEvict(allEntries = true)
void update(Permission resources); void update(Permission resources);
/**
* delete
* @param permissions
*/
@CacheEvict(allEntries = true)
void delete(Set<Permission> permissions); void delete(Set<Permission> permissions);
/**
* permission tree
* @return
*/
@Cacheable(key = "'tree'")
Object getPermissionTree(List<Permission> permissions); Object getPermissionTree(List<Permission> permissions);
/**
* findByPid
* @param pid
* @return
*/
@Cacheable(key = "'pid:'+#p0")
List<Permission> findByPid(long pid); List<Permission> findByPid(long pid);
/**
* build Tree
* @param permissionDTOS
* @return
*/
@Cacheable
Object buildTree(List<PermissionDTO> permissionDTOS); Object buildTree(List<PermissionDTO> permissionDTOS);
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
List<PermissionDTO> queryAll(PermissionQueryCriteria criteria); List<PermissionDTO> queryAll(PermissionQueryCriteria criteria);
Set<Permission> getDeletePermission(List<Permission> permissions, Set<Permission> permissionSet); Set<Permission> getDeletePermission(List<Permission> permissions, Set<Permission> permissionSet);
......
...@@ -4,11 +4,7 @@ import me.zhengjie.modules.system.domain.Role; ...@@ -4,11 +4,7 @@ import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.service.dto.RoleDTO; import me.zhengjie.modules.system.service.dto.RoleDTO;
import me.zhengjie.modules.system.service.dto.RoleQueryCriteria; import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
import me.zhengjie.modules.system.service.dto.RoleSmallDTO; 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 org.springframework.data.domain.Pageable;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -16,95 +12,31 @@ import java.util.Set; ...@@ -16,95 +12,31 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-03 * @date 2018-12-03
*/ */
@CacheConfig(cacheNames = "role")
public interface RoleService { public interface RoleService {
/**
* get
* @param id
* @return
*/
@Cacheable(key = "#p0")
RoleDTO findById(long id); RoleDTO findById(long id);
/**
* create
* @param resources
* @return
*/
@CacheEvict(allEntries = true)
RoleDTO create(Role resources); RoleDTO create(Role resources);
/**
* update
* @param resources
*/
@CacheEvict(allEntries = true)
void update(Role resources); void update(Role resources);
/**
* delete
* @param id
*/
@CacheEvict(allEntries = true)
void delete(Long id); void delete(Long id);
/**
* key的名称如有修改,请同步修改 UserServiceImpl 中的 update 方法
* findByUsers_Id
* @param id
* @return
*/
@Cacheable(key = "'findByUsers_Id:' + #p0")
List<RoleSmallDTO> findByUsers_Id(Long id); List<RoleSmallDTO> findByUsers_Id(Long id);
@Cacheable
Integer findByRoles(Set<Role> roles); Integer findByRoles(Set<Role> roles);
/**
* updatePermission
* @param resources
* @param roleDTO
*/
@CacheEvict(allEntries = true)
void updatePermission(Role resources, RoleDTO roleDTO); void updatePermission(Role resources, RoleDTO roleDTO);
/**
* updateMenu
* @param resources
* @param roleDTO
*/
@CacheEvict(allEntries = true)
void updateMenu(Role resources, RoleDTO roleDTO); void updateMenu(Role resources, RoleDTO roleDTO);
@CacheEvict(allEntries = true)
void untiedMenu(Long id); void untiedMenu(Long id);
/**
* queryAll
* @param pageable
* @return
*/
@Cacheable
Object queryAll(Pageable pageable); Object queryAll(Pageable pageable);
/**
* queryAll
* @param pageable
* @param criteria
* @return
*/
@Cacheable
Object queryAll(RoleQueryCriteria criteria, Pageable pageable); Object queryAll(RoleQueryCriteria criteria, Pageable pageable);
/**
* queryAll
* @param criteria
* @return
*/
@Cacheable
List<RoleDTO> queryAll(RoleQueryCriteria criteria); List<RoleDTO> queryAll(RoleQueryCriteria criteria);
@CacheEvict(allEntries = true)
void untiedPermission(Long id); void untiedPermission(Long id);
} }
package me.zhengjie.modules.system.service; package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.User; 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.UserDTO;
import me.zhengjie.modules.system.service.dto.UserQueryCriteria; 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.data.domain.Pageable;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
...@@ -18,74 +13,26 @@ import java.util.List; ...@@ -18,74 +13,26 @@ import java.util.List;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-11-23 * @date 2018-11-23
*/ */
@CacheConfig(cacheNames = "user")
public interface UserService { public interface UserService {
/**
* get
* @param id
* @return
*/
@Cacheable(key = "#p0")
UserDTO findById(long id); UserDTO findById(long id);
/**
* create
* @param resources
* @return
*/
@CacheEvict(allEntries = true)
UserDTO create(User resources); UserDTO create(User resources);
/**
* update
* @param resources
*/
@CacheEvict(allEntries = true)
void update(User resources); void update(User resources);
/**
* delete
* @param id
*/
@CacheEvict(allEntries = true)
void delete(Long id); void delete(Long id);
/**
* findByName
* @param userName
* @return
*/
@Cacheable(key = "'loadUserByUsername:'+#p0")
UserDTO findByName(String userName); UserDTO findByName(String userName);
/**
* 修改密码
* @param username
* @param encryptPassword
*/
@CacheEvict(allEntries = true)
void updatePass(String username, String encryptPassword); void updatePass(String username, String encryptPassword);
/**
* 修改头像
* @param file
*/
@CacheEvict(allEntries = true)
void updateAvatar(MultipartFile file); void updateAvatar(MultipartFile file);
/**
* 修改邮箱
* @param username
* @param email
*/
@CacheEvict(allEntries = true)
void updateEmail(String username, String email); void updateEmail(String username, String email);
@Cacheable
Object queryAll(UserQueryCriteria criteria, Pageable pageable); Object queryAll(UserQueryCriteria criteria, Pageable pageable);
@Cacheable
List<UserDTO> queryAll(UserQueryCriteria criteria); List<UserDTO> queryAll(UserQueryCriteria criteria);
void download(List<UserDTO> queryAll, HttpServletResponse response) throws IOException; void download(List<UserDTO> queryAll, HttpServletResponse response) throws IOException;
......
...@@ -15,22 +15,16 @@ import java.util.List; ...@@ -15,22 +15,16 @@ import java.util.List;
@Data @Data
public class DeptDTO implements Serializable { public class DeptDTO implements Serializable {
/** // ID
* ID
*/
private Long id; private Long id;
/** // 名称
* 名称
*/
private String name; private String name;
@NotNull @NotNull
private Boolean enabled; private Boolean enabled;
/** // 上级部门
* 上级部门
*/
private Long pid; private Long pid;
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
......
...@@ -10,13 +10,7 @@ import java.io.Serializable; ...@@ -10,13 +10,7 @@ import java.io.Serializable;
@Data @Data
public class DeptSmallDTO implements Serializable { public class DeptSmallDTO implements Serializable {
/**
* ID
*/
private Long id; private Long id;
/**
* 名称
*/
private String name; private String name;
} }
\ No newline at end of file
...@@ -12,13 +12,7 @@ public class DictDTO implements Serializable { ...@@ -12,13 +12,7 @@ public class DictDTO implements Serializable {
private Long id; private Long id;
/**
* 字典名称
*/
private String name; private String name;
/**
* 描述
*/
private String remark; private String remark;
} }
...@@ -12,18 +12,9 @@ public class DictDetailDTO implements Serializable { ...@@ -12,18 +12,9 @@ public class DictDetailDTO implements Serializable {
private Long id; private Long id;
/**
* 字典标签
*/
private String label; private String label;
/**
* 字典值
*/
private String value; private String value;
/**
* 排序
*/
private String sort; private String sort;
} }
\ No newline at end of file
...@@ -16,33 +16,18 @@ import java.io.Serializable; ...@@ -16,33 +16,18 @@ import java.io.Serializable;
@NoArgsConstructor @NoArgsConstructor
public class JobDTO implements Serializable { public class JobDTO implements Serializable {
/**
* ID
*/
private Long id; private Long id;
private Long sort; private Long sort;
/**
* 名称
*/
private String name; private String name;
/**
* 状态
*/
private Boolean enabled; private Boolean enabled;
private DeptDTO dept; private DeptDTO dept;
/**
* 如果分公司存在相同部门,则显示上级部门名称
*/
private String deptSuperiorName; private String deptSuperiorName;
/**
* 创建日期
*/
private Timestamp createTime; private Timestamp createTime;
public JobDTO(String name, Boolean enabled) { public JobDTO(String name, Boolean enabled) {
......
...@@ -12,13 +12,7 @@ import java.io.Serializable; ...@@ -12,13 +12,7 @@ import java.io.Serializable;
@NoArgsConstructor @NoArgsConstructor
public class JobSmallDTO implements Serializable { public class JobSmallDTO implements Serializable {
/**
* ID
*/
private Long id; private Long id;
/**
* 名称
*/
private String name; private String name;
} }
\ No newline at end of file
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