upd: 编码规范

This commit is contained in:
2025-04-09 19:57:56 +08:00
parent 747af5aa6c
commit f3719b3f1c
10 changed files with 25 additions and 25 deletions
@@ -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 续期判断
@@ -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);
}
@@ -32,14 +32,14 @@ public class OnlineController {
@GetMapping
@PreAuthorize("@el.check()")
public ResponseEntity<PageResult<UserOnlineModel>> 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("踢出用户")
@@ -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);
}
@@ -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<UserOnlineModel> queryOnlineUserPage(String username, Pageable pageable);
PageResult<UserOnlineModel> describeUserOnlineModelPage(String username, Pageable pageable);
/**
* 查询全部数据,不分页
@@ -34,7 +34,7 @@ public interface UserOnlineService {
* @param username /
* @return /
*/
List<UserOnlineModel> selectOnlineUserByUsername(String username);
List<UserOnlineModel> describeUserOnlineModelListByUsername(String username);
/**
* 退出登录
@@ -50,7 +50,7 @@ public interface UserOnlineService {
* @param response /
* @throws IOException /
*/
void downloadExcel(List<UserOnlineModel> all, HttpServletResponse response) throws IOException;
void downloadUserOnlineModelExcel(List<UserOnlineModel> all, HttpServletResponse response) throws IOException;
/**
* 查询用户
@@ -58,7 +58,7 @@ public interface UserOnlineService {
* @param key /
* @return /
*/
UserOnlineModel getOnlineUserByKey(String key);
UserOnlineModel describeUserOnlineModelByKey(String key);
/**
* 根据用户名强退用户
@@ -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)) {
@@ -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;
@@ -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<UserOnlineModel> queryOnlineUserPage(String username, Pageable pageable) {
List<UserOnlineModel> onlineUserList = selectOnlineUserByUsername(username);
public PageResult<UserOnlineModel> describeUserOnlineModelPage(String username, Pageable pageable) {
List<UserOnlineModel> onlineUserList = describeUserOnlineModelListByUsername(username);
List<UserOnlineModel> paging = PageUtil.softPaging(pageable.getPageNumber(), pageable.getPageSize(), onlineUserList);
return PageUtil.toPage(paging, onlineUserList.size());
}
@Override
public List<UserOnlineModel> selectOnlineUserByUsername(String username) {
public List<UserOnlineModel> describeUserOnlineModelListByUsername(String username) {
String loginKey = SystemRedisKey.ONLINE_USER + (StringUtil.isBlank(username) ? "" : "*" + username);
List<String> keys = redisHelper.scan(loginKey + "*");
Collections.reverse(keys);
@@ -91,7 +91,7 @@ public class UserOnlineServiceImpl implements UserOnlineService {
}
@Override
public void downloadExcel(List<UserOnlineModel> all, HttpServletResponse response) throws IOException {
public void downloadUserOnlineModelExcel(List<UserOnlineModel> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (UserOnlineModel user : all) {
Map<String, Object> 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);
}
@@ -223,7 +223,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
public void delCaches(Long id, List<User> 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<Long> userIds = users.stream().map(User::getId).collect(Collectors.toSet());
redisHelper.delByKeys(SystemRedisKey.DATA_USER, userIds);
redisHelper.delByKeys(SystemRedisKey.MENU_USER, userIds);
@@ -277,6 +277,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
* @param username /
*/
private void flushCache(String username) {
userCacheService.cleanUserCacheByUsername(username);
userCacheService.cleanUserJwtModelCacheByUsername(username);
}
}