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/MesTypeEnum.java | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 59 insertions(+), 0 deletions(-) diff --git a/oying-system/src/main/java/com/oying/modules/message/common/MesTypeEnum.java b/oying-system/src/main/java/com/oying/modules/message/common/MesTypeEnum.java new file mode 100644 index 0000000..fcf6782 --- /dev/null +++ b/oying-system/src/main/java/com/oying/modules/message/common/MesTypeEnum.java @@ -0,0 +1,59 @@ +package com.oying.modules.message.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum MesTypeEnum { + //1=系统 2=订单 3=评价/留言 + SYSTEM(1, "系统"), + ORDER(2, "订单"), + COMMENT(3, "评价/留言"); + + private final Integer key; + private final String value; + + /** + * 根据key获取枚举实例 + * @param key key值 + * @return 对应的枚举实例,未找到返回null + */ + public static MesTypeEnum getByKey(Integer key) { + if (key == null) { + return null; + } + for (MesTypeEnum typeEnum : MesTypeEnum.values()) { + if (typeEnum.key.equals(key)) { + return typeEnum; + } + } + return null; + } + + /** + * 根据value获取枚举实例 + * @param value value值 + * @return 对应的枚举实例,未找到返回null + */ + public static MesTypeEnum getByValue(String value) { + if (value == null) { + return null; + } + for (MesTypeEnum typeEnum : MesTypeEnum.values()) { + if (typeEnum.value.equals(value)) { + return typeEnum; + } + } + return null; + } + + @Override + public String toString() { + return "MesTypeEnum{" + + "key=" + key + + ", value='" + value + '\'' + + ", name='" + this.name() + '\'' + + '}'; + } +} -- Gitblit v1.9.3