AccountInfo 的构建使用 Builder 模式。

This commit is contained in:
2023-03-12 13:29:07 +08:00
parent b4bccfe663
commit 5f1cb36235
6 changed files with 86 additions and 27 deletions

View File

@@ -69,7 +69,11 @@ public class AccountManagementService {
command.getPasswordConfirmation(),
command.getStatus(),
command.getRoleRefs(),
AccountInfo.of(command.getNickname(), command.getAvatar(), command.getSex()),
AccountInfo.builder()
.nickname(command.getNickname())
.avatar(command.getAvatar())
.sex(command.getSex())
.build(),
adminAuthLogic.getLoginIdAsLong());
accountRepository.save(account);
}

View File

@@ -17,7 +17,6 @@ import xyz.zhouxy.plusone.system.domain.model.account.AccountStatus;
import xyz.zhouxy.plusone.system.domain.model.account.Email;
import xyz.zhouxy.plusone.system.domain.model.account.MobilePhone;
import xyz.zhouxy.plusone.system.domain.model.account.Password;
import xyz.zhouxy.plusone.system.domain.model.account.Sex;
import xyz.zhouxy.plusone.system.domain.model.account.Username;
/**
@@ -82,7 +81,9 @@ public class RegisterAccountService {
Password.newPassword(command.getPassword(), command.getReenteredPassword()),
AccountStatus.AVAILABLE,
Set.of(DEFAULT_ROLE_ID),
AccountInfo.of(command.getNickname(), null, Sex.UNSET));
AccountInfo.builder()
.nickname(command.getNickname())
.build());
accountRepository.save(accountToSave);
}