From f8fbf1db4df0d59c3387980cd46811de6359131b Mon Sep 17 00:00:00 2001 From: liaoxujun@qq.com <liaoxujun@qq.com> Date: 星期一, 21 八月 2023 14:57:04 +0800 Subject: [PATCH] 修改登录授权方式,增加zctoken登录方案,增加分布式消息队列 --- ZcPayCore/Model/OderInfo.cs | 55 +++++ DocumentServiceAPI.Web.Entry/appsettings.json | 8 .gitignore | 2 DocumentServiceAPI.Application/UserAndLogin/LogInController.cs | 236 ++++++++++++++--------- ZcPayCore/ZcPayCore.csproj | 20 ++ DocumentServiceApi.InitQMessage/INITQMessageDefine.cs | 19 + DocumentServiceAPI.Application/applicationsettings.json | 15 + DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs | 66 +++++ DocumentServiceAPI.sln | 6 DocumentServiceAPI.Model/Permissions/TenantPermissions.cs | 46 ++++ DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj | 9 DocumentServiceApi.InitQMessage/MessageReceive.cs | 29 ++ DocumentServiceApi.InitQMessage/TenantOderInfo.cs | 15 + DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs | 4 DocumentServiceApi.InitQMessage/INITQSetups.cs | 48 ++++ 15 files changed, 470 insertions(+), 108 deletions(-) diff --git a/.gitignore b/.gitignore index 34fae7d..6456eb0 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ /DocumentFile.Service/obj /DocumentServiceAPI.Services/bin /DocumentServiceAPI.Services/obj +ZcPayCore/obj/ +DocumentServiceApi.InitQMessage/obj/ diff --git a/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs b/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs index 3478ee1..fa1f9fa 100644 --- a/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs +++ b/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs @@ -3,9 +3,14 @@ using DocumentServiceAPI.Utility; using Furion.DynamicApiController; using Furion.JsonSerialization; +using Microsoft.AspNetCore.Http; +using Microsoft.IdentityModel.Tokens; +using NetTaste; +using Newtonsoft.Json.Linq; using Swashbuckle.AspNetCore.Annotations; using System; using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -28,133 +33,172 @@ } /// <summary> /// 鐧诲綍 1 杈撳叆鍛樺伐璐︽埛鎴栬�呯鎴疯处鎴凤紝2 閫夋嫨绉熸埛璐︽埛锛�3 閫夋嫨鍏徃 + /// 褰撳瘑鐮佷负绌烘椂锛屽甫鍏ョ敤鎴蜂腑蹇僼oken鍗冲彲瀹炵幇鐧诲綍 /// </summary> /// <returns>鐧诲綍淇℃伅</returns> [HttpPost("LogoIn")] - public async Task<RetLoginVM> LogoIn (LoginPsWordIN Parma) + public async Task<RetLoginVM> LogoIn ( LoginPsWordIN Parma) { - bool needtoken=false; - if (Parma.TenantId==null) + //zctok鏍¢獙鎴愬姛鏄惁鏍囧織 + bool IsTokenPass=false; + + if(string.IsNullOrEmpty(Parma.PassWord)) { - //濡傛灉杩樻病纭畾绉熸埛ID 闇�瑕佸厛纭畾绉熸埛ID - List<TenderVM>Tender = await _userService.GetUserTenderList(Parma.ITCode); - - switch (Tender.Count) + + var Request = App.HttpContext.Request; + string stoken = Request.Headers["Authorization"]; + if (stoken == null) + throw Oops.Oh("娌℃湁杈撳叆瀵嗙爜"); + stoken = stoken.Replace("Bearer ", ""); + + var isvale = _tokenService.CheckJwt(stoken, out SecurityToken securityToken); + JwtSecurityToken jwtToken = securityToken as JwtSecurityToken; + string itcode = jwtToken.Claims.FirstOrDefault(claim => claim.Type == "sub")?.Value; + if (isvale == false) + throw Oops.Oh("鐧诲綍淇℃伅鍑洪敊"); + if(Parma.ITCode!= itcode) + throw Oops.Oh("鐢ㄦ埛鍚嶉敊璇�"); + + + } + + bool needtoken = false; + + if (Parma.TenantId == null) { - case 0: - throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�"); - case 1: - needtoken = await _userService.CheckPsw(Tender[0].TenderId, Tender[0].EmployeeID,Parma.PassWord); - - if(!needtoken) + //濡傛灉杩樻病纭畾绉熸埛ID 闇�瑕佸厛纭畾绉熸埛ID + List<TenderVM> Tender = await _userService.GetUserTenderList(Parma.ITCode); + + switch (Tender.Count) + { + case 0: throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�"); - - Parma.TenantId = Tender[0].TenderId; - Parma.employeeID = Tender[0].EmployeeID; - if (Parma.UnitID == null) + case 1: + if (!needtoken) { - - List<UnitVM> Units = await _userService.GetUserUnitList(Parma.TenantId ?? 0); - if (Units.Count == 0) - { - //娌℃湁鍏徃 - needtoken = true; - } - else if (Units.Count == 1) - { - Parma.UnitID = Units[0].UnitID; - needtoken = true; - } - else - { - //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛 - return new RetLoginVM - { - NeedNext = true, - Units = Units, + needtoken = await _userService.CheckPsw(Tender[0].TenderId, Tender[0].EmployeeID, Parma.PassWord); - }; - } + if (!needtoken) + throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�"); } - - break; - - default: + + + Parma.TenantId = Tender[0].TenderId; + Parma.employeeID = Tender[0].EmployeeID; + if (Parma.UnitID == null) + { + + List<UnitVM> Units = await _userService.GetUserUnitList(Parma.TenantId ?? 0); + if (Units.Count == 0) + { + //娌℃湁鍏徃 + needtoken = true; + } + else if (Units.Count == 1) + { + Parma.UnitID = Units[0].UnitID; + needtoken = true; + } + else + { + //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛 + return new RetLoginVM + { + NeedNext = true, + Units = Units, + + }; + } + } + + break; + + default: + //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛 + return new RetLoginVM + { + NeedNext = true, + Tenants = Tender, + + }; + + + } + + + + + + } + else if (Parma.UnitID == null) + { + + var Units = await _userService.GetUserUnitList(Parma.TenantId ?? 0); + if (Units.Count == 0) + { + //娌℃湁鍏徃 + needtoken = true; + } + else if (Units.Count == 1) { + Parma.UnitID = Units[0].UnitID; + needtoken = true; + } + else + { //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛 return new RetLoginVM { NeedNext = true, - Tenants = Tender, + Units = Units, }; + } - } - - - - - } - else if(Parma.UnitID==null) - { - - var Units = await _userService.GetUserUnitList(Parma.TenantId??0); - if(Units.Count==0) + if (needtoken || Parma.UnitID != null) { - //娌℃湁鍏徃 - needtoken = true; - } - else if (Units.Count==1) { - Parma.UnitID= Units[0].UnitID; - needtoken = true; - } - else + + TenderVM Tender = (await _userService.GetUserTenderList(Parma.ITCode)).Where(x => x.TenderId == Parma.TenantId && x.EmployeeID == Parma.employeeID).SingleOrDefault(); + if (Tender == null) + { + throw Oops.Oh($"璐︽埛瀵嗙爜鎴栬�呯鎴烽�夋嫨閿欒"); + } + if (!IsTokenPass) { - //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛 + needtoken = await _userService.CheckPsw(Tender.TenderId, Tender.EmployeeID, Parma.PassWord); + + if (!needtoken) + throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�"); + } + var token = _tokenService.CreateToken(new Model.JwtInfo + { + EID = Tender.EmployeeID, + LogInSource = Parma.Form, + TEID = Tender.TenderId, + UID = Parma.UnitID, + }); return new RetLoginVM { - NeedNext = true, - Units = Units, + NeedNext = false, + Token = token, }; } - - } - - if(needtoken|| Parma.UnitID!=null) - { - - TenderVM Tender = (await _userService.GetUserTenderList(Parma.ITCode)).Where(x=>x.TenderId==Parma.TenantId&&x.EmployeeID==Parma.employeeID).SingleOrDefault(); - if(Tender==null) - { - throw Oops.Oh($"璐︽埛瀵嗙爜鎴栬�呯鎴烽�夋嫨閿欒"); - } - needtoken = await _userService.CheckPsw(Tender. TenderId, Tender.EmployeeID, Parma.PassWord); - - if (!needtoken) - throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�"); - var token= _tokenService.CreateToken(new Model.JwtInfo - { - EID = Tender.EmployeeID, - LogInSource = Parma.Form, - TEID = Tender.TenderId, - UID = Parma.UnitID, - }); - return new RetLoginVM - { - NeedNext = false, - Token = token, - - }; - } - throw Oops.Oh($"鍙傛暟閿欒"); + throw Oops.Oh($"鍙傛暟閿欒"); + + + } - + + + + + /// <summary> /// 鑾峰彇鍏徃鍒楄〃 diff --git a/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs b/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs index 8988879..ce8b762 100644 --- a/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs +++ b/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs @@ -3,10 +3,13 @@ using Furion.Authorization; using Furion.DistributedIDGenerator; using Furion.JsonSerialization; +using Furion.Logging.Extensions; +using Microsoft.IdentityModel.Tokens; using NetTaste; using SqlSugar.Extensions; using System; using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Reflection; using System.Security.Claims; @@ -18,7 +21,7 @@ /// <summary> /// token鏈嶅姟绫� /// </summary> - public class TokenService: IScoped + public class TokenService : IScoped { /// <summary> /// Token鏄暐 @@ -27,7 +30,7 @@ private ISqlSugarClient _db; private UserService _UserService; private IRedisCacheService _RedisCase; - public TokenService(ISqlSugarClient db, UserService UserInfoService, IRedisCacheService RedisCase ) { + public TokenService(ISqlSugarClient db, UserService UserInfoService, IRedisCacheService RedisCase) { _db = db; _UserService = UserInfoService; _RedisCase = RedisCase; @@ -36,9 +39,9 @@ /// 鏂板缓涓�涓猅Oken /// </summary> /// <returns></returns> - public string CreateToken(JwtInfo jwt) + public string CreateToken(JwtInfo jwt) { - string TokenKey=TokenKeys+ getTokenKey(jwt); + string TokenKey = TokenKeys + getTokenKey(jwt); IDictionary<string, object> propertyDictionary = new Dictionary<string, object>(); PropertyInfo[] properties = jwt.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); @@ -51,14 +54,57 @@ propertyDictionary.Add(propertyName.ToLower(), propertyValue); } var ID = IDGen.NextID(); - jwt.JID = ID; - var token= JWTEncryption.Encrypt(propertyDictionary, App.GetConfig<JWTSettingsOptions>("JWTSettings").ExpiredTime ?? 3600); - if(jwt.LogInSource==LogInFrom.PC) - _RedisCase.Add<string>(TokenKey, ID.ToString(), expireSeconds: (int )(App.GetConfig<JWTSettingsOptions>("JWTSettings").ExpiredTime??3600)); + jwt.JID = ID; + var token = JWTEncryption.Encrypt(propertyDictionary, App.GetConfig<JWTSettingsOptions>("JWTSettings").ExpiredTime ?? 3600); + if (jwt.LogInSource == LogInFrom.PC) + _RedisCase.Add<string>(TokenKey, ID.ToString(), expireSeconds: (int)(App.GetConfig<JWTSettingsOptions>("JWTSettings").ExpiredTime ?? 3600)); return token; } + /// <summary> + /// 鏍¢獙token 鐨勬湁鏁堟�� + /// </summary> + /// <param name="Token"> Token鏍¢獙</param> + /// <param name="validationParameters"></param> + /// <param name="securityToken"></param> + /// <returns></returns> + public bool CheckJwt(string Token, out SecurityToken? securityToken) + { + var configuration = App.Configuration; + // var value = configuration["xxx:xxx"]; + + string secretKey = configuration["ZCUserInfoJwtOP:SecurityKey"]; + if (secretKey == null) + { + "娌℃湁閰嶇疆鐢ㄦ埛涓績鐨勫畨鍏ㄧ閽� ZCUserInfoJwtOP:SecurityKey 鎵句笉鍒�".LogInformation<TokenService>(); + throw Oops.Oh("閰嶇疆閿欒锛岃仈绯荤鐞嗗憳"); + } + JwtSecurityTokenHandler tokenHandler = new JwtSecurityTokenHandler(); + //JwtSecurityToken jwt = tokenHandler.ReadJwtToken(Token); + + // 楠岃瘉 JWT 绛惧悕骞舵鏌ユ湁鏁堟湡 + TokenValidationParameters validationParameters = new TokenValidationParameters + { + ValidateIssuerSigningKey = true, + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey)), + ValidateIssuer = false, + ValidateAudience = false, + ClockSkew = TimeSpan.Zero // 绂佺敤鏃堕棿鍋忕Щ閲� + }; + try + { + ClaimsPrincipal claimsPrincipal = tokenHandler.ValidateToken(Token, validationParameters, out SecurityToken validatedToken); + + securityToken = validatedToken; + return true; + } + catch (SecurityTokenException) + { + securityToken=null; + return false; + } + } /// <summary> @@ -91,6 +137,10 @@ string TokenKey = TokenKeys + jwt.EID?.ToString() + jwt.UID?.ToString() + jwt.TEID?.ToString(); return TokenKey; } + + + + } } diff --git a/DocumentServiceAPI.Application/applicationsettings.json b/DocumentServiceAPI.Application/applicationsettings.json index 9ba3089..fadfbf6 100644 --- a/DocumentServiceAPI.Application/applicationsettings.json +++ b/DocumentServiceAPI.Application/applicationsettings.json @@ -46,12 +46,25 @@ "KeepVerb": true,//淇濇寔鐗堟湰鍙蜂竴鑷� "LowercaseRoute": false }, - + "CorsAccessorSettings": { "WithExposedHeaders": [ "access-token", "x-access-token", "environment" ] + }, + "ZCUserInfoJwtOP": { //zc鐢ㄦ埛涓績jwt閰嶇疆 鐢ㄤ簬瑙f瀽zc鐨則oken + + "Issuer": "http://zc", + "Audience": "http://zc", + "Expires": 86400, + "weixinExpires": 1296000, // 86400, + "SecurityKey": "superSecretKey@345", + "RefreshTokenExpires": 86400, + "LoginPath": "/_Framework/Redirect401" + } + + } \ No newline at end of file diff --git a/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs b/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs index bdb4a9c..f896efb 100644 --- a/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs +++ b/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs @@ -1,6 +1,8 @@ 锘縰sing DocumentServiceAPI.Enum; +using SqlSugar; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,8 +12,50 @@ /// <summary> /// 绉熸埛鏉冮檺 /// </summary> - public class TenantPermissions + public class TenantPermissions: BaseModel { + /// <summary> + /// id + /// </summary> + [Display(Name = "id ")] + [SugarColumn(ColumnDescription = "id ")] + public int Id { get; set; } + /// <summary> + /// 绉熸埛ID + /// </summary> + [Display(Name = "绉熸埛ID ")] + [SugarColumn(ColumnDescription = "绉熸埛ID ")] + public int TenantId { get; set; } + + + /// <summary> + /// 鏈�澶т紒涓氫釜鏁� + /// </summary> + [Display(Name = "鏈�澶т紒涓氫釜鏁� ")] + [SugarColumn(ColumnDescription = "鏈�澶т紒涓氫釜鏁� ")] + public int UnitMaxCount { get; set; } + + /// <summary> + /// 鏈�澶у憳宸ユ暟閲� + /// </summary> + [Display(Name = "鏈�澶у憳宸ユ暟閲� ")] + [SugarColumn(ColumnDescription = "鏈�澶у憳宸ユ暟閲� ")] + public int EmployeeMaxCount { get; set; } + + + /// <summary> + /// 鍒版湡鏃堕棿 + /// </summary> + [Display(Name = "鍒版湡鏃堕棿 ")] + [SugarColumn(ColumnDescription = "鍒版湡鏃堕棿 ")] + public DateTime OverTime { get; set; } + + /// <summary> + /// 鎻忚堪 + /// </summary> + [Display(Name = "鎻忚堪 ")] + [SugarColumn(ColumnDescription = "鎻忚堪 ")] + public string? Description { get; set; } } } diff --git a/DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs b/DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs index ad89288..dc0d05c 100644 --- a/DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs +++ b/DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs @@ -1,4 +1,5 @@ 锘縰sing Furion.Authorization; +using Furion.DataEncryption; using Microsoft.AspNetCore.Authorization; namespace DocumentServiceAPI.Web.Entry @@ -8,6 +9,7 @@ /// </summary> public class AuthorizeHandler:AppAuthorizeHandler { + /// <summary> /// 璇锋眰绠¢亾 /// </summary> @@ -17,7 +19,7 @@ public override Task<bool> PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext) { // 姝ゅ宸茬粡鑷姩楠岃瘉 Jwt token鐨勬湁鏁堟�т簡锛屾棤闇�鎵嬪姩楠岃瘉 - + // 妫�鏌ユ潈闄愶紝濡傛灉鏂规硶鏄紓姝ョ殑灏变笉鐢� Task.FromResult 鍖呰9锛岀洿鎺ヤ娇鐢� async/await 鍗冲彲 return Task.FromResult(CheckAuthorzie(httpContext)); } diff --git a/DocumentServiceAPI.Web.Entry/appsettings.json b/DocumentServiceAPI.Web.Entry/appsettings.json index 550e6de..396bcc1 100644 --- a/DocumentServiceAPI.Web.Entry/appsettings.json +++ b/DocumentServiceAPI.Web.Entry/appsettings.json @@ -12,7 +12,8 @@ { "ConfigId": "default", //澶氬簱閰嶇疆ID - "ConnectionString": "Server=.;Database=doc_new;User ID=sa;Password=123456;", + //"ConnectionString": "Server=.;Database=doc_new;User ID=sa;Password=123456;", + "ConnectionString": "Server=localhost\\SQLEXPRESS;Database=CY_DocumentSystemOnline;User ID=sa;Password=123456;", "DbType": "SqlServer", "IsAutoCloseConnection": true @@ -28,7 +29,12 @@ }, + //娑堟伅闃熷垪閰嶇疆 涓轰簡鐙珛閮ㄧ讲锛岃繖閲屽崟鐙厤缃� + "InitQRedisConfig": { + // 濡傛灉閲囩敤瀹瑰櫒鍖栭儴缃睸ervice 瑕佸啓鎴恟edis鐨勬湇鍔″悕锛屽惁鍒欏啓鍦板潃 + "ConnectionString": "127.0.0.1:6379,password=,connectTimeout=30000,responseTimeout=30000,abortConnect=false,connectRetry=1,syncTimeout=10000,DefaultDatabase=10" //redis鏁版嵁搴撹繛鎺ュ瓧绗︿覆 + }, "JWTSettings": { diff --git a/DocumentServiceAPI.sln b/DocumentServiceAPI.sln index e632510..b2f35c3 100644 --- a/DocumentServiceAPI.sln +++ b/DocumentServiceAPI.sln @@ -21,6 +21,8 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocumentServiceAPI.Services", "DocumentServiceAPI.Services\DocumentServiceAPI.Services.csproj", "{3369F102-ABB2-42A4-B216-58D530AEE8BE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZcPayCore", "ZcPayCore\ZcPayCore.csproj", "{76BFAB65-B7AC-4534-A595-363551111129}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -62,6 +64,10 @@ {3369F102-ABB2-42A4-B216-58D530AEE8BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {3369F102-ABB2-42A4-B216-58D530AEE8BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {3369F102-ABB2-42A4-B216-58D530AEE8BE}.Release|Any CPU.Build.0 = Release|Any CPU + {76BFAB65-B7AC-4534-A595-363551111129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76BFAB65-B7AC-4534-A595-363551111129}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76BFAB65-B7AC-4534-A595-363551111129}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76BFAB65-B7AC-4534-A595-363551111129}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj b/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj @@ -0,0 +1,9 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + +</Project> diff --git a/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs b/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs new file mode 100644 index 0000000..55ad3dd --- /dev/null +++ b/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs @@ -0,0 +1,19 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DocumentServiceApi.InitQMessage +{ + /// <summary> + /// 娑堟伅缁撴瀯瀹氫箟 + /// </summary> + public static class INITQMessageDefine + { + /// <summary> + /// 璐叆Oder娑堟伅 + /// </summary> + public const string InitTentOder = "DocumentServiceAPI_OderINIT"; + } +} diff --git a/DocumentServiceApi.InitQMessage/INITQSetups.cs b/DocumentServiceApi.InitQMessage/INITQSetups.cs new file mode 100644 index 0000000..bd9ce74 --- /dev/null +++ b/DocumentServiceApi.InitQMessage/INITQSetups.cs @@ -0,0 +1,48 @@ +锘縰sing CSRedis; +using Furion; +using InitQ; +using Mapster; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace DocumentServiceApi.InitQMessage +{ + /// <summary> + /// 娉ㄥ唽 INITQ + /// </summary> + public class DocServiceApiStartup : AppStartup + { + public void ConfigureServices(IServiceCollection services) { + + + var readisconnectionstring = App.Configuration["InitQRedisConfig:ConnectionString"]; + if (readisconnectionstring != null) + //鍒濆鍖杛edi閰嶇疆 + { + services.AddInitQ((op) => + { + op.SuspendTime = 500; + op.IntervalTime = 500; + op.ConnectionString = readisconnectionstring; + op.ListSubscribe = new List<Type>() { typeof(MessageReceive) }; + op.ShowLog = false; + }); + } + + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + + + } + } +} diff --git a/DocumentServiceApi.InitQMessage/MessageReceive.cs b/DocumentServiceApi.InitQMessage/MessageReceive.cs new file mode 100644 index 0000000..0d5dcf5 --- /dev/null +++ b/DocumentServiceApi.InitQMessage/MessageReceive.cs @@ -0,0 +1,29 @@ +锘縰sing InitQ.Abstractions; +using InitQ.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DocumentServiceApi.InitQMessage +{ + /// <summary> + /// 娑堟伅鎺ユ敹澶勭悊鍑芥暟 + /// </summary> + public class MessageReceive: IRedisSubscribe + { + /// <summary> + /// 鍒濆鍖栬鍗曞鐞� + /// </summary> + /// <param name="msg"></param> + /// <returns></returns> + + [Subscribe(INITQMessageDefine.InitTentOder)] + private async Task InitTenantOder(string msg) + { + + } + + } +} diff --git a/DocumentServiceApi.InitQMessage/TenantOderInfo.cs b/DocumentServiceApi.InitQMessage/TenantOderInfo.cs new file mode 100644 index 0000000..7efe8dc --- /dev/null +++ b/DocumentServiceApi.InitQMessage/TenantOderInfo.cs @@ -0,0 +1,15 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DocumentServiceApi.InitQMessage +{ + /// <summary> + /// 璁㈠崟璇︽儏 + /// </summary> + public class TenantOderInfo + { + } +} diff --git a/ZcPayCore/Model/OderInfo.cs b/ZcPayCore/Model/OderInfo.cs new file mode 100644 index 0000000..094f2f9 --- /dev/null +++ b/ZcPayCore/Model/OderInfo.cs @@ -0,0 +1,55 @@ +锘縰sing DocumentServiceAPI.Enum; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZcPayCore.Model +{ + /// <summary> + /// 閫氱敤璁㈠崟绫� + /// </summary> + [Display(Name = "閫氱敤璁㈠崟绫� ")] + [SugarTable(TableName = "Oder", TableDescription = "閫氱敤璁㈠崟绫�")] + public class Oder : BaseModel + { + /// <summary> + /// Id + /// </summary> + [Display(Name = "Id ")] + [SugarColumn(ColumnDescription = "Id ",IsIdentity =true,IsPrimaryKey =true)] + public int Id { get; set; } + + /// <summary> + /// 鐢ㄦ埛ID 涔熷彲鑳芥槸绉熸埛ID + /// </summary> + [Display(Name = "鐢ㄦ埛ID 涔熷彲鑳芥槸绉熸埛ID ")] + [SugarColumn(ColumnDescription = "鐢ㄦ埛ID 涔熷彲鑳芥槸绉熸埛ID ")] + public int UserID { get; set; } + + /// <summary> + /// 璁㈠崟璇︽儏鎻忚堪 + /// </summary> + [Display(Name = "璁㈠崟璇︽儏鎻忚堪 ")] + [SugarColumn(ColumnDescription = "璁㈠崟璇︽儏鎻忚堪 ")] + public string? Description { get; set; } + + /// <summary> + /// 鍏朵粬鍙傛暟 + /// </summary> + [Display(Name = "鍏朵粬鍙傛暟 ")] + [SugarColumn(ColumnDescription = "鍏朵粬鍙傛暟 ")] + public string? Param { get; set; } + + /// <summary> + /// PropertyDecName + /// </summary> + [Display(Name = "PropertyDecName ")] + [SugarColumn(ColumnDescription = "PropertyDecName ")] + public int Property { get; set; } + + } +} diff --git a/ZcPayCore/ZcPayCore.csproj b/ZcPayCore/ZcPayCore.csproj new file mode 100644 index 0000000..0f64f88 --- /dev/null +++ b/ZcPayCore/ZcPayCore.csproj @@ -0,0 +1,20 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>enable</Nullable> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="Essensoft.Paylink.Alipay" Version="4.1.2" /> + <PackageReference Include="Essensoft.Paylink.Security" Version="4.1.2" /> + <PackageReference Include="Essensoft.Paylink.WeChatPay" Version="4.1.2" /> + <PackageReference Include="SqlSugarCore" Version="5.1.4.99" /> + </ItemGroup> + + <ItemGroup> + <ProjectReference Include="..\DocumentServiceAPI.Enum\DocumentServiceAPI.Enum.csproj" /> + </ItemGroup> + +</Project> -- Gitblit v1.9.1