From 6c8e038aad394c1e91c8c046d3de25dc8e84ecbe Mon Sep 17 00:00:00 2001 From: lg <999544862qq.com> Date: 星期日, 01 九月 2024 09:31:27 +0800 Subject: [PATCH] 优化 --- WebApi/Gs.Toolbox/UtilityHelper.cs | 33 +++++++++++++++++++++++++++++++-- 1 files changed, 31 insertions(+), 2 deletions(-) diff --git a/WebApi/Gs.Toolbox/UtilityHelper.cs b/WebApi/Gs.Toolbox/UtilityHelper.cs index a0198de..e7b2271 100644 --- a/WebApi/Gs.Toolbox/UtilityHelper.cs +++ b/WebApi/Gs.Toolbox/UtilityHelper.cs @@ -1,17 +1,46 @@ -锘縰sing System; +锘縰sing Microsoft.AspNetCore.Http; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using static System.Net.WebRequestMethods; namespace Gs.Toolbox { public static class UtilityHelper { - public static Guid? GetGuid(string? str) { + /// <summary> + /// string 杞琯uid + /// </summary> + /// <param name="str"></param> + /// <returns></returns> + public static Guid? GetGuid(string? str) + { if (string.IsNullOrEmpty(str)) return null; return Guid.Parse(str); } + /// <summary> + /// 璇诲彇userGuid,orgGuid + /// </summary> + /// <param name="_http"></param> + /// <returns></returns> + public static (string?, string?) GetUserGuidAndOrgGuid(IHttpContextAccessor _http) + { + try + { + string _token = _http.HttpContext.Request.Headers["token"]; + string[] _ary = _token.Split("~"); + return (_ary[0], _ary[1]); + } + catch (Exception ex) + { + Gs.Toolbox.LogHelper.Debug("GetUserGuidAndOrgGuid:", ex.Message); + return (null, null); + } + + } } } -- Gitblit v1.9.3