| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- namespace Admin.NET.Plugin.AiDOP.Infrastructure.S8;
- /// <summary>
- /// S8-SEVERITY-FOLLOW-SERIOUS-STANDARDIZE-EXEC-1:S8 异常 severity 业务枚举。
- /// 当前阶段只保留 FOLLOW(关注)/ SERIOUS(严重)两档;
- /// 旧值 LOW/MEDIUM/HIGH/CRITICAL 仅作为 legacy 兼容输入,新写入必须落 FOLLOW/SERIOUS。
- /// </summary>
- public static class S8SeverityCode
- {
- public const string Follow = "FOLLOW";
- public const string Serious = "SERIOUS";
- /// <summary>归一化:旧值/空值/新值 -> FOLLOW / SERIOUS。空值默认 FOLLOW。</summary>
- public static string Normalize(string? code)
- {
- if (string.IsNullOrWhiteSpace(code)) return Follow;
- return code.Trim().ToUpperInvariant() switch
- {
- "FOLLOW" => Follow,
- "LOW" => Follow,
- "MEDIUM" => Follow,
- "SERIOUS" => Serious,
- "HIGH" => Serious,
- "CRITICAL" => Serious,
- _ => Follow,
- };
- }
- public static bool IsFollow(string? code) => Normalize(code) == Follow;
- public static bool IsSerious(string? code) => Normalize(code) == Serious;
- /// <summary>新值或旧值合法(用于 legacy 查询参数兼容)。</summary>
- public static bool IsValid(string? code)
- {
- if (string.IsNullOrWhiteSpace(code)) return false;
- return code.Trim().ToUpperInvariant() switch
- {
- "FOLLOW" or "SERIOUS" or "LOW" or "MEDIUM" or "HIGH" or "CRITICAL" => true,
- _ => false,
- };
- }
- public static string Label(string? code) => Normalize(code) switch
- {
- Serious => "严重",
- _ => "关注",
- };
- public static object[] Options() =>
- new[] { Follow, Serious }
- .Select(v => new { value = v, label = Label(v) })
- .ToArray<object>();
- }
|