From 239d53384116cb92f0bf013e00932927bea5024f Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Fri, 7 Jun 2024 01:54:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Persons/SmsVerifyCodeInputDto.cs | 14 +++++++++- .../UserTokenDto.cs | 20 ++++++++++++++ .../AppointScheduleAppService.cs | 4 +-- .../Persons/PersonAppService.cs | 26 ++++++++++++++----- .../Enums/CacheKeys.cs | 1 + .../appsettings.json | 1 + 6 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/Shentun.WebPeis.Application.Contracts/Persons/SmsVerifyCodeInputDto.cs b/src/Shentun.WebPeis.Application.Contracts/Persons/SmsVerifyCodeInputDto.cs index 0093683..fb9e483 100644 --- a/src/Shentun.WebPeis.Application.Contracts/Persons/SmsVerifyCodeInputDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/Persons/SmsVerifyCodeInputDto.cs @@ -9,7 +9,7 @@ namespace Shentun.WebPeis.Persons /// /// 微信OpenId /// - public string WechatOpenId { get; set; } + public string? WechatOpenId { get; set; } /// /// 姓名 /// @@ -19,6 +19,18 @@ namespace Shentun.WebPeis.Persons /// 手机号码 /// public string MobileTelephone { get; set; } + /// + /// 身份证号 + /// public string IdNo { get; set; } + + /// + /// 会话键 + /// + public string SessionKey { get; set; } + /// + /// 会话键值 + /// + public string SessionKeyValue { get; set; } } } diff --git a/src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs b/src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs index a20a148..d6e4617 100644 --- a/src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs @@ -6,9 +6,29 @@ namespace Shentun.WebPeis { public class UserTokenDto { + /// + /// 是否新用户 + /// public string IsNewUser { get; set; } = "Y"; + /// + /// 微信OpenId + /// public string OpenId { get; set; } + /// + /// 访问TOKEN + /// public string AccessToken { get; set; } + /// + /// 刷新Token + /// public string RefreshToken { get; set; } + /// + /// 会话键 + /// + public string SessionKey { get; set; } + /// + /// 会话键值 + /// + public string SessionKeyValue { get; set; } } } diff --git a/src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs b/src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs index b09f253..f676520 100644 --- a/src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs +++ b/src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs @@ -97,8 +97,8 @@ namespace Shentun.WebPeis.AppointSchedules { AppointScheduleId = x.Key.AppointScheduleId, AppointDate = x.Key.AppointDate, - IsWork = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) == 0 ? 'N' : 'Y', - IsFull = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) <= x.Key.AppointScheduleTimes.Sum(m => m.AppointNumber) ? 'Y' : 'N' + IsWork = x.Key.IsWork, + IsFull = x.Key.AppointScheduleTimes.Sum(m => m.NumberLimit) <= x.Key.AppointScheduleTimes.Sum(m => m.AppointNumber) ? 'Y' : 'N' }).ToList(); return list; } diff --git a/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs b/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs index 354f0a3..bccf0ac 100644 --- a/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs +++ b/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs @@ -71,7 +71,7 @@ namespace Shentun.WebPeis.Persons IRepository patientRegisterRepository, IRepository patientRepository, CacheService cacheService, - IHttpContextAccessor httpContextAccessor, + //IHttpContextAccessor httpContextAccessor, IRepository customerOrgRepository) { _repository = repository; @@ -85,7 +85,7 @@ namespace Shentun.WebPeis.Persons _patientRegisterRepository = patientRegisterRepository; _patientRepository = patientRepository; _cacheService = cacheService; - _httpContextAccessor = httpContextAccessor; + //_httpContextAccessor = httpContextAccessor; _customerOrgRepository = customerOrgRepository; } @@ -130,6 +130,11 @@ namespace Shentun.WebPeis.Persons var dicStr = dic.Select(m => m.Key + "=" + m.Value).DefaultIfEmpty().Aggregate((m, n) => m + "&" + n); var token = await GetTokenAsync(dicStr); + var sessionKey = CacheKeys.SessionKey + Guid.NewGuid().ToString(); + var sessionKeyValue = Guid.NewGuid().ToString(); + _cache.Set(sessionKey, sessionKeyValue); + token.SessionKey = sessionKey; + token.SessionKeyValue = sessionKeyValue; return token; } @@ -411,13 +416,22 @@ namespace Shentun.WebPeis.Persons { throw new UserFriendlyException("input不能为空"); } - if (string.IsNullOrWhiteSpace(input.WechatOpenId)) + //if (string.IsNullOrWhiteSpace(input.WechatOpenId)) + //{ + // throw new UserFriendlyException("WechatOpenId不能为空"); + //} + //if (_cache.Get(CacheKeys.OpenIdKey + input.WechatOpenId) != input.WechatOpenId) + //{ + // throw new UserFriendlyException("无效的WechatOpenId"); + //} + + if (string.IsNullOrWhiteSpace(input.SessionKey)) { - throw new UserFriendlyException("WechatOpenId不能为空"); + throw new UserFriendlyException("SessionKey不能为空"); } - if (_cache.Get(CacheKeys.OpenIdKey + input.WechatOpenId) != input.WechatOpenId) + if (_cache.Get(input.SessionKey) != input.SessionKeyValue) { - throw new UserFriendlyException("无效的WechatOpenId"); + throw new UserFriendlyException("无效的SessionKeyValue"); } if (string.IsNullOrWhiteSpace(input.PersonName)) diff --git a/src/Shentun.WebPeis.Domain.Shared/Enums/CacheKeys.cs b/src/Shentun.WebPeis.Domain.Shared/Enums/CacheKeys.cs index 244962a..adbf700 100644 --- a/src/Shentun.WebPeis.Domain.Shared/Enums/CacheKeys.cs +++ b/src/Shentun.WebPeis.Domain.Shared/Enums/CacheKeys.cs @@ -8,5 +8,6 @@ namespace Shentun.WebPeis.Enums { public const string OpenIdKey = "OpenIdKey"; public const string SmsKey = "SmsKey"; + public const string SessionKey = "SessionKey"; } } diff --git a/test/Shentun.WebPeis.Application.Tests/appsettings.json b/test/Shentun.WebPeis.Application.Tests/appsettings.json index 6239e51..51239e4 100644 --- a/test/Shentun.WebPeis.Application.Tests/appsettings.json +++ b/test/Shentun.WebPeis.Application.Tests/appsettings.json @@ -47,6 +47,7 @@ "User": "admin", "Password": "888888", "VerifySmsTypeId": "3a12e09d-438a-1d08-d4f0-712aef13708d", + "VerifySmsValidTime": "1", "SmsAppId": "3a12e09f-8534-ec43-8c46-e61af0964ab6" } }