diff --git a/plusone-basic/plusone-basic-domain/src/main/java/xyz/zhouxy/plusone/constant/EntityStatus.java b/plusone-basic/plusone-basic-domain/src/main/java/xyz/zhouxy/plusone/constant/EntityStatus.java index d8d3501..752e31e 100644 --- a/plusone-basic/plusone-basic-domain/src/main/java/xyz/zhouxy/plusone/constant/EntityStatus.java +++ b/plusone-basic/plusone-basic-domain/src/main/java/xyz/zhouxy/plusone/constant/EntityStatus.java @@ -1,5 +1,9 @@ package xyz.zhouxy.plusone.constant; +import java.util.Collection; + +import javax.annotation.Nonnull; + import xyz.zhouxy.plusone.commons.util.Enumeration; /** @@ -9,24 +13,24 @@ import xyz.zhouxy.plusone.commons.util.Enumeration; */ public final class EntityStatus extends Enumeration { - private EntityStatus(int value, String name) { - super(value, name); + private EntityStatus(int id, @Nonnull String name) { + super(id, name); } // 常量 public static final EntityStatus AVAILABLE = new EntityStatus(0, "正常"); public static final EntityStatus DISABLED = new EntityStatus(1, "禁用"); - private static final EnumerationValuesHolder ENUMERATION_VALUES = new EnumerationValuesHolder<>( - AVAILABLE, - DISABLED); + private static final ValueSet VALUE_SET = new ValueSet<>( + AVAILABLE, DISABLED); - public static EntityStatus of(int value) { - return ENUMERATION_VALUES.get(value); + @Nonnull + public static EntityStatus of(int id) { + return VALUE_SET.get(id); } - @Override - public String toString() { - return "EntityStatus" + super.toString(); + @Nonnull + public static Collection constants() { + return VALUE_SET.getValues(); } } diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/result/MenuViewObject.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/result/MenuViewObject.java index 316eafe..1870391 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/result/MenuViewObject.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/query/result/MenuViewObject.java @@ -109,7 +109,7 @@ public class MenuViewObject implements IWithOrderNumber { viewObject.icon = menu.getIcon(); viewObject.hidden = menu.isHidden(); viewObject.orderNumber = menu.getOrderNumber(); - viewObject.status = menu.getStatus().getValue(); + viewObject.status = menu.getStatus().getId(); viewObject.remarks = menu.getRemarks(); if (viewObject.type == MenuType.MENU_ITEM.ordinal()) { viewObject.component = menu.getComponent(); diff --git a/plusone-system/plusone-system-domain/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountStatus.java b/plusone-system/plusone-system-domain/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountStatus.java index f49ad82..b5e9ba7 100644 --- a/plusone-system/plusone-system-domain/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountStatus.java +++ b/plusone-system/plusone-system-domain/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountStatus.java @@ -1,5 +1,9 @@ package xyz.zhouxy.plusone.system.domain.model.account; +import java.util.Collection; + +import javax.annotation.Nonnull; + import lombok.Getter; import xyz.zhouxy.plusone.commons.util.Enumeration; import xyz.zhouxy.plusone.domain.IValueObject; @@ -12,18 +16,23 @@ import xyz.zhouxy.plusone.domain.IValueObject; @Getter public final class AccountStatus extends Enumeration implements IValueObject { - private AccountStatus(int value, String name) { - super(value, name); + private AccountStatus(int id, @Nonnull String name) { + super(id, name); } public static final AccountStatus AVAILABLE = new AccountStatus(0, "账号正常"); public static final AccountStatus LOCKED = new AccountStatus(1, "账号被锁定"); - private static final EnumerationValuesHolder ENUMERATION_VALUES = new EnumerationValuesHolder<>( + private static final ValueSet VALUE_SET = new ValueSet<>( AVAILABLE, LOCKED); - public static AccountStatus of(int value) { - return ENUMERATION_VALUES.get(value); + public static AccountStatus of(int id) { + return VALUE_SET.get(id); + } + + @Nonnull + public static Collection constants() { + return VALUE_SET.getValues(); } } diff --git a/plusone-system/plusone-system-domain/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/Sex.java b/plusone-system/plusone-system-domain/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/Sex.java index 2430bbc..2f66038 100644 --- a/plusone-system/plusone-system-domain/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/Sex.java +++ b/plusone-system/plusone-system-domain/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/Sex.java @@ -1,5 +1,7 @@ package xyz.zhouxy.plusone.system.domain.model.account; +import java.util.Collection; + import javax.annotation.Nonnull; import xyz.zhouxy.plusone.commons.util.Enumeration; @@ -18,16 +20,19 @@ public final class Sex extends Enumeration implements IValueObject { @Nonnull public static final Sex FEMALE = new Sex(2, "女性"); - private Sex(int value, String name) { - super(value, name); + private Sex(int id, @Nonnull String name) { + super(id, name); } - private static EnumerationValuesHolder values = new EnumerationValuesHolder<>( - UNSET, - MALE, - FEMALE); + private static final ValueSet VALUE_SET = new ValueSet<>(UNSET, MALE, FEMALE); + @Nonnull public static Sex of(int value) { - return values.get(value); + return VALUE_SET.get(value); + } + + @Nonnull + public static Collection constants() { + return VALUE_SET.getValues(); } } diff --git a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountRepositoryImpl.java b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountRepositoryImpl.java index 32ec762..161284d 100644 --- a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountRepositoryImpl.java +++ b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountRepositoryImpl.java @@ -206,9 +206,9 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport .addValue("password", entity.getPassword().value()) .addValue("salt", entity.getPassword().getSalt()) .addValue("avatar", accountInfo.getAvatar().toString()) - .addValue("sex", accountInfo.getSex().getValue()) + .addValue("sex", accountInfo.getSex().getId()) .addValue("nickname", getValueOrNull(accountInfo.getNickname())) - .addValue("status", entity.getStatus().getValue()) + .addValue("status", entity.getStatus().getId()) .addValue("createdBy", entity.getCreatedBy()) .addValue("createTime", now) .addValue("updatedBy", entity.getUpdatedBy()) diff --git a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/menu/MenuRepositoryImpl.java b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/menu/MenuRepositoryImpl.java index 93b9e97..e09fa0d 100644 --- a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/menu/MenuRepositoryImpl.java +++ b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/menu/MenuRepositoryImpl.java @@ -188,7 +188,7 @@ public class MenuRepositoryImpl extends JdbcRepositorySupport implem .addValue("icon", entity.getIcon()) .addValue("hidden", entity.isHidden()) .addValue("orderNumber", entity.getOrderNumber()) - .addValue("status", entity.getStatus().getValue()) + .addValue("status", entity.getStatus().getId()) .addValue("remarks", entity.getRemarks()) .addValue("component", entity.getComponent()) .addValue("cache", entity.getCache()) diff --git a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/role/RoleRepositoryImpl.java b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/role/RoleRepositoryImpl.java index 060718f..8d6657d 100644 --- a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/role/RoleRepositoryImpl.java +++ b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/role/RoleRepositoryImpl.java @@ -135,7 +135,7 @@ public class RoleRepositoryImpl extends JdbcRepositorySupport implem .addValue("id", id) .addValue("name", entity.getName()) .addValue("identifier", entity.getIdentifier()) - .addValue("status", entity.getStatus().getValue()) + .addValue("status", entity.getStatus().getId()) .addValue("remarks", entity.getRemarks()) .addValue("createTime", now) .addValue("createdBy", loginId)