新增修改密码接口

This commit is contained in:
tianfeng 2025-09-25 12:00:18 +08:00
parent 4aab90a066
commit 77d9d1e249
4 changed files with 40 additions and 0 deletions

View File

@ -74,6 +74,14 @@ public class UserAuthTypeRestController extends BaseController {
userAuthTypeService.accountBindUserAuthType(cmd); userAuthTypeService.accountBindUserAuthType(cmd);
} }
/**
* 修改账号密码.
*/
@PostMapping("/account-update")
public void accountUpdate(@RequestBody @Validated AccountBindUserAuthTypeCmd cmd) {
userAuthTypeService.accountUpdate(cmd);
}
/** /**
* 账号是否已经绑定. * 账号是否已经绑定.
* *

View File

@ -36,6 +36,31 @@ public class AccountBindUserAuthTypeCmdExe {
private final PasswordLogService passwordLogService; private final PasswordLogService passwordLogService;
public void execute(AccountBindUserAuthTypeCmd cmd) { public void execute(AccountBindUserAuthTypeCmd cmd) {
AuthType authType = authTypeService.getAuthInfo(
AuthTypeEnum.ACCOUNT.name(),
cmd.requiredReqUserIdStr()
);
// 4032 已被绑定
ResponseAssert.isNull(UserErrorCode.ALREADY_USED, authType);
AccountAuth accountAuth = accountAuthService.getByUserId(cmd.requiredReqUserId());
ResponseAssert.isNull(UserErrorCode.ALREADY_USED, accountAuth);
//4061 密码不符合规则
ResponseAssert.isTrue(UserErrorCode.ACCOUNT_PASSWORD_NOT_COMPLY_WITH_RULES,
validatePassword(cmd.getPwd()));
accountAuthService.saveAccountAuth(new AccountAuth()
.setUserId(cmd.requiredReqUserId())
.setPwd(cmd.getPwd())
.setDel(Boolean.FALSE)
);
authTypeService.save(toAuthType(cmd.requiredReqUserId(), cmd));
}
public void accountUpdate(AccountBindUserAuthTypeCmd cmd) {
//4061 密码不符合规则 //4061 密码不符合规则
ResponseAssert.isTrue(UserErrorCode.ACCOUNT_PASSWORD_NOT_COMPLY_WITH_RULES, validatePassword(cmd.getPwd())); ResponseAssert.isTrue(UserErrorCode.ACCOUNT_PASSWORD_NOT_COMPLY_WITH_RULES, validatePassword(cmd.getPwd()));

View File

@ -56,6 +56,11 @@ public class UserAuthTypeServiceImpl implements UserAuthTypeService {
accountBindUserAuthTypeCmdExe.execute(cmd); accountBindUserAuthTypeCmdExe.execute(cmd);
} }
@Override
public void accountUpdate(AccountBindUserAuthTypeCmd cmd) {
accountBindUserAuthTypeCmdExe.accountUpdate(cmd);
}
@Override @Override
public Boolean accountIsBind(AppExtCommand cmd) { public Boolean accountIsBind(AppExtCommand cmd) {
return accountIsBindCmdExe.execute(cmd); return accountIsBindCmdExe.execute(cmd);

View File

@ -21,6 +21,8 @@ public interface UserAuthTypeService {
void accountBindUserAuthType(AccountBindUserAuthTypeCmd cmd); void accountBindUserAuthType(AccountBindUserAuthTypeCmd cmd);
void accountUpdate(AccountBindUserAuthTypeCmd cmd);
Boolean accountIsBind(AppExtCommand cmd); Boolean accountIsBind(AppExtCommand cmd);
void restoreAuthDelByUserId(Long userId); void restoreAuthDelByUserId(Long userId);