From c75e415b61108679e9b1259d1598f5c29c913cd9 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Wed, 24 Apr 2024 16:47:32 +0800 Subject: [PATCH] =?UTF-8?q?enum=20=E5=A2=9E=E5=8A=A0=20valueOfType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/ai/enums/ChatRoleSourceEnum.java | 10 ++++++++++ .../yudao/module/ai/enums/ChatRoleVisibilityEnum.java | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleSourceEnum.java b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleSourceEnum.java index 388640f42..877da17ba 100644 --- a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleSourceEnum.java +++ b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleSourceEnum.java @@ -23,4 +23,14 @@ public enum ChatRoleSourceEnum { private String type; private String name; + + + public static ChatRoleSourceEnum valueOfType(String type) { + for (ChatRoleSourceEnum itemEnum : ChatRoleSourceEnum.values()) { + if (itemEnum.getType().equals(type)) { + return itemEnum; + } + } + throw new IllegalArgumentException("Invalid MessageType value: " + type); + } } diff --git a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleVisibilityEnum.java b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleVisibilityEnum.java index eef31935a..c8b09aedb 100644 --- a/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleVisibilityEnum.java +++ b/yudao-module-ai/yudao-module-ai-api/src/main/java/cn/iocoder/yudao/module/ai/enums/ChatRoleVisibilityEnum.java @@ -22,4 +22,15 @@ public enum ChatRoleVisibilityEnum { private String type; private String name; + + + public static ChatRoleVisibilityEnum valueOfType(String type) { + for (ChatRoleVisibilityEnum itemEnum : ChatRoleVisibilityEnum.values()) { + if (itemEnum.getType().equals(type)) { + return itemEnum; + } + } + throw new IllegalArgumentException("Invalid MessageType value: " + type); + } + }