修改密码接口更改

This commit is contained in:
tianfeng 2025-09-24 11:55:27 +08:00
parent 7cbcf3d0f3
commit 4aab90a066
5 changed files with 38 additions and 30 deletions

View File

@ -218,6 +218,9 @@ public enum UserErrorCode implements IResponseErrorCode {
//不在当前团队
,NOT_IN_TEAM(4073, "Not in team")
// 密码不正确
,PASSWORD_NOT_MATCH(4074, "password is incorrect")
;

View File

@ -45,12 +45,7 @@ public class AppUserAccountRestController extends BaseController {
/**
* 修改账号密码(账号).
*
* @eo.name 修改账号密码(账号).
* @eo.url /account-pwd-reset
* @eo.method post
* @eo.request-type json
* 删除账号密码
*/
@PostMapping(value = "/account-pwd-reset", consumes = MediaType.APPLICATION_JSON_VALUE)
public void accountPwdUpdate(@RequestBody @Validated AccountPwdResetCmd cmd) {

View File

@ -67,12 +67,7 @@ public class UserAuthTypeRestController extends BaseController {
}
/**
* 账号绑定认证关系.
*
* @eo.name 账号绑定认证关系.
* @eo.url /account-bind
* @eo.method post
* @eo.request-type json
* 设置账号密码.
*/
@PostMapping("/account-bind")
public void accountBindUserAuthType(@RequestBody @Validated AccountBindUserAuthTypeCmd cmd) {

View File

@ -1,16 +1,24 @@
package com.red.circle.other.app.command.user;
import com.red.circle.component.redis.service.RedisService;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.other.app.dto.cmd.user.user.AccountBindUserAuthTypeCmd;
import com.red.circle.other.infra.database.rds.entity.user.user.AccountAuth;
import com.red.circle.other.infra.database.rds.entity.user.user.AuthType;
import com.red.circle.other.infra.database.rds.entity.user.user.PasswordLog;
import com.red.circle.other.infra.database.rds.service.user.user.AccountAuthService;
import com.red.circle.other.infra.database.rds.service.user.user.AuthTypeService;
import com.red.circle.other.infra.database.rds.service.user.user.PasswordLogService;
import com.red.circle.other.inner.asserts.user.UserErrorCode;
import com.red.circle.other.inner.enums.user.AuthTypeEnum;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.red.circle.tool.core.collection.CollectionUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
@ -25,31 +33,33 @@ public class AccountBindUserAuthTypeCmdExe {
private final AuthTypeService authTypeService;
private final AccountAuthService accountAuthService;
private final PasswordLogService passwordLogService;
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()));
ResponseAssert.isTrue(UserErrorCode.ACCOUNT_PASSWORD_NOT_COMPLY_WITH_RULES, validatePassword(cmd.getPwd()));
AccountAuth accountAuth = accountAuthService.getByPassword(cmd.getOldPwd(), cmd.getReqUserId());
ResponseAssert.notNull(UserErrorCode.PASSWORD_NOT_MATCH, accountAuth);
ResponseAssert.isTrue(CommonErrorCode.OPERATING_FAILURE, accountAuthService.deleteById(accountAuth.getId()));
authTypeService.deleteAuthType(cmd.getReqUserId(), AuthTypeEnum.ACCOUNT.name());
accountAuthService.saveAccountAuth(new AccountAuth()
.setUserId(cmd.requiredReqUserId())
.setPwd(cmd.getPwd())
.setDel(Boolean.FALSE)
);
.setUserId(cmd.requiredReqUserId())
.setPwd(cmd.getPwd())
.setDel(Boolean.FALSE));
authTypeService.save(toAuthType(cmd.requiredReqUserId(), cmd));
passwordLogService.save(PasswordLog.builder()
.businessType("ACCOUNT_PASSWORD")
.operateType("UPDATE_PASSWORD")
.userId(cmd.getReqUserId())
.sysOrigin(cmd.requireReqSysOrigin())
.pwd(cmd.getPwd())
.imei(cmd.getReqImei())
.build());
}

View File

@ -23,4 +23,9 @@ public class AccountBindUserAuthTypeCmd extends AppExtCommand {
@NotBlank(message = "pwd required.")
private String pwd;
/**
* 旧密码
*/
private String oldPwd;
}