mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	chore: 优化部分方法排序
This commit is contained in:
		| @@ -25,8 +25,8 @@ import top.continew.admin.system.model.req.UserReq; | ||||
| import top.continew.admin.system.model.req.UserRoleUpdateReq; | ||||
| import top.continew.admin.system.model.resp.UserDetailResp; | ||||
| import top.continew.admin.system.model.resp.UserResp; | ||||
| import top.continew.starter.extension.crud.service.BaseService; | ||||
| import top.continew.starter.data.mybatis.plus.service.IService; | ||||
| import top.continew.starter.extension.crud.service.BaseService; | ||||
|  | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.List; | ||||
| @@ -47,6 +47,22 @@ public interface UserService extends BaseService<UserResp, UserDetailResp, UserQ | ||||
|      */ | ||||
|     Long add(UserDO user); | ||||
|  | ||||
|     /** | ||||
|      * 重置密码 | ||||
|      * | ||||
|      * @param req 重置信息 | ||||
|      * @param id  ID | ||||
|      */ | ||||
|     void resetPassword(UserPasswordResetReq req, Long id); | ||||
|  | ||||
|     /** | ||||
|      * 修改角色 | ||||
|      * | ||||
|      * @param updateReq 修改信息 | ||||
|      * @param id        ID | ||||
|      */ | ||||
|     void updateRole(UserRoleUpdateReq updateReq, Long id); | ||||
|  | ||||
|     /** | ||||
|      * 上传头像 | ||||
|      * | ||||
| @@ -73,6 +89,14 @@ public interface UserService extends BaseService<UserResp, UserDetailResp, UserQ | ||||
|      */ | ||||
|     void updatePassword(String oldPassword, String newPassword, Long id); | ||||
|  | ||||
|     /** | ||||
|      * 密码是否已过期 | ||||
|      * | ||||
|      * @param pwdResetTime 上次重置密码时间 | ||||
|      * @return 是否过期 | ||||
|      */ | ||||
|     boolean isPasswordExpired(LocalDateTime pwdResetTime); | ||||
|  | ||||
|     /** | ||||
|      * 修改手机号 | ||||
|      * | ||||
| @@ -91,22 +115,6 @@ public interface UserService extends BaseService<UserResp, UserDetailResp, UserQ | ||||
|      */ | ||||
|     void updateEmail(String newEmail, String oldPassword, Long id); | ||||
|  | ||||
|     /** | ||||
|      * 重置密码 | ||||
|      * | ||||
|      * @param req 重置信息 | ||||
|      * @param id  ID | ||||
|      */ | ||||
|     void resetPassword(UserPasswordResetReq req, Long id); | ||||
|  | ||||
|     /** | ||||
|      * 修改角色 | ||||
|      * | ||||
|      * @param updateReq 修改信息 | ||||
|      * @param id        ID | ||||
|      */ | ||||
|     void updateRole(UserRoleUpdateReq updateReq, Long id); | ||||
|  | ||||
|     /** | ||||
|      * 根据用户名查询 | ||||
|      * | ||||
| @@ -138,12 +146,4 @@ public interface UserService extends BaseService<UserResp, UserDetailResp, UserQ | ||||
|      * @return 用户数量 | ||||
|      */ | ||||
|     Long countByDeptIds(List<Long> deptIds); | ||||
|  | ||||
|     /** | ||||
|      * 密码是否已过期 | ||||
|      *  | ||||
|      * @param pwdResetTime 上次重置密码时间 | ||||
|      * @return 是否过期 | ||||
|      */ | ||||
|     boolean isPasswordExpired(LocalDateTime pwdResetTime); | ||||
| } | ||||
|   | ||||
| @@ -17,6 +17,7 @@ | ||||
| package top.continew.admin.system.service.impl; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import lombok.RequiredArgsConstructor; | ||||
| import org.springframework.security.crypto.password.PasswordEncoder; | ||||
| import org.springframework.stereotype.Service; | ||||
| @@ -43,6 +44,9 @@ public class UserPasswordHistoryServiceImpl implements UserPasswordHistoryServic | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
|     public void add(Long userId, String password, int count) { | ||||
|         if (StrUtil.isBlank(password)) { | ||||
|             return; | ||||
|         } | ||||
|         baseMapper.insert(new UserPasswordHistoryDO(userId, password)); | ||||
|         // 删除过期历史密码 | ||||
|         baseMapper.deleteExpired(userId, count); | ||||
|   | ||||
| @@ -158,6 +158,21 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes | ||||
|         super.delete(ids); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void resetPassword(UserPasswordResetReq req, Long id) { | ||||
|         UserDO user = super.getById(id); | ||||
|         user.setPassword(req.getNewPassword()); | ||||
|         user.setPwdResetTime(LocalDateTime.now()); | ||||
|         baseMapper.updateById(user); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateRole(UserRoleUpdateReq updateReq, Long id) { | ||||
|         super.getById(id); | ||||
|         // 保存用户和角色关联 | ||||
|         userRoleService.add(updateReq.getRoleIds(), id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String uploadAvatar(MultipartFile avatarFile, Long id) { | ||||
|         String avatarImageType = FileNameUtil.extName(avatarFile.getOriginalFilename()); | ||||
| @@ -241,21 +256,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes | ||||
|         baseMapper.lambdaUpdate().set(UserDO::getEmail, newEmail).eq(UserDO::getId, id).update(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void resetPassword(UserPasswordResetReq req, Long id) { | ||||
|         UserDO user = super.getById(id); | ||||
|         user.setPassword(req.getNewPassword()); | ||||
|         user.setPwdResetTime(LocalDateTime.now()); | ||||
|         baseMapper.updateById(user); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateRole(UserRoleUpdateReq updateReq, Long id) { | ||||
|         super.getById(id); | ||||
|         // 保存用户和角色关联 | ||||
|         userRoleService.add(updateReq.getRoleIds(), id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public UserDO getByUsername(String username) { | ||||
|         return baseMapper.selectByUsername(username); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user