BUGFIX:同一浏览器切换版本登录时,密码被置空

This commit is contained in:
2025-08-13 16:45:30 +08:00
parent 1e25ae36f1
commit c28db81893
5 changed files with 35 additions and 10 deletions

View File

@@ -304,7 +304,9 @@ public class AccountController {
@PostMapping("deleteSubAccount")
@ApiOperation(value = "子账号删除")
public Response<Boolean> deleteSubAccount(@Valid @RequestBody AddSubAccountDTO addSubAccountDTO) {
return Response.success(accountService.deleteSubAccount(addSubAccountDTO));
// return Response.success(accountService.deleteSubAccount(addSubAccountDTO));
accountService.removeSubAccount(addSubAccountDTO, true);
return Response.success();
}
@PostMapping("subAccountList")

View File

@@ -125,6 +125,9 @@ public class Account implements Serializable {
private BigDecimal creditsUsageLimit;
// 学校分配的积分使用情况
private BigDecimal creditsUsage = BigDecimal.ZERO;
private Integer subAccountNum;
private String invitationCode;

View File

@@ -2,11 +2,17 @@ package com.ai.da.model.dto;
import com.ai.da.mapper.primary.entity.Account;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
public class AddSubAccountDTO extends Account {
private List<Long> deleteIdList;
public AddSubAccountDTO(List<Long> deleteIdList) {
this.deleteIdList = deleteIdList;
}
}

View File

@@ -205,6 +205,8 @@ public interface AccountService extends IService<Account> {
Boolean deleteSubAccount(AddSubAccountDTO addSubAccountDTO);
void removeSubAccount(AddSubAccountDTO addSubAccountDTO, boolean returnCredits);
PageBaseResponse<Account> subAccountList(SubAccountPageDTO subAccountPageDTO);
Account accountDetail(Long id);

View File

@@ -132,10 +132,12 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
Account account = getOneByEmail(accountDTO.getEmail());
//用户有效期校验
validateUserValidaExpire(account);
if ("Third-000000".equals(account.getUserPassword())) {
if ("Third-000000".equals(account.getUserPassword()) && !StringUtil.isNullOrEmpty(accountDTO.getPassword())) {
account.setUserPassword(accountDTO.getPassword());
accountMapper.updateById(account);
} else {
} else if ("Third-000000".equals(account.getUserPassword())){
throw new BusinessException("Password cannot be empty");
} else {
if (!account.getUserPassword().equals(accountDTO.getPassword())) {
throw new BusinessException("password.error", ResultEnum.PROMPT.getCode());
}
@@ -1161,10 +1163,14 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
@Override
public Boolean designWorksRegister(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO) {
log.info("注册账号。邮箱:{}", accountDesignWorksRegisterDTO.getUserEmail() );
QueryWrapper<Account> qw = new QueryWrapper<>();
qw.eq("BINARY user_email", accountDesignWorksRegisterDTO.getUserEmail());
List<Account> accountList = accountMapper.selectList(qw);
if (CollectionUtil.isNotEmpty(accountList)) {
QueryWrapper<Account> qwA = new QueryWrapper<>();
qwA.eq("BINARY user_email", accountDesignWorksRegisterDTO.getUserEmail());
List<Account> accountList = accountMapper.selectList(qwA);
QueryWrapper<TrialOrder> qwT = new QueryWrapper<>();
qwT.eq("BINARY email", accountDesignWorksRegisterDTO.getUserEmail());
List<TrialOrder> trialOrders = trialOrderMapper.selectList(qwT);
if (CollectionUtil.isNotEmpty(accountList) || CollectionUtil.isNotEmpty(trialOrders)) {
throw new BusinessException("The email has already been registered");
}
@@ -2032,9 +2038,12 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
Account account = accounts.get(0);
validateUserValidaExpire(account);
if ("Third-000000".equals(account.getUserPassword())) {
if ("Third-000000".equals(account.getUserPassword()) && !StringUtil.isNullOrEmpty(accountDTO.getPassword())) {
account.setUserPassword(accountDTO.getPassword());
accountMapper.updateById(account);
} else if ("Third-000000".equals(account.getUserPassword())){
throw new BusinessException("Password cannot be empty");
} else {
if (!account.getUserPassword().equals(accountDTO.getPassword())) {
throw new BusinessException("password.error", ResultEnum.PROMPT.getCode());
@@ -2092,14 +2101,16 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
qw.lambda().eq(Account::getUserPassword, accountDTO.getPassword());
accounts = accountMapper.selectList(qw);
if (CollectionUtil.isEmpty(accounts)) {
throw new BusinessException("Password error.");
throw new BusinessException("password.error");
}
Account account = accounts.get(0);
validateUserValidaExpire(account);
if ("Third-000000".equals(account.getUserPassword())) {
if ("Third-000000".equals(account.getUserPassword()) && !StringUtil.isNullOrEmpty(accountDTO.getPassword())) {
account.setUserPassword(accountDTO.getPassword());
accountMapper.updateById(account);
} else if ("Third-000000".equals(account.getUserPassword())){
throw new BusinessException("Password cannot be empty");
} else {
if (!account.getUserPassword().equals(accountDTO.getPassword())) {
throw new BusinessException("password.error", ResultEnum.PROMPT.getCode());
@@ -2192,6 +2203,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
if (isUsernameExists(account.getOrganizationName(), addSubAccountDTO.getUserName())) {
throw new BusinessException("This organization already has an account with the same username.");
}
// 之后是否需要检验密码不能设置为空
// 校验当前账号邮箱是否有个人账号
Account subAccount = accountMapper.selectOne(new QueryWrapper<Account>().eq("user_email", addSubAccountDTO.getUserEmail()));