From 982313135d1c239fe3b20e4c5664781f92d40aca Mon Sep 17 00:00:00 2001 From: xin <1099200748@qq.com> Date: Thu, 31 Jul 2025 17:17:39 +0800 Subject: [PATCH] Merge branch 'master' into xin --- oying-system/src/main/java/com/oying/modules/message/common/PlatFormEnum.java | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 59 insertions(+), 0 deletions(-) diff --git a/oying-system/src/main/java/com/oying/modules/message/common/PlatFormEnum.java b/oying-system/src/main/java/com/oying/modules/message/common/PlatFormEnum.java new file mode 100644 index 0000000..384d0be --- /dev/null +++ b/oying-system/src/main/java/com/oying/modules/message/common/PlatFormEnum.java @@ -0,0 +1,59 @@ +package com.oying.modules.message.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum PlatFormEnum { + //1=买家 2=商户 3=骑手" + BUYER(1, "买家"), + MERCHANT(2, "商户"), + RIDE(3, "骑手"); + + private final Integer key; + private final String value; + + /** + * 根据key获取枚举实例 + * @param key key值 + * @return 对应的枚举实例,未找到返回null + */ + public static PlatFormEnum getByKey(Integer key) { + if (key == null) { + return null; + } + for (PlatFormEnum platFormEnum : PlatFormEnum.values()) { + if (platFormEnum.key.equals(key)) { + return platFormEnum; + } + } + return null; + } + + /** + * 根据value获取枚举实例 + * @param value value值 + * @return 对应的枚举实例,未找到返回null + */ + public static PlatFormEnum getByValue(String value) { + if (value == null) { + return null; + } + for (PlatFormEnum platFormEnum : PlatFormEnum.values()) { + if (platFormEnum.value.equals(value)) { + return platFormEnum; + } + } + return null; + } + + @Override + public String toString() { + return "PlatFormEnum{" + + "key=" + key + + ", value='" + value + '\'' + + ", name='" + this.name() + '\'' + + '}'; + } +} -- Gitblit v1.9.3