upd: 编码规范

This commit is contained in:
2025-04-09 20:26:30 +08:00
parent 3a74dc00ac
commit 3a86cca504
12 changed files with 90 additions and 90 deletions
@@ -35,7 +35,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
throw new BadRequestException("账号未激活!");
}
// 获取用户的权限
List<RoleCodeModel> authorities = roleService.buildPermissions(user);
List<RoleCodeModel> authorities = roleService.buildUserRolePermissions(user);
// 初始化JwtUserDto
userJwtModel = new UserJwtModel(user, dataService.describeDeptIdListByUserIdWithDeptId(user), authorities);
// 添加缓存数据
@@ -44,22 +44,22 @@ public class MenuController {
@GetMapping(value = "/download")
@PreAuthorize("@el.check('menu:list')")
public void exportMenu(HttpServletResponse response, QueryMenuRequest criteria) throws Exception {
menuService.downloadExcel(menuService.selectMenuByCriteria(criteria, false), response);
menuService.downloadMenuExcel(menuService.describeMenuList(criteria, false), response);
}
@PostMapping(value = "/buildMenus")
@ApiOperation("获取前端所需菜单")
public ResponseEntity<List<MenuResponse>> buildMenus() {
List<Menu> menuList = menuService.selectMenuByUserId(SecurityHelper.getCurrentUserId());
List<Menu> menus = menuService.buildTree(menuList);
return new ResponseEntity<>(menuService.buildMenus(menus), HttpStatus.OK);
List<Menu> menuList = menuService.describeMenuListByUserId(SecurityHelper.getCurrentUserId());
List<Menu> menus = menuService.buildMenuTree(menuList);
return new ResponseEntity<>(menuService.buildMenuResponse(menus), HttpStatus.OK);
}
@ApiOperation("返回全部的菜单")
@PostMapping(value = "/queryAllMenu")
@PreAuthorize("@el.check('menu:list','roles:list')")
public ResponseEntity<List<Menu>> queryAllMenu(@RequestParam Long pid) {
return new ResponseEntity<>(menuService.selectMenuByPid(pid), HttpStatus.OK);
return new ResponseEntity<>(menuService.describeMenuListByPid(pid), HttpStatus.OK);
}
@ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
@@ -67,9 +67,9 @@ public class MenuController {
@PreAuthorize("@el.check('menu:list','roles:list')")
public ResponseEntity<Object> queryChildMenu(@RequestParam Long id) {
Set<Menu> menuSet = new HashSet<>();
List<Menu> menuList = menuService.selectMenuByPid(id);
List<Menu> menuList = menuService.describeMenuListByPid(id);
menuSet.add(menuService.getById(id));
menuSet = menuService.selectChildMenus(menuList, menuSet);
menuSet = menuService.describeChildMenuSet(menuList, menuSet);
Set<Long> ids = menuSet.stream().map(Menu::getId).collect(Collectors.toSet());
return new ResponseEntity<>(ids, HttpStatus.OK);
}
@@ -78,7 +78,7 @@ public class MenuController {
@ApiOperation("查询菜单")
@PreAuthorize("@el.check('menu:list')")
public ResponseEntity<PageResult<Menu>> queryMenu(QueryMenuRequest criteria) throws Exception {
List<Menu> menuList = menuService.selectMenuByCriteria(criteria, true);
List<Menu> menuList = menuService.describeMenuList(criteria, true);
return new ResponseEntity<>(PageUtil.toPage(menuList), HttpStatus.OK);
}
@@ -89,8 +89,8 @@ public class MenuController {
Set<Menu> menus = new LinkedHashSet<>();
if (CollectionUtil.isNotEmpty(ids)) {
for (Long id : ids) {
Menu menu = menuService.getMenuById(id);
List<Menu> menuList = menuService.selectSuperiorMenu(menu, new ArrayList<>());
Menu menu = menuService.describeMenuById(id);
List<Menu> menuList = menuService.describeSuperiorMenuList(menu, new ArrayList<>());
for (Menu data : menuList) {
if (data.getId().equals(menu.getPid())) {
data.setSubCount(data.getSubCount() - 1);
@@ -100,9 +100,9 @@ public class MenuController {
}
// 编辑菜单时不显示自己以及自己下级的数据,避免出现PID数据环形问题
menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet());
return new ResponseEntity<>(menuService.buildTree(new ArrayList<>(menus)), HttpStatus.OK);
return new ResponseEntity<>(menuService.buildMenuTree(new ArrayList<>(menus)), HttpStatus.OK);
}
return new ResponseEntity<>(menuService.selectMenuByPid(null), HttpStatus.OK);
return new ResponseEntity<>(menuService.describeMenuListByPid(null), HttpStatus.OK);
}
@ApiOperation("新增菜单")
@@ -112,7 +112,7 @@ public class MenuController {
if (resources.getId() != null) {
throw new BadRequestException("A new " + ENTITY_NAME + " cannot already have an ID");
}
menuService.saveMenu(resources);
menuService.createMenu(resources);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@@ -120,7 +120,7 @@ public class MenuController {
@PostMapping(value = "/updateMenu")
@PreAuthorize("@el.check('menu:edit')")
public ResponseEntity<Object> updateMenu(@Validated(Menu.Update.class) @RequestBody Menu resources) {
menuService.updateMenuById(resources);
menuService.modifyMenuById(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@@ -130,9 +130,9 @@ public class MenuController {
public ResponseEntity<Object> deleteMenu(@RequestBody Set<Long> ids) {
Set<Menu> menuSet = new HashSet<>();
for (Long id : ids) {
List<Menu> menuList = menuService.selectMenuByPid(id);
List<Menu> menuList = menuService.describeMenuListByPid(id);
menuSet.add(menuService.getById(id));
menuSet = menuService.selectChildMenus(menuList, menuSet);
menuSet = menuService.describeChildMenuSet(menuList, menuSet);
}
menuService.deleteMenuByIds(menuSet);
return new ResponseEntity<>(HttpStatus.OK);
@@ -23,6 +23,6 @@ public class MonitorController {
@ApiOperation("查询服务监控")
@PreAuthorize("@el.check('monitor:list')")
public ResponseEntity<Object> queryMonitor() {
return new ResponseEntity<>(serverService.getServerInfo(), HttpStatus.OK);
return new ResponseEntity<>(serverService.describeServerMonitorInfo(), HttpStatus.OK);
}
}
@@ -41,21 +41,21 @@ public class RoleController {
@PostMapping(value = "/getRoleById/{id}")
@PreAuthorize("@el.check('roles:list')")
public ResponseEntity<Role> getRoleById(@PathVariable Long id) {
return new ResponseEntity<>(roleService.getRoleById(id), HttpStatus.OK);
return new ResponseEntity<>(roleService.describeRoleById(id), HttpStatus.OK);
}
@ApiOperation("导出角色数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('role:list')")
public void exportRole(HttpServletResponse response, QueryRoleRequest criteria) throws IOException {
roleService.downloadExcel(roleService.selectRoleByCriteria(criteria), response);
roleService.downloadRoleExcel(roleService.describeRoleList(criteria), response);
}
@ApiOperation("返回全部的角色")
@PostMapping(value = "/queryAllRole")
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
public ResponseEntity<List<Role>> queryAllRole() {
return new ResponseEntity<>(roleService.selectRole(), HttpStatus.OK);
return new ResponseEntity<>(roleService.describeRoleList(), HttpStatus.OK);
}
@ApiOperation("查询角色")
@@ -63,20 +63,20 @@ public class RoleController {
@PreAuthorize("@el.check('roles:list')")
public ResponseEntity<PageResult<Role>> queryRole(QueryRoleRequest criteria) {
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
return new ResponseEntity<>(roleService.queryRolePage(criteria, page), HttpStatus.OK);
return new ResponseEntity<>(roleService.describeRolePage(criteria, page), HttpStatus.OK);
}
@ApiOperation("获取用户级别")
@PostMapping(value = "/getRoleLevel")
public ResponseEntity<Object> getRoleLevel() {
return new ResponseEntity<>(Dict.create().set("level", getLevels(null)), HttpStatus.OK);
return new ResponseEntity<>(Dict.create().set("level", checkRoleLevels(null)), HttpStatus.OK);
}
@ApiOperation("新增角色")
@PostMapping(value = "/createRole")
@PreAuthorize("@el.check('roles:add')")
public ResponseEntity<Object> createRole(@Validated @RequestBody CreateRoleRequest resources) {
getLevels(resources.getLevel());
checkRoleLevels(resources.getLevel());
roleService.createRole(resources);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@@ -85,8 +85,8 @@ public class RoleController {
@PostMapping(value = "/updateRole")
@PreAuthorize("@el.check('roles:edit')")
public ResponseEntity<Object> updateRole(@Validated(Role.Update.class) @RequestBody Role resources) {
getLevels(resources.getLevel());
roleService.updateRoleById(resources);
checkRoleLevels(resources.getLevel());
roleService.modifyRoleById(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@@ -95,8 +95,8 @@ public class RoleController {
@PreAuthorize("@el.check('roles:edit')")
public ResponseEntity<Object> updateRoleMenu(@RequestBody Role resources) {
Role role = roleService.getById(resources.getId());
getLevels(role.getLevel());
roleService.updateMenuById(resources);
checkRoleLevels(role.getLevel());
roleService.modifyBindMenuById(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@@ -106,7 +106,7 @@ public class RoleController {
public ResponseEntity<Object> deleteRole(@RequestBody Set<Long> ids) {
for (Long id : ids) {
Role role = roleService.getById(id);
getLevels(role.getLevel());
checkRoleLevels(role.getLevel());
}
// 验证是否被用户关联
roleService.verifyBindRelationByIds(ids);
@@ -115,12 +115,12 @@ public class RoleController {
}
/**
* 获取用户的角色级别
* 检查用户的角色级别
*
* @return /
*/
private int getLevels(Integer level) {
List<Integer> levels = roleService.selectRoleByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList());
private int checkRoleLevels(Integer level) {
List<Integer> levels = roleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList());
int min = Collections.min(levels);
if (level != null) {
if (level < min) {
@@ -131,8 +131,8 @@ public class UserController {
@PreAuthorize("@el.check('user:del')")
public ResponseEntity<Object> deleteUser(@RequestBody Set<Long> ids) {
for (Long id : ids) {
Integer currentLevel = Collections.min(roleService.selectRoleByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList()));
Integer optLevel = Collections.min(roleService.selectRoleByUsersId(id).stream().map(Role::getLevel).collect(Collectors.toList()));
Integer currentLevel = Collections.min(roleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList()));
Integer optLevel = Collections.min(roleService.describeRoleListByUsersId(id).stream().map(Role::getLevel).collect(Collectors.toList()));
if (currentLevel > optLevel) {
throw new BadRequestException("角色权限不足,不能删除:" + userService.getUserById(id).getUsername());
}
@@ -190,8 +190,8 @@ public class UserController {
* @param resources /
*/
private void checkLevel(User resources) {
Integer currentLevel = Collections.min(roleService.selectRoleByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList()));
Integer optLevel = roleService.getDeptLevelByRoles(resources.getRoles());
Integer currentLevel = Collections.min(roleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList()));
Integer optLevel = roleService.describeDeptLevelByRoles(resources.getRoles());
if (currentLevel > optLevel) {
throw new BadRequestException("角色权限不足");
}
@@ -19,7 +19,7 @@ public interface MenuService extends IService<Menu> {
* @return /
* @throws Exception /
*/
List<Menu> selectMenuByCriteria(QueryMenuRequest criteria, Boolean isQuery) throws Exception;
List<Menu> describeMenuList(QueryMenuRequest criteria, Boolean isQuery) throws Exception;
/**
* 根据ID查询
@@ -27,21 +27,21 @@ public interface MenuService extends IService<Menu> {
* @param id /
* @return /
*/
Menu getMenuById(long id);
Menu describeMenuById(long id);
/**
* 创建
*
* @param resources /
*/
void saveMenu(Menu resources);
void createMenu(Menu resources);
/**
* 编辑
*
* @param resources /
*/
void updateMenuById(Menu resources);
void modifyMenuById(Menu resources);
/**
* 获取所有子节点,包含自身ID
@@ -50,7 +50,7 @@ public interface MenuService extends IService<Menu> {
* @param menuSet /
* @return /
*/
Set<Menu> selectChildMenus(List<Menu> menuList, Set<Menu> menuSet);
Set<Menu> describeChildMenuSet(List<Menu> menuList, Set<Menu> menuSet);
/**
* 构建菜单树
@@ -58,7 +58,7 @@ public interface MenuService extends IService<Menu> {
* @param menus 原始数据
* @return /
*/
List<Menu> buildTree(List<Menu> menus);
List<Menu> buildMenuTree(List<Menu> menus);
/**
* 构建菜单树
@@ -66,7 +66,7 @@ public interface MenuService extends IService<Menu> {
* @param menus /
* @return /
*/
List<MenuResponse> buildMenus(List<Menu> menus);
List<MenuResponse> buildMenuResponse(List<Menu> menus);
/**
* 删除
@@ -82,7 +82,7 @@ public interface MenuService extends IService<Menu> {
* @param response /
* @throws IOException /
*/
void downloadExcel(List<Menu> menus, HttpServletResponse response) throws IOException;
void downloadMenuExcel(List<Menu> menus, HttpServletResponse response) throws IOException;
/**
* 懒加载菜单数据
@@ -90,7 +90,7 @@ public interface MenuService extends IService<Menu> {
* @param pid /
* @return /
*/
List<Menu> selectMenuByPid(Long pid);
List<Menu> describeMenuListByPid(Long pid);
/**
* 根据ID获取同级与上级数据
@@ -99,7 +99,7 @@ public interface MenuService extends IService<Menu> {
* @param objects /
* @return /
*/
List<Menu> selectSuperiorMenu(Menu menu, List<Menu> objects);
List<Menu> describeSuperiorMenuList(Menu menu, List<Menu> objects);
/**
* 根据当前用户获取菜单
@@ -107,5 +107,5 @@ public interface MenuService extends IService<Menu> {
* @param currentUserId /
* @return /
*/
List<Menu> selectMenuByUserId(Long currentUserId);
List<Menu> describeMenuListByUserId(Long currentUserId);
}
@@ -5,9 +5,9 @@ import java.util.Map;
public interface MonitorService {
/**
* 查询数据分页
* 查询服务器监控信息
*
* @return Map<String, Object>
*/
Map<String, Object> getServerInfo();
Map<String, Object> describeServerMonitorInfo();
}
@@ -21,7 +21,7 @@ public interface RoleService extends IService<Role> {
*
* @return /
*/
List<Role> selectRole();
List<Role> describeRoleList();
/**
* 查询全部
@@ -29,7 +29,7 @@ public interface RoleService extends IService<Role> {
* @param criteria 条件
* @return /
*/
List<Role> selectRoleByCriteria(QueryRoleRequest criteria);
List<Role> describeRoleList(QueryRoleRequest criteria);
/**
* 待条件分页查询
@@ -38,7 +38,7 @@ public interface RoleService extends IService<Role> {
* @param page 分页参数
* @return /
*/
PageResult<Role> queryRolePage(QueryRoleRequest criteria, Page<Object> page);
PageResult<Role> describeRolePage(QueryRoleRequest criteria, Page<Object> page);
/**
* 根据ID查询
@@ -46,7 +46,7 @@ public interface RoleService extends IService<Role> {
* @param id /
* @return /
*/
Role getRoleById(long id);
Role describeRoleById(long id);
/**
* 创建
@@ -60,14 +60,14 @@ public interface RoleService extends IService<Role> {
*
* @param resources /
*/
void updateRoleById(Role resources);
void modifyRoleById(Role resources);
/**
* 修改绑定的菜单
*
* @param resources /
*/
void updateMenuById(Role resources);
void modifyBindMenuById(Role resources);
/**
* 删除
@@ -82,7 +82,7 @@ public interface RoleService extends IService<Role> {
* @param userId 用户ID
* @return /
*/
List<Role> selectRoleByUsersId(Long userId);
List<Role> describeRoleListByUsersId(Long userId);
/**
* 根据角色查询角色级别
@@ -90,7 +90,7 @@ public interface RoleService extends IService<Role> {
* @param roles /
* @return /
*/
Integer getDeptLevelByRoles(Set<Role> roles);
Integer describeDeptLevelByRoles(Set<Role> roles);
/**
* 获取用户权限信息
@@ -98,7 +98,7 @@ public interface RoleService extends IService<Role> {
* @param user 用户信息
* @return 权限信息
*/
List<RoleCodeModel> buildPermissions(User user);
List<RoleCodeModel> buildUserRolePermissions(User user);
/**
* 导出数据
@@ -107,7 +107,7 @@ public interface RoleService extends IService<Role> {
* @param response /
* @throws IOException /
*/
void downloadExcel(List<Role> roles, HttpServletResponse response) throws IOException;
void downloadRoleExcel(List<Role> roles, HttpServletResponse response) throws IOException;
/**
* 验证是否被用户关联
@@ -122,5 +122,5 @@ public interface RoleService extends IService<Role> {
* @param menuId /
* @return /
*/
List<Role> selectRoleByMenuId(Long menuId);
List<Role> describeRoleListByMenuId(Long menuId);
}
@@ -42,7 +42,7 @@ public class DataServiceImpl implements DataService {
if (CollUtil.isEmpty(ids)) {
Set<Long> deptIds = new HashSet<>();
// 查询用户角色
List<Role> roleList = roleService.selectRoleByUsersId(user.getId());
List<Role> roleList = roleService.describeRoleListByUsersId(user.getId());
// 获取对应的部门ID
for (Role role : roleList) {
DataScopeEnum dataScopeEnum = DataScopeEnum.find(role.getDataScope());
@@ -53,7 +53,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
private static final String NO_STR = "否";
@Override
public List<Menu> selectMenuByCriteria(QueryMenuRequest criteria, Boolean isQuery) throws Exception {
public List<Menu> describeMenuList(QueryMenuRequest criteria, Boolean isQuery) throws Exception {
if (Boolean.TRUE.equals(isQuery)) {
criteria.setPidIsNull(true);
List<Field> fields = ClassUtil.getAllFields(criteria.getClass(), new ArrayList<>());
@@ -75,7 +75,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
}
@Override
public Menu getMenuById(long id) {
public Menu describeMenuById(long id) {
String key = SystemRedisKey.MENU_ID + id;
Menu menu = redisHelper.get(key, Menu.class);
if (menu == null) {
@@ -92,11 +92,11 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
* @return /
*/
@Override
public List<Menu> selectMenuByUserId(Long currentUserId) {
public List<Menu> describeMenuListByUserId(Long currentUserId) {
String key = SystemRedisKey.MENU_USER + currentUserId;
List<Menu> menus = redisHelper.getList(key, Menu.class);
if (CollUtil.isEmpty(menus)) {
List<Role> roles = roleService.selectRoleByUsersId(currentUserId);
List<Role> roles = roleService.describeRoleListByUsersId(currentUserId);
Set<Long> roleIds = roles.stream().map(Role::getId).collect(Collectors.toSet());
menus = new ArrayList<>(menuMapper.queryMenuSetByRoleIdsAndType(roleIds, 2));
redisHelper.set(key, menus, 1, TimeUnit.DAYS);
@@ -106,7 +106,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
@Override
@Transactional(rollbackFor = Exception.class)
public void saveMenu(Menu resources) {
public void createMenu(Menu resources) {
if (menuMapper.getMenuByTitle(resources.getTitle()) != null) {
throw new EntityExistException(Menu.class, "title", resources.getTitle());
}
@@ -132,7 +132,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMenuById(Menu resources) {
public void modifyMenuById(Menu resources) {
if (resources.getId().equals(resources.getPid())) {
throw new BadRequestException("上级不能为自己");
}
@@ -183,12 +183,12 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
}
@Override
public Set<Menu> selectChildMenus(List<Menu> menuList, Set<Menu> menuSet) {
public Set<Menu> describeChildMenuSet(List<Menu> menuList, Set<Menu> menuSet) {
for (Menu menu : menuList) {
menuSet.add(menu);
List<Menu> menus = menuMapper.queryMenuListByPidOrderByMenuSort(menu.getId());
if (CollUtil.isNotEmpty(menus)) {
selectChildMenus(menus, menuSet);
describeChildMenuSet(menus, menuSet);
}
}
return menuSet;
@@ -207,7 +207,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
}
@Override
public List<Menu> selectMenuByPid(Long pid) {
public List<Menu> describeMenuListByPid(Long pid) {
List<Menu> menus;
if (pid != null && !pid.equals(0L)) {
menus = menuMapper.queryMenuListByPidOrderByMenuSort(pid);
@@ -218,17 +218,17 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
}
@Override
public List<Menu> selectSuperiorMenu(Menu menu, List<Menu> menus) {
public List<Menu> describeSuperiorMenuList(Menu menu, List<Menu> menus) {
if (menu.getPid() == null) {
menus.addAll(menuMapper.queryMenuListByPidIsNullOrderByMenuSort());
return menus;
}
menus.addAll(menuMapper.queryMenuListByPidOrderByMenuSort(menu.getPid()));
return selectSuperiorMenu(getMenuById(menu.getPid()), menus);
return describeSuperiorMenuList(describeMenuById(menu.getPid()), menus);
}
@Override
public List<Menu> buildTree(List<Menu> menus) {
public List<Menu> buildMenuTree(List<Menu> menus) {
List<Menu> trees = new ArrayList<>();
Set<Long> ids = new HashSet<>();
for (Menu menu : menus) {
@@ -252,7 +252,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
}
@Override
public List<MenuResponse> buildMenus(List<Menu> menus) {
public List<MenuResponse> buildMenuResponse(List<Menu> menus) {
List<MenuResponse> list = new LinkedList<>();
menus.forEach(menu -> {
if (menu != null) {
@@ -277,7 +277,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
if (CollectionUtil.isNotEmpty(menuList)) {
menuResponse.setAlwaysShow(true);
menuResponse.setRedirect("noredirect");
menuResponse.setChildren(buildMenus(menuList));
menuResponse.setChildren(buildMenuResponse(menuList));
// 处理是一级菜单并且没有子菜单的情况
} else if (menu.getPid() == null) {
MenuResponse menuResponse1 = getMenuVo(menu, menuResponse);
@@ -296,7 +296,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
}
@Override
public void downloadExcel(List<Menu> menus, HttpServletResponse response) throws IOException {
public void downloadMenuExcel(List<Menu> menus, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (Menu menu : menus) {
Map<String, Object> map = new LinkedHashMap<>();
@@ -329,7 +329,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
redisHelper.del(SystemRedisKey.MENU_ID + id);
redisHelper.delByKeys(SystemRedisKey.MENU_USER, users.stream().map(User::getId).collect(Collectors.toSet()));
// 清除 Role 缓存
List<Role> roles = roleService.selectRoleByMenuId(id);
List<Role> roles = roleService.describeRoleListByMenuId(id);
redisHelper.delByKeys(SystemRedisKey.ROLE_ID, roles.stream().map(Role::getId).collect(Collectors.toSet()));
}
@@ -32,7 +32,7 @@ public class MonitorServiceImpl implements MonitorService {
private final DecimalFormat df = new DecimalFormat("0.00");
@Override
public Map<String, Object> getServerInfo() {
public Map<String, Object> describeServerMonitorInfo() {
Map<String, Object> resultMap = new LinkedHashMap<>(8);
try {
SystemInfo si = new SystemInfo();
@@ -51,17 +51,17 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
private final RedisHelper redisHelper;
@Override
public List<Role> selectRole() {
public List<Role> describeRoleList() {
return roleMapper.queryRoleList();
}
@Override
public List<Role> selectRoleByCriteria(QueryRoleRequest criteria) {
public List<Role> describeRoleList(QueryRoleRequest criteria) {
return roleMapper.queryRoleListByArgs(criteria);
}
@Override
public PageResult<Role> queryRolePage(QueryRoleRequest criteria, Page<Object> page) {
public PageResult<Role> describeRolePage(QueryRoleRequest criteria, Page<Object> page) {
criteria.setOffset(page.offset());
List<Role> roles = roleMapper.queryRoleListByArgs(criteria);
Long total = roleMapper.getRoleCountByArgs(criteria);
@@ -69,7 +69,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
}
@Override
public Role getRoleById(long id) {
public Role describeRoleById(long id) {
String key = SystemRedisKey.ROLE_ID + id;
Role role = redisHelper.get(key, Role.class);
if (role == null) {
@@ -94,7 +94,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
@Override
@Transactional(rollbackFor = Exception.class)
public void updateRoleById(Role resources) {
public void modifyRoleById(Role resources) {
Role role = getById(resources.getId());
Role role1 = roleMapper.getRoleByName(resources.getName());
if (role1 != null && !role1.getId().equals(role.getId())) {
@@ -118,7 +118,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
}
@Override
public void updateMenuById(Role role) {
public void modifyBindMenuById(Role role) {
List<User> users = userMapper.queryUserListByRoleId(role.getId());
// 更新菜单
roleMenuMapper.deleteByRoleId(role.getId());
@@ -144,7 +144,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
}
@Override
public List<Role> selectRoleByUsersId(Long userId) {
public List<Role> describeRoleListByUsersId(Long userId) {
String key = SystemRedisKey.ROLE_USER + userId;
List<Role> roles = redisHelper.getList(key, Role.class);
if (CollUtil.isEmpty(roles)) {
@@ -155,19 +155,19 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
}
@Override
public Integer getDeptLevelByRoles(Set<Role> roles) {
public Integer describeDeptLevelByRoles(Set<Role> roles) {
if (CollUtil.isEmpty(roles)) {
return Integer.MAX_VALUE;
}
Set<Role> roleSet = new HashSet<>();
for (Role role : roles) {
roleSet.add(getRoleById(role.getId()));
roleSet.add(describeRoleById(role.getId()));
}
return Collections.min(roleSet.stream().map(Role::getLevel).collect(Collectors.toList()));
}
@Override
public List<RoleCodeModel> buildPermissions(User user) {
public List<RoleCodeModel> buildUserRolePermissions(User user) {
String key = SystemRedisKey.ROLE_AUTH + user.getId();
List<RoleCodeModel> authorityList = redisHelper.getList(key, RoleCodeModel.class);
if (CollUtil.isEmpty(authorityList)) {
@@ -190,7 +190,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
}
@Override
public void downloadExcel(List<Role> roles, HttpServletResponse response) throws IOException {
public void downloadRoleExcel(List<Role> roles, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (Role role : roles) {
Map<String, Object> map = new LinkedHashMap<>();
@@ -211,7 +211,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
}
@Override
public List<Role> selectRoleByMenuId(Long menuId) {
public List<Role> describeRoleListByMenuId(Long menuId) {
return roleMapper.queryRoleListByMenuId(menuId);
}