From 9359c9cb5b689d2d2594593cb810b9baa6978f68 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Mon, 6 Jul 2026 15:39:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(channel):=20=E4=BF=AE=E5=A4=8D=20inApp=20?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=96=B9=E5=BC=8F=E8=A2=AB=20Normalize=20?= =?UTF-8?q?=E8=AF=AF=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一映射为 canonical code inApp,并修正站内信显示名匹配。 --- .../Consts/IssueNotifyMethodCodes.cs | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/Oms.Domain/ChannelsAggregate/Consts/IssueNotifyMethodCodes.cs b/src/Oms.Domain/ChannelsAggregate/Consts/IssueNotifyMethodCodes.cs index 3d495ec..887cf44 100644 --- a/src/Oms.Domain/ChannelsAggregate/Consts/IssueNotifyMethodCodes.cs +++ b/src/Oms.Domain/ChannelsAggregate/Consts/IssueNotifyMethodCodes.cs @@ -8,22 +8,22 @@ public static class IssueNotifyMethodCodes public const string Feishu = "feishu"; public const string Wechat = "wechat"; - public static readonly HashSet All = - [ + public static readonly HashSet All = new(StringComparer.OrdinalIgnoreCase) + { InApp, Email, Sms, Feishu, Wechat - ]; + }; public static string GetDisplayName(string? code) => code?.Trim().ToLowerInvariant() switch { - InApp => "站内信", - Email => "邮件", - Sms => "短信", - Feishu => "飞书", - Wechat => "微信", + "inapp" => "站内信", + "email" => "邮件", + "sms" => "短信", + "feishu" => "飞书", + "wechat" => "微信", _ => code ?? string.Empty }; @@ -36,8 +36,9 @@ public static class IssueNotifyMethodCodes var parts = raw .Split([',', ';', ' '], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) - .Select(x => x.ToLowerInvariant()) - .Where(x => All.Contains(x)) + .Select(ToCanonical) + .Where(x => x != null) + .Cast() .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); @@ -54,4 +55,22 @@ public static class IssueNotifyMethodCodes return normalized.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToList(); } + + private static string? ToCanonical(string raw) + { + if (string.IsNullOrWhiteSpace(raw)) + { + return null; + } + + return raw.Trim().ToLowerInvariant() switch + { + "inapp" => InApp, + "email" => Email, + "sms" => Sms, + "feishu" => Feishu, + "wechat" => Wechat, + _ => null + }; + } }