Commit e8fb276a authored by renjie's avatar renjie

子用户bug

parent 13ddf354
...@@ -690,19 +690,18 @@ public class AccountServiceImpl implements AccountService { ...@@ -690,19 +690,18 @@ public class AccountServiceImpl implements AccountService {
throw new ClientRequestException(AccountErrorCode.CHILDMAX, "account cannot have more children"); throw new ClientRequestException(AccountErrorCode.CHILDMAX, "account cannot have more children");
} }
int nameNumber = existing.getChildCount(); int count = existing.getChildCount();
int time = subUsersRequestDto.getAmount(); int time = subUsersRequestDto.getAmount();
for (int i = 0; i < time; i++) { for (int i = 0; i < time; i++) {
if (nameNumber >= 1000) if (count >= 1000)
throw new ClientRequestException(AccountErrorCode.CHILDMAX, "account cannot have more children"); throw new ClientRequestException(AccountErrorCode.CHILDMAX, "account cannot have more children");
AccountDto user = new AccountDto(); AccountDto user = new AccountDto();
nameNumber++; if (i < 10)
if (nameNumber < 10) user.setName(existing.getName() + "00" + i);
user.setName(existing.getName() + "00" + nameNumber); else if (i< 100)
else if (nameNumber < 100) user.setName(existing.getName() + "0" + i);
user.setName(existing.getName() + "0" + nameNumber);
else else
user.setName(existing.getName() + nameNumber); user.setName(existing.getName() + i);
Account child = repository.findByName(user.getName()); Account child = repository.findByName(user.getName());
if (child != null) { if (child != null) {
...@@ -746,9 +745,10 @@ public class AccountServiceImpl implements AccountService { ...@@ -746,9 +745,10 @@ public class AccountServiceImpl implements AccountService {
// emailService.sendEmailVerification(user.getUsername(), user.getEmail(), user.getVerificationCode()); // emailService.sendEmailVerification(user.getUsername(), user.getEmail(), user.getVerificationCode());
log.info("new account has been created: " + account.getName()); log.info("new account has been created: " + account.getName());
count++;
} }
existing.setChildCount(nameNumber); existing.setChildCount(count);
repository.save(existing); repository.save(existing);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment