diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/context/TokenFilter.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/context/TokenFilter.java index 923ea6aa..813b5133 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/context/TokenFilter.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/context/TokenFilter.java @@ -38,7 +38,7 @@ public class TokenFilter extends GenericFilterBean { if (StrUtil.isNotBlank(token)) { // 获取用户Token的Key String loginKey = tokenProvider.loginKey(token); - UserOnlineModel userOnlineModel = onlineUserService.getOnlineUserByKey(loginKey); + UserOnlineModel userOnlineModel = onlineUserService.describeUserOnlineModelByKey(loginKey); // 判断用户在线信息是否为空 if (userOnlineModel != null) { // Token 续期判断 diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/rest/AuthController.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/rest/AuthController.java index 00d74156..3c0f8a3a 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/rest/AuthController.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/rest/AuthController.java @@ -93,7 +93,7 @@ public class AuthController { onlineUserService.kickOutByUsername(loginRequest.getUsername()); } // 保存在线信息 - onlineUserService.save(jwtUser, token, request); + onlineUserService.saveUserJwtModelByToken(jwtUser, token, request); // 返回登录信息 return ResponseEntity.ok(authInfo); } diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/rest/OnlineController.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/rest/OnlineController.java index 18e37639..2e2753ff 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/rest/OnlineController.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/rest/OnlineController.java @@ -32,14 +32,14 @@ public class OnlineController { @GetMapping @PreAuthorize("@el.check()") public ResponseEntity> queryOnlineUser(String username, Pageable pageable) { - return new ResponseEntity<>(userOnlineService.queryOnlineUserPage(username, pageable), HttpStatus.OK); + return new ResponseEntity<>(userOnlineService.describeUserOnlineModelPage(username, pageable), HttpStatus.OK); } @ApiOperation("导出数据") @GetMapping(value = "/download") @PreAuthorize("@el.check()") public void exportOnlineUser(HttpServletResponse response, String username) throws IOException { - userOnlineService.downloadExcel(userOnlineService.selectOnlineUserByUsername(username), response); + userOnlineService.downloadUserOnlineModelExcel(userOnlineService.describeUserOnlineModelListByUsername(username), response); } @ApiOperation("踢出用户") diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/UserCacheService.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/UserCacheService.java index cd53dd1c..8daede9b 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/UserCacheService.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/UserCacheService.java @@ -10,7 +10,7 @@ public interface UserCacheService { * @param username 用户名 * @return UserJwtModel */ - UserJwtModel getUserCacheByUsername(String username); + UserJwtModel describeUserJwtModelByUsername(String username); /** * 添加缓存到Redis @@ -18,7 +18,7 @@ public interface UserCacheService { * @param userName 用户名 */ @Async - void addUserCache(String userName, UserJwtModel user); + void cacheUserJwtModelByUserName(String userName, UserJwtModel user); /** * 清理用户缓存信息 @@ -27,5 +27,5 @@ public interface UserCacheService { * @param userName 用户名 */ @Async - void cleanUserCacheByUsername(String userName); + void cleanUserJwtModelCacheByUsername(String userName); } diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/UserOnlineService.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/UserOnlineService.java index c4753fdd..a0485a48 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/UserOnlineService.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/UserOnlineService.java @@ -17,7 +17,7 @@ public interface UserOnlineService { * @param token / * @param request / */ - void save(UserJwtModel userJwtModel, String token, HttpServletRequest request); + void saveUserJwtModelByToken(UserJwtModel userJwtModel, String token, HttpServletRequest request); /** * 查询全部数据 @@ -26,7 +26,7 @@ public interface UserOnlineService { * @param pageable / * @return / */ - PageResult queryOnlineUserPage(String username, Pageable pageable); + PageResult describeUserOnlineModelPage(String username, Pageable pageable); /** * 查询全部数据,不分页 @@ -34,7 +34,7 @@ public interface UserOnlineService { * @param username / * @return / */ - List selectOnlineUserByUsername(String username); + List describeUserOnlineModelListByUsername(String username); /** * 退出登录 @@ -50,7 +50,7 @@ public interface UserOnlineService { * @param response / * @throws IOException / */ - void downloadExcel(List all, HttpServletResponse response) throws IOException; + void downloadUserOnlineModelExcel(List all, HttpServletResponse response) throws IOException; /** * 查询用户 @@ -58,7 +58,7 @@ public interface UserOnlineService { * @param key / * @return / */ - UserOnlineModel getOnlineUserByKey(String key); + UserOnlineModel describeUserOnlineModelByKey(String key); /** * 根据用户名强退用户 diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserCacheServiceImpl.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserCacheServiceImpl.java index 046d7f18..18c16877 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserCacheServiceImpl.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserCacheServiceImpl.java @@ -18,7 +18,7 @@ public class UserCacheServiceImpl implements UserCacheService { private RedisHelper redisHelper; @Override - public UserJwtModel getUserCacheByUsername(String username) { + public UserJwtModel describeUserJwtModelByUsername(String username) { // 转小写 username = StringUtil.lowerCase(username); if (StringUtil.isNotEmpty(username)) { @@ -30,7 +30,7 @@ public class UserCacheServiceImpl implements UserCacheService { @Override - public void addUserCache(String userName, UserJwtModel user) { + public void cacheUserJwtModelByUserName(String userName, UserJwtModel user) { // 转小写 userName = StringUtil.lowerCase(userName); if (StringUtil.isNotEmpty(userName)) { @@ -42,7 +42,7 @@ public class UserCacheServiceImpl implements UserCacheService { @Override - public void cleanUserCacheByUsername(String userName) { + public void cleanUserJwtModelCacheByUsername(String userName) { // 转小写 userName = StringUtil.lowerCase(userName); if (StringUtil.isNotEmpty(userName)) { diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserDetailsServiceImpl.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserDetailsServiceImpl.java index 96652c5d..a57ae4a7 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserDetailsServiceImpl.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserDetailsServiceImpl.java @@ -25,7 +25,7 @@ public class UserDetailsServiceImpl implements UserDetailsService { @Override public UserJwtModel loadUserByUsername(String username) { - UserJwtModel userJwtModel = userCacheService.getUserCacheByUsername(username); + UserJwtModel userJwtModel = userCacheService.describeUserJwtModelByUsername(username); if (userJwtModel == null) { User user = userService.getUserByUsername(username); if (user == null) { @@ -39,7 +39,7 @@ public class UserDetailsServiceImpl implements UserDetailsService { // 初始化JwtUserDto userJwtModel = new UserJwtModel(user, dataService.selectDeptIdByUserIdWithDeptId(user), authorities); // 添加缓存数据 - userCacheService.addUserCache(username, userJwtModel); + userCacheService.cacheUserJwtModelByUserName(username, userJwtModel); } } return userJwtModel; diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserOnlineServiceImpl.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserOnlineServiceImpl.java index 5f2bfc19..19cbe389 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserOnlineServiceImpl.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/core/service/impl/UserOnlineServiceImpl.java @@ -39,7 +39,7 @@ public class UserOnlineServiceImpl implements UserOnlineService { private final RedisHelper redisHelper; @Override - public void save(UserJwtModel userJwtModel, String token, HttpServletRequest request) { + public void saveUserJwtModelByToken(UserJwtModel userJwtModel, String token, HttpServletRequest request) { String dept = userJwtModel.getUser().getDept().getName(); String ip = BrowserUtil.getIp(request); String id = tokenProvider.getId(token); @@ -65,14 +65,14 @@ public class UserOnlineServiceImpl implements UserOnlineService { } @Override - public PageResult queryOnlineUserPage(String username, Pageable pageable) { - List onlineUserList = selectOnlineUserByUsername(username); + public PageResult describeUserOnlineModelPage(String username, Pageable pageable) { + List onlineUserList = describeUserOnlineModelListByUsername(username); List paging = PageUtil.softPaging(pageable.getPageNumber(), pageable.getPageSize(), onlineUserList); return PageUtil.toPage(paging, onlineUserList.size()); } @Override - public List selectOnlineUserByUsername(String username) { + public List describeUserOnlineModelListByUsername(String username) { String loginKey = SystemRedisKey.ONLINE_USER + (StringUtil.isBlank(username) ? "" : "*" + username); List keys = redisHelper.scan(loginKey + "*"); Collections.reverse(keys); @@ -91,7 +91,7 @@ public class UserOnlineServiceImpl implements UserOnlineService { } @Override - public void downloadExcel(List all, HttpServletResponse response) throws IOException { + public void downloadUserOnlineModelExcel(List all, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (UserOnlineModel user : all) { Map map = new LinkedHashMap<>(); @@ -107,7 +107,7 @@ public class UserOnlineServiceImpl implements UserOnlineService { } @Override - public UserOnlineModel getOnlineUserByKey(String key) { + public UserOnlineModel describeUserOnlineModelByKey(String key) { return redisHelper.get(key, UserOnlineModel.class); } diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/impl/RoleServiceImpl.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/impl/RoleServiceImpl.java index 0c626737..55b5a1a9 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/impl/RoleServiceImpl.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/impl/RoleServiceImpl.java @@ -223,7 +223,7 @@ public class RoleServiceImpl extends ServiceImpl implements Ro public void delCaches(Long id, List users) { users = CollectionUtil.isEmpty(users) ? userMapper.queryUserListByRoleId(id) : users; if (CollectionUtil.isNotEmpty(users)) { - users.forEach(item -> userCacheService.cleanUserCacheByUsername(item.getUsername())); + users.forEach(item -> userCacheService.cleanUserJwtModelCacheByUsername(item.getUsername())); Set userIds = users.stream().map(User::getId).collect(Collectors.toSet()); redisHelper.delByKeys(SystemRedisKey.DATA_USER, userIds); redisHelper.delByKeys(SystemRedisKey.MENU_USER, userIds); diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/impl/UserServiceImpl.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/impl/UserServiceImpl.java index fc483c70..b6bd9201 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/impl/UserServiceImpl.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/impl/UserServiceImpl.java @@ -277,6 +277,6 @@ public class UserServiceImpl extends ServiceImpl implements Us * @param username / */ private void flushCache(String username) { - userCacheService.cleanUserCacheByUsername(username); + userCacheService.cleanUserJwtModelCacheByUsername(username); } }