feat(user): 新增重置密码接口及DTO
This commit is contained in:
@@ -97,4 +97,10 @@ public class UserController {
|
||||
public BaseResponse<Boolean> verifyMail(@RequestBody VerifyCodeDTO verifyCodeDTO) {
|
||||
return ResultUtils.success(userService.verifyMailCode(verifyCodeDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/resetPassWord")
|
||||
@Operation(summary = "重置密码",description = "重置密码接口")
|
||||
public BaseResponse<Boolean> resetPassWord(@RequestBody ResetPassWordDTO resetPassWordDTO) {
|
||||
return ResultUtils.success(userService.resetPassWord(resetPassWordDTO));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.yolo.keyborad.model.dto.user;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/12/4 19:17
|
||||
*/
|
||||
@Data
|
||||
public class ResetPassWordDTO {
|
||||
|
||||
@Schema(description = "邮箱地址")
|
||||
private String mailAddress;
|
||||
|
||||
@Schema(description = "密码")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "确认密码")
|
||||
private String confirmPassword;
|
||||
}
|
||||
@@ -24,4 +24,6 @@ public interface UserService extends IService<KeyboardUser> {
|
||||
void sendVerifyMail(SendMailDTO userRegisterDTO);
|
||||
|
||||
Boolean verifyMailCode(VerifyCodeDTO verifyCodeDTO);
|
||||
|
||||
Boolean resetPassWord(ResetPassWordDTO resetPassWordDTO);
|
||||
}
|
||||
|
||||
@@ -160,4 +160,22 @@ public class UserServiceImpl extends ServiceImpl<KeyboardUserMapper, KeyboardUse
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean resetPassWord(ResetPassWordDTO resetPassWordDTO) {
|
||||
KeyboardUser keyboardUser = keyboardUserMapper.selectOne(
|
||||
new LambdaQueryWrapper<KeyboardUser>()
|
||||
.eq(KeyboardUser::getEmail, resetPassWordDTO.getMailAddress())
|
||||
.eq(KeyboardUser::getStatus, false));
|
||||
|
||||
if (keyboardUser == null) {
|
||||
throw new BusinessException(ErrorCode.USER_NOT_FOUND);
|
||||
}
|
||||
if (resetPassWordDTO.getPassword().equals(resetPassWordDTO.getConfirmPassword())) {
|
||||
throw new BusinessException(ErrorCode.CONFIRM_PASSWORD_NOT_MATCH);
|
||||
}
|
||||
keyboardUser.setPassword(passwordEncoder.encode(resetPassWordDTO.getPassword()));
|
||||
return keyboardUserMapper.updateById(keyboardUser) > 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user