From 8444a4f044f9c2b528172708da0c3d87a50e0935 Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 9 Apr 2025 20:31:32 +0800 Subject: [PATCH] =?UTF-8?q?upd:=20=E7=BC=96=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/UserDetailsServiceImpl.java | 2 +- .../system/rest/UserController.java | 26 +++++++++---------- .../system/service/UserService.java | 22 ++++++++-------- .../system/service/impl/UserServiceImpl.java | 22 ++++++++-------- 4 files changed, 36 insertions(+), 36 deletions(-) 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 2b854ca9..60ed4c41 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 @@ -27,7 +27,7 @@ public class UserDetailsServiceImpl implements UserDetailsService { public UserJwtModel loadUserByUsername(String username) { UserJwtModel userJwtModel = userCacheService.describeUserJwtModelByUsername(username); if (userJwtModel == null) { - User user = userService.getUserByUsername(username); + User user = userService.describeUserByUsername(username); if (user == null) { throw new BadRequestException("用户不存在"); } else { diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/rest/UserController.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/rest/UserController.java index bfff87bd..615c2d75 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/rest/UserController.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/rest/UserController.java @@ -64,7 +64,7 @@ public class UserController { @GetMapping(value = "/download") @PreAuthorize("@el.check('user:list')") public void exportUser(HttpServletResponse response, QueryUserRequest criteria) throws IOException { - userService.downloadExcel(userService.selectUserByCriteria(criteria), response); + userService.downloadUserExcel(userService.describeUserList(criteria), response); } @ApiOperation("查询用户") @@ -80,18 +80,18 @@ public class UserController { criteria.getDeptIds().addAll(deptService.describeChildDeptIdListByDeptIds(data)); } // 数据权限 - List dataScopes = dataService.describeDeptIdListByUserIdWithDeptId(userService.getUserByUsername(SecurityHelper.getCurrentUsername())); + List dataScopes = dataService.describeDeptIdListByUserIdWithDeptId(userService.describeUserByUsername(SecurityHelper.getCurrentUsername())); // criteria.getDeptIds() 不为空并且数据权限不为空则取交集 if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) { // 取交集 criteria.getDeptIds().retainAll(dataScopes); if (!CollectionUtil.isEmpty(criteria.getDeptIds())) { - return new ResponseEntity<>(userService.queryUserPage(criteria, page), HttpStatus.OK); + return new ResponseEntity<>(userService.describeUserPage(criteria, page), HttpStatus.OK); } } else { // 否则取并集 criteria.getDeptIds().addAll(dataScopes); - return new ResponseEntity<>(userService.queryUserPage(criteria, page), HttpStatus.OK); + return new ResponseEntity<>(userService.describeUserPage(criteria, page), HttpStatus.OK); } return new ResponseEntity<>(PageUtil.noData(), HttpStatus.OK); } @@ -112,7 +112,7 @@ public class UserController { @PreAuthorize("@el.check('user:edit')") public ResponseEntity updateUser(@Validated(User.Update.class) @RequestBody User resources) throws Exception { checkLevel(resources); - userService.updateUserById(resources); + userService.modifyUserById(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @@ -122,7 +122,7 @@ public class UserController { if (!resources.getId().equals(SecurityHelper.getCurrentUserId())) { throw new BadRequestException("不能修改他人资料"); } - userService.updateCenterInfoById(resources); + userService.modifyUserCenterInfoById(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @@ -134,7 +134,7 @@ public class UserController { 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()); + throw new BadRequestException("角色权限不足,不能删除:" + userService.describeUserById(id).getUsername()); } } userService.deleteUserByIds(ids); @@ -146,14 +146,14 @@ public class UserController { public ResponseEntity updatePassword(@RequestBody UpdateUserPasswordResponse passVo) throws Exception { String oldPass = RsaEncryptUtil.decryptByPrivateKey(RsaProperties.privateKey, passVo.getOldPass()); String newPass = RsaEncryptUtil.decryptByPrivateKey(RsaProperties.privateKey, passVo.getNewPass()); - User user = userService.getUserByUsername(SecurityHelper.getCurrentUsername()); + User user = userService.describeUserByUsername(SecurityHelper.getCurrentUsername()); if (!passwordEncoder.matches(oldPass, user.getPassword())) { throw new BadRequestException("修改失败,旧密码错误"); } if (passwordEncoder.matches(newPass, user.getPassword())) { throw new BadRequestException("新密码不能与旧密码相同"); } - userService.updatePasswordByUsername(user.getUsername(), passwordEncoder.encode(newPass)); + userService.modifyUserPasswordByUsername(user.getUsername(), passwordEncoder.encode(newPass)); return new ResponseEntity<>(HttpStatus.OK); } @@ -161,26 +161,26 @@ public class UserController { @PostMapping(value = "/resetPwd") public ResponseEntity resetPwd(@RequestBody Set ids) { String defaultPwd = passwordEncoder.encode("123456"); - userService.resetPasswordByIds(ids, defaultPwd); + userService.resetUserPasswordByIds(ids, defaultPwd); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation("修改头像") @PostMapping(value = "/updateAvatar") public ResponseEntity updateUserAvatar(@RequestParam MultipartFile avatar) { - return new ResponseEntity<>(userService.updateAvatarFile(avatar), HttpStatus.OK); + return new ResponseEntity<>(userService.modifyUserAvatarFile(avatar), HttpStatus.OK); } @ApiOperation("修改邮箱") @PostMapping(value = "/updateEmail/{code}") public ResponseEntity updateUserEmail(@PathVariable String code, @RequestBody User resources) throws Exception { String password = RsaEncryptUtil.decryptByPrivateKey(RsaProperties.privateKey, resources.getPassword()); - User user = userService.getUserByUsername(SecurityHelper.getCurrentUsername()); + User user = userService.describeUserByUsername(SecurityHelper.getCurrentUsername()); if (!passwordEncoder.matches(password, user.getPassword())) { throw new BadRequestException("密码错误"); } verificationCodeService.checkCodeAvailable(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey(), resources.getEmail(), code); - userService.updateEmailByUsername(user.getUsername(), resources.getEmail()); + userService.modifyUserEmailByUsername(user.getUsername(), resources.getEmail()); return new ResponseEntity<>(HttpStatus.OK); } diff --git a/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/UserService.java b/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/UserService.java index 669f3730..930e3085 100644 --- a/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/UserService.java +++ b/cutejava/cutejava-system/src/main/java/cn/odboy/application/system/service/UserService.java @@ -20,7 +20,7 @@ public interface UserService extends IService { * @param id ID * @return / */ - User getUserById(long id); + User describeUserById(long id); /** * 新增用户 @@ -35,7 +35,7 @@ public interface UserService extends IService { * @param resources / * @throws Exception / */ - void updateUserById(User resources) throws Exception; + void modifyUserById(User resources) throws Exception; /** * 删除用户 @@ -50,7 +50,7 @@ public interface UserService extends IService { * @param username / * @return / */ - User getUserByUsername(String username); + User describeUserByUsername(String username); /** * 修改密码 @@ -58,7 +58,7 @@ public interface UserService extends IService { * @param username 用户名 * @param encryptPassword 密码 */ - void updatePasswordByUsername(String username, String encryptPassword); + void modifyUserPasswordByUsername(String username, String encryptPassword); /** * 修改头像 @@ -66,7 +66,7 @@ public interface UserService extends IService { * @param file 文件 * @return / */ - Map updateAvatarFile(MultipartFile file); + Map modifyUserAvatarFile(MultipartFile file); /** * 修改邮箱 @@ -74,7 +74,7 @@ public interface UserService extends IService { * @param username 用户名 * @param email 邮箱 */ - void updateEmailByUsername(String username, String email); + void modifyUserEmailByUsername(String username, String email); /** * 查询全部 @@ -83,7 +83,7 @@ public interface UserService extends IService { * @param page 分页参数 * @return / */ - PageResult queryUserPage(QueryUserRequest criteria, Page page); + PageResult describeUserPage(QueryUserRequest criteria, Page page); /** * 查询全部不分页 @@ -91,7 +91,7 @@ public interface UserService extends IService { * @param criteria 条件 * @return / */ - List selectUserByCriteria(QueryUserRequest criteria); + List describeUserList(QueryUserRequest criteria); /** * 导出数据 @@ -100,14 +100,14 @@ public interface UserService extends IService { * @param response / * @throws IOException / */ - void downloadExcel(List queryAll, HttpServletResponse response) throws IOException; + void downloadUserExcel(List queryAll, HttpServletResponse response) throws IOException; /** * 用户自助修改资料 * * @param resources / */ - void updateCenterInfoById(User resources); + void modifyUserCenterInfoById(User resources); /** * 重置密码 @@ -115,5 +115,5 @@ public interface UserService extends IService { * @param ids 用户id * @param password 密码 */ - void resetPasswordByIds(Set ids, String password); + void resetUserPasswordByIds(Set ids, String password); } 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 b6bd9201..6714b03e 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 @@ -53,7 +53,7 @@ public class UserServiceImpl extends ServiceImpl implements Us private final UserOnlineService userOnlineService; @Override - public PageResult queryUserPage(QueryUserRequest criteria, Page page) { + public PageResult describeUserPage(QueryUserRequest criteria, Page page) { criteria.setOffset(page.offset()); List users = userMapper.queryUserPageByArgs(criteria, PageUtil.getCount(userMapper)).getRecords(); Long total = userMapper.getUserCountByArgs(criteria); @@ -61,13 +61,13 @@ public class UserServiceImpl extends ServiceImpl implements Us } @Override - public List selectUserByCriteria(QueryUserRequest criteria) { + public List describeUserList(QueryUserRequest criteria) { return userMapper.queryUserPageByArgs(criteria, PageUtil.getCount(userMapper)).getRecords(); } @Override @Transactional(rollbackFor = Exception.class) - public User getUserById(long id) { + public User describeUserById(long id) { String key = SystemRedisKey.USER_ID + id; User user = redisHelper.get(key, User.class); if (user == null) { @@ -99,7 +99,7 @@ public class UserServiceImpl extends ServiceImpl implements Us @Override @Transactional(rollbackFor = Exception.class) - public void updateUserById(User resources) { + public void modifyUserById(User resources) { User user = getById(resources.getId()); User user1 = userMapper.getUserByUsername(resources.getUsername()); User user2 = userMapper.getUserByEmail(resources.getEmail()); @@ -151,7 +151,7 @@ public class UserServiceImpl extends ServiceImpl implements Us @Override @Transactional(rollbackFor = Exception.class) - public void updateCenterInfoById(User resources) { + public void modifyUserCenterInfoById(User resources) { User user = getById(resources.getId()); User user1 = userMapper.getUserByPhone(resources.getPhone()); if (user1 != null && !user.getId().equals(user1.getId())) { @@ -181,20 +181,20 @@ public class UserServiceImpl extends ServiceImpl implements Us } @Override - public User getUserByUsername(String username) { + public User describeUserByUsername(String username) { return userMapper.getUserByUsername(username); } @Override @Transactional(rollbackFor = Exception.class) - public void updatePasswordByUsername(String username, String pass) { + public void modifyUserPasswordByUsername(String username, String pass) { userMapper.updatePasswordByUsername(username, pass, new Date()); flushCache(username); } @Override @Transactional(rollbackFor = Exception.class) - public void resetPasswordByIds(Set ids, String password) { + public void resetUserPasswordByIds(Set ids, String password) { List users = userMapper.selectByIds(ids); // 清除缓存 users.forEach(user -> { @@ -209,7 +209,7 @@ public class UserServiceImpl extends ServiceImpl implements Us @Override @Transactional(rollbackFor = Exception.class) - public Map updateAvatarFile(MultipartFile multipartFile) { + public Map modifyUserAvatarFile(MultipartFile multipartFile) { // 文件大小验证 FileUtil.checkSize(fileProperties.getAvatarMaxSize(), multipartFile.getSize()); // 验证文件上传的格式 @@ -236,13 +236,13 @@ public class UserServiceImpl extends ServiceImpl implements Us @Override @Transactional(rollbackFor = Exception.class) - public void updateEmailByUsername(String username, String email) { + public void modifyUserEmailByUsername(String username, String email) { userMapper.updateEmailByUsername(username, email); flushCache(username); } @Override - public void downloadExcel(List users, HttpServletResponse response) throws IOException { + public void downloadUserExcel(List users, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (User user : users) { List roles = user.getRoles().stream().map(Role::getName).collect(Collectors.toList());