| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- namespace Admin.NET.Plugin.AiDOP.Const.S8;
- /// <summary>
- /// S8-ACTION-PERMISSION-1:异常单「操作」的规范编码。
- ///
- /// <para><b>每一条都对应一个真实存在的 API</b>(见 <see cref="S8ExceptionActionCatalog.All"/> 里的
- /// <c>ApiHint</c>)。刻意<b>不</b>凭空造 <c>EXCEPTION_CLOSE</c> 之类的动作 ——
- /// S8 没有独立的「关闭」接口,关闭是 <c>approve-verification</c> 通过后的状态机结果,
- /// 给它一个可配置的权限位只会让管理员配了一个永远不会被检查的开关。</para>
- /// </summary>
- public static class S8ExceptionActionCode
- {
- /// <summary>查看异常(列表 / 详情 / 时间线 / 决策 / 证据 / 筛选项)。</summary>
- public const string View = "EXCEPTION_VIEW";
- /// <summary>
- /// 查看全部异常(跨规则责任池)。
- /// <para>在 P1-B 建立配置位,由 P1-C 的可见性收敛真正消费 ——
- /// 届时「非责任池成员」将只能看到自己有责任的规则所产生的异常。</para>
- /// </summary>
- public const string ViewAll = "EXCEPTION_VIEW_ALL";
- /// <summary>人工提报异常(<c>POST /reports</c>)。</summary>
- public const string Create = "EXCEPTION_CREATE";
- /// <summary>认领(<c>POST {id}/claim</c>)。处理人恒为当前登录账号。</summary>
- public const string Claim = "EXCEPTION_CLAIM";
- /// <summary>转派 / 指派他人(<c>POST {id}/transfer</c>)。与认领分开,权限强于认领。</summary>
- public const string Transfer = "EXCEPTION_TRANSFER";
- /// <summary>开始处理(<c>POST {id}/start-progress</c>)。</summary>
- public const string Start = "EXCEPTION_START";
- /// <summary>提交复核(<c>POST {id}/submit-verification</c>)。</summary>
- public const string SubmitVerify = "EXCEPTION_SUBMIT_VERIFY";
- /// <summary>审核通过 / 退回(<c>POST {id}/approve-verification</c> · <c>{id}/reject-verification</c>)。</summary>
- public const string Verify = "EXCEPTION_VERIFY";
- /// <summary>升级(<c>POST {id}/upgrade</c>)。</summary>
- public const string Upgrade = "EXCEPTION_UPGRADE";
- /// <summary>驳回(<c>POST {id}/reject</c>)。</summary>
- public const string Reject = "EXCEPTION_REJECT";
- /// <summary>补充说明(<c>POST {id}/comment</c>)。</summary>
- public const string Comment = "EXCEPTION_COMMENT";
- }
- /// <summary>一个可配置动作的元信息。</summary>
- public sealed record S8ExceptionActionDefinition(
- string Code,
- string DisplayName,
- string ApiHint,
- /// <summary>
- /// 该动作在<b>旧权限体系</b>中的对应能力码(<c>SysMenu.Permission</c>)。
- /// 仅供首次 Provisioning 推导默认值使用 —— 让「本租户原本谁能做」原样延续,
- /// 而不是拍脑袋给一套新默认。为 null 表示旧体系里没有对应位(如 ViewAll)。
- /// </summary>
- string? LegacyPermissionCode,
- /// <summary>
- /// 该动作还等价于哪些旧能力码(并集推导)。例如「审核」在旧体系里被拆成
- /// approve / reject 两个码,任一持有即视为拥有审核能力。
- /// </summary>
- string[] LegacyPermissionAliases,
- int OrderNo);
- /// <summary>
- /// 动作目录。<b>这是「S8 异常单到底有哪些可授权动作」的唯一出处</b> ——
- /// 后端授权、Provisioning 默认值、前端权限矩阵三方共用同一份,
- /// 避免出现「页面上能配、后端根本不检查」或反之。
- /// </summary>
- public static class S8ExceptionActionCatalog
- {
- public static readonly IReadOnlyList<S8ExceptionActionDefinition> All = new List<S8ExceptionActionDefinition>
- {
- new(S8ExceptionActionCode.View, "查看异常", "GET /exceptions · {id} · timeline · decisions · evidences",
- S8PermissionCatalog.ExceptionRead, Array.Empty<string>(), 10),
- new(S8ExceptionActionCode.ViewAll, "查看全部异常", "(P1-C 可见性收敛消费)",
- null, Array.Empty<string>(), 20),
- new(S8ExceptionActionCode.Create, "提报异常", "POST /reports",
- S8PermissionCatalog.ExceptionCreate, Array.Empty<string>(), 30),
- new(S8ExceptionActionCode.Claim, "认领", "POST /exceptions/{id}/claim",
- S8PermissionCatalog.ExceptionClaim, Array.Empty<string>(), 40),
- new(S8ExceptionActionCode.Transfer, "转派", "POST /exceptions/{id}/transfer",
- S8PermissionCatalog.ExceptionAssign, Array.Empty<string>(), 50),
- new(S8ExceptionActionCode.Start, "开始处理", "POST /exceptions/{id}/start-progress",
- S8PermissionCatalog.ExceptionStart, Array.Empty<string>(), 60),
- new(S8ExceptionActionCode.SubmitVerify, "提交复核", "POST /exceptions/{id}/submit-verification",
- S8PermissionCatalog.VerificationSubmit, Array.Empty<string>(), 70),
- new(S8ExceptionActionCode.Verify, "审核(通过 / 退回)",
- "POST /exceptions/{id}/approve-verification · reject-verification",
- S8PermissionCatalog.VerificationApprove,
- new[] { S8PermissionCatalog.VerificationReject }, 80),
- new(S8ExceptionActionCode.Upgrade, "升级", "POST /exceptions/{id}/upgrade",
- S8PermissionCatalog.ExceptionUpgrade, Array.Empty<string>(), 90),
- new(S8ExceptionActionCode.Reject, "驳回", "POST /exceptions/{id}/reject",
- S8PermissionCatalog.ExceptionReject, Array.Empty<string>(), 100),
- new(S8ExceptionActionCode.Comment, "补充说明", "POST /exceptions/{id}/comment",
- S8PermissionCatalog.ExceptionComment, Array.Empty<string>(), 110),
- };
- private static readonly Dictionary<string, S8ExceptionActionDefinition> ByCode =
- All.ToDictionary(x => x.Code, StringComparer.OrdinalIgnoreCase);
- /// <summary>动作码是否在目录中。<b>不在目录 = 未知动作 = 一律拒绝</b>(fail closed)。</summary>
- public static bool IsKnown(string? code) =>
- !string.IsNullOrWhiteSpace(code) && ByCode.ContainsKey(code!);
- public static S8ExceptionActionDefinition? Find(string? code) =>
- string.IsNullOrWhiteSpace(code) ? null : ByCode.GetValueOrDefault(code!);
- }
|