Browse Source

SessionContext staffNo

xf 1 year ago
parent
commit
b43460b9fb

+ 4 - 4
src/Hotline.Api/Controllers/TestController.cs

@@ -102,12 +102,12 @@ public class TestController : BaseController
     [HttpGet("time")]
     public async Task<string> GetTime()
     {
-        //var rsp = await _wexClient.QueryTelsAsync(new QueryTelRequest { StaffNo = "123" }, HttpContext.RequestAborted);
+        //var rsp = await _wexClient.QueryTelsAsync(new QueryTelRequest {  }, HttpContext.RequestAborted);
 
-        //return DateTime.Now.ToString("F");
+        return DateTime.Now.ToString("F");
 
-        var rsp = await _daprClient.InvokeMethodAsync<string>(HttpMethod.Get, "identity", "api/v1/Test/time", HttpContext.RequestAborted);
-        return rsp;
+        //var rsp = await _daprClient.InvokeMethodAsync<string>(HttpMethod.Get, "identity", "api/v1/Test/time", HttpContext.RequestAborted);
+        //return rsp;
     }
 
     [HttpGet("pgsql")]

+ 8 - 1
src/Hotline.Api/StartupExtensions.cs

@@ -12,6 +12,7 @@ using Hotline.Wex;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Identity;
 using Serilog;
+using System.Text.Json;
 using XF.Domain.Dependency;
 using XF.Domain.Filters;
 using XF.Domain.Options;
@@ -55,6 +56,12 @@ internal static class StartupExtensions
             })
             .AddDapr(d =>
             {
+                d.UseJsonSerializationOptions(new JsonSerializerOptions
+                {
+                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+                    DictionaryKeyPolicy = JsonNamingPolicy.CamelCase,
+                    //Converters = { new JsonStringEnumConverter() }
+                });
 #if DEBUG
                 d.UseHttpEndpoint("http://110.188.24.28:50202");
                 d.UseGrpcEndpoint("http://110.188.24.28:50203");
@@ -146,7 +153,7 @@ internal static class StartupExtensions
         app.MapControllers()
             .RequireAuthorization();
         //app.MapSubscribeHandler();
-
+        
         return app;
     }
 }

+ 1 - 0
src/Hotline.Application/Identity/IdentityAppService.cs

@@ -83,6 +83,7 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
             new(AppClaimTypes.DepartmentId, user.OrgId??string.Empty),
             new(AppClaimTypes.DepartmentCode, user.OrgCode??string.Empty),
             new(AppClaimTypes.DepartmentName, user.Organization?.OrgName??string.Empty),
+            new(AppClaimTypes.StaffNo, user.StaffNo),
         };
         claims.AddRange(account.Roles.Select(d => new Claim(JwtClaimTypes.Role, d.Name)));
         var token = _jwtSecurity.EncodeJwtToken(claims);

+ 5 - 5
src/Hotline.Share/Enums/FlowEngine/EHandlerType.cs

@@ -34,9 +34,9 @@ public enum EHandlerType
     [Description("指定部门")]
     AssignOrg = 4,
 
-    /// <summary>
-    /// 自定义(用户)
-    /// </summary>
-    [Description("自定义")]
-    Custom = 5,
+    ///// <summary>
+    ///// 自定义(用户)
+    ///// </summary>
+    //[Description("自定义")]
+    //Custom = 5,
 }

+ 6 - 0
src/XF.Domain/Authentications/DefaultSessionContext.cs

@@ -27,6 +27,7 @@ namespace XF.Domain.Authentications
             OrgCode = user.FindFirstValue(AppClaimTypes.DepartmentCode);
             OrgName = user.FindFirstValue(AppClaimTypes.DepartmentName);
             ClientId = user.FindFirstValue(JwtClaimTypes.ClientId);
+            StaffNo = user.FindFirstValue(AppClaimTypes.StaffNo);
         }
 
         /// <summary>
@@ -55,5 +56,10 @@ namespace XF.Domain.Authentications
         public string RequiredOrgId => OrgId ?? throw new ArgumentNullException();
         public string RequiredOrgCode => OrgCode ?? throw new ArgumentNullException();
         public string? ClientId { get; }
+
+        /// <summary>
+        /// 工号
+        /// </summary>
+        public string? StaffNo { get; }
     }
 }

+ 5 - 0
src/XF.Domain/Authentications/ISessionContext.cs

@@ -39,5 +39,10 @@ public interface ISessionContext
     string RequiredOrgCode { get; }
 
     string? ClientId { get; }
+
+    /// <summary>
+    /// 工号
+    /// </summary>
+    string? StaffNo { get; }
 }
 

+ 1 - 1
src/XF.Domain/XF.Domain.csproj

@@ -17,7 +17,7 @@
     <PackageReference Include="Serilog.Enrichers.Span" Version="2.3.0" />
     <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.25.1" />
     <PackageReference Include="XF.Utility.UnifyResponse" Version="1.0.6" />
-    <PackageReference Include="XF.Utility.AppIdentityModel" Version="1.0.4" />
+    <PackageReference Include="XF.Utility.AppIdentityModel" Version="1.0.5" />
   </ItemGroup>
 
 </Project>