修改领域模型。
This commit is contained in:
@@ -27,7 +27,7 @@ public class AccountCreated extends DomainEvent {
|
||||
|
||||
public AccountCreated(Account account) {
|
||||
this.username = account.getUsername();
|
||||
this.email = account.getEmail();
|
||||
this.mobilePhone = account.getMobilePhone();
|
||||
this.email = account.getEmail().orElse(null);
|
||||
this.mobilePhone = account.getMobilePhone().orElse(null);
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ public class AccountLocked extends DomainEvent {
|
||||
|
||||
public AccountLocked(Account account) {
|
||||
this.username = account.getUsername();
|
||||
this.email = account.getEmail();
|
||||
this.mobilePhone = account.getMobilePhone();
|
||||
this.email = account.getEmail().orElse(null);
|
||||
this.mobilePhone = account.getMobilePhone().orElse(null);
|
||||
}
|
||||
}
|
||||
|
@@ -27,8 +27,8 @@ public class AccountPasswordChanged extends DomainEvent {
|
||||
|
||||
public AccountPasswordChanged(Account account) {
|
||||
this.username = account.getUsername();
|
||||
this.email = account.getEmail();
|
||||
this.mobilePhone = account.getMobilePhone();
|
||||
this.email = account.getEmail().orElse(null);
|
||||
this.mobilePhone = account.getMobilePhone().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -25,6 +25,6 @@ public class EmailChanged extends DomainEvent {
|
||||
|
||||
public EmailChanged(Account account) {
|
||||
this.username = account.getUsername();
|
||||
this.email = account.getEmail();
|
||||
this.email = account.getEmail().orElse(null);
|
||||
}
|
||||
}
|
||||
|
@@ -25,6 +25,6 @@ public class MobilePhoneChanged extends DomainEvent {
|
||||
|
||||
public MobilePhoneChanged(Account account) {
|
||||
this.username = account.getUsername();
|
||||
this.mobilePhone = account.getMobilePhone();
|
||||
this.mobilePhone = account.getMobilePhone().orElse(null);
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ public class UsernameChanged extends DomainEvent {
|
||||
|
||||
public UsernameChanged(Account account) {
|
||||
this.username = account.getUsername();
|
||||
this.email = account.getEmail();
|
||||
this.mobilePhone = account.getMobilePhone();
|
||||
this.email = account.getEmail().orElse(null);
|
||||
this.mobilePhone = account.getMobilePhone().orElse(null);
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,6 @@ import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import xyz.zhouxy.plusone.domain.AggregateRoot;
|
||||
import xyz.zhouxy.plusone.domain.IWithVersion;
|
||||
@@ -30,17 +28,17 @@ public class Account extends AggregateRoot<Long> implements IWithVersion {
|
||||
|
||||
// ===================== 字段 ====================
|
||||
private Long id;
|
||||
private @Getter Username username;
|
||||
private @Getter Email email;
|
||||
private @Getter MobilePhone mobilePhone;
|
||||
private Username username;
|
||||
private Email email;
|
||||
private MobilePhone mobilePhone;
|
||||
private Password password;
|
||||
private @Getter AccountStatus status;
|
||||
private @Getter AccountInfo accountInfo;
|
||||
private AccountStatus status;
|
||||
private AccountInfo accountInfo;
|
||||
private Set<Long> roleRefs = new HashSet<>();
|
||||
|
||||
private @Getter Long createdBy;
|
||||
private @Getter @Setter Long updatedBy;
|
||||
private @Getter long version;
|
||||
private Long createdBy;
|
||||
private Long updatedBy;
|
||||
private long version;
|
||||
|
||||
public void setUsername(Username username) {
|
||||
this.username = username;
|
||||
@@ -223,11 +221,48 @@ public class Account extends AggregateRoot<Long> implements IWithVersion {
|
||||
return Optional.ofNullable(id);
|
||||
}
|
||||
|
||||
public Set<Long> getRoleIds() {
|
||||
return Set.copyOf(this.roleRefs);
|
||||
public Username getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public Optional<Email> getEmail() {
|
||||
return Optional.ofNullable(email);
|
||||
}
|
||||
|
||||
public Optional<MobilePhone> getMobilePhone() {
|
||||
return Optional.ofNullable(mobilePhone);
|
||||
}
|
||||
|
||||
Password getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public AccountStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public AccountInfo getAccountInfo() {
|
||||
return accountInfo;
|
||||
}
|
||||
|
||||
public Set<Long> getRoleIds() {
|
||||
return Set.copyOf(roleRefs);
|
||||
}
|
||||
|
||||
public Optional<Long> getCreatedBy() {
|
||||
return Optional.ofNullable(createdBy);
|
||||
}
|
||||
|
||||
public Optional<Long> getUpdatedBy() {
|
||||
return Optional.ofNullable(updatedBy);
|
||||
}
|
||||
|
||||
public void setUpdatedBy(long updatedBy) {
|
||||
this.updatedBy = updatedBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package xyz.zhouxy.plusone.system.domain.model.account;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
@@ -13,13 +14,12 @@ import xyz.zhouxy.plusone.domain.IValueObject;
|
||||
*
|
||||
* @author <a href="https://gitee.com/zhouxy108">ZhouXY</a>
|
||||
*/
|
||||
@Getter
|
||||
@ToString
|
||||
public class AccountInfo implements IValueObject {
|
||||
|
||||
private final Nickname nickname;
|
||||
private final URL avatar;
|
||||
private final Sex sex;
|
||||
private final @Getter Sex sex;
|
||||
|
||||
private AccountInfo(Nickname nickname, URL avatar, Sex sex) {
|
||||
this.nickname = nickname;
|
||||
@@ -40,4 +40,12 @@ public class AccountInfo implements IValueObject {
|
||||
}
|
||||
return new AccountInfo(Nickname.ofNullable(nickname), avatarURL, sex);
|
||||
}
|
||||
|
||||
public Optional<Nickname> getNickname() {
|
||||
return Optional.ofNullable(nickname);
|
||||
}
|
||||
|
||||
public Optional<URL> getAvatar() {
|
||||
return Optional.ofNullable(avatar);
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.ToString;
|
||||
import xyz.zhouxy.plusone.domain.AggregateRoot;
|
||||
@@ -115,7 +114,7 @@ public class Dict extends AggregateRoot<Long> implements IWithLabel, IWithVersio
|
||||
}
|
||||
|
||||
public Set<DictValue> getValues() {
|
||||
return this.values.values().stream().collect(Collectors.toSet());
|
||||
return Set.copyOf(this.values.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user