From f4e84a98facb28bbfc63343c81095a9787812e27 Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期六, 30 八月 2025 16:25:51 +0800 Subject: [PATCH] 1.PDA分组织 --- Controllers/BaseController.cs | 31 +++++++++---------------------- 1 files changed, 9 insertions(+), 22 deletions(-) diff --git a/Controllers/BaseController.cs b/Controllers/BaseController.cs index 3caae53..52ffce2 100644 --- a/Controllers/BaseController.cs +++ b/Controllers/BaseController.cs @@ -1,34 +1,21 @@ 锘縰sing Microsoft.AspNetCore.Mvc; -using System; +using Microsoft.Extensions.DependencyInjection; public class BaseController : ControllerBase { - protected string OrgId + private RequestInfo _requestInfo; + + protected RequestInfo RequestInfo { get { - var orgId = GetOrgIdFromHeader(); - if (string.IsNullOrEmpty(orgId)) + if (_requestInfo == null) { - throw new ArgumentException("璇锋眰缁勭粐ID涓嶅瓨鍦紒璇锋鏌ヨ姹傚ご涓槸鍚﹀寘鍚湁鏁堢殑OrgId銆�"); + //蹇呭~椤� + //_requestInfo.ValidateRequired("OrgId"); + _requestInfo = HttpContext.RequestServices.GetService<RequestInfo>(); } - return orgId; + return _requestInfo; } - } - - private string GetOrgIdFromHeader() - { - if (HttpContext.Request.Headers.TryGetValue("OrgId", out var orgIdValue)) - { - return orgIdValue.ToString(); - } - return null; - } - - // 鍙�夛細鎻愪緵涓�涓畨鍏ㄨ幏鍙朞rgId鐨勬柟娉曪紝涓嶆姏鍑哄紓甯歌�屾槸杩斿洖榛樿鍊兼垨null - protected bool TryGetOrgId(out string orgId) - { - orgId = GetOrgIdFromHeader(); - return !string.IsNullOrEmpty(orgId); } } \ No newline at end of file -- Gitblit v1.9.3