From ba0a0556de740d73b0b3a747df6c82d698583166 Mon Sep 17 00:00:00 2001
From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com>
Date: Thu, 6 Jun 2024 22:31:19 +0800
Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=BA=A6=E6=A8=A1=E6=9D=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Shentun.Sms.Client/CreateSmsTaskDto.cs | 90 ++++++
Shentun.Sms.Client/Shentun.Sms.Client.csproj | 18 ++
Shentun.Sms.Client/SmsClientHelper.cs | 263 ++++++++++++++++++
Shentun.Sms.Client/SmsLoginInputDto.cs | 14 +
Shentun.Sms.Client/SmsLoginOutDataDto.cs | 16 ++
Shentun.Sms.Client/SmsWebApiOutDto.cs | 17 ++
Shentun.WebPeis.sln | 7 +
.../JsonDateTimeConverter.cs | 30 ++
.../Persons/PersonAppService.cs | 27 +-
.../Shentun.WebPeis.Application.csproj | 1 +
.../Models/AppointScheduleTemplate.cs | 3 +
.../Models/AppointScheduleTemplateTime.cs | 45 +++
.../Shentun.WebPeis.Domain.csproj | 1 +
.../AppointScheduleTemplateTimeConfigure.cs | 48 ++++
.../EntityFrameworkCore/WebPeisDbContext.cs | 2 +
.../appsettings.json | 10 +-
.../PersonAppServiceTest.cs | 23 +-
.../appsettings.json | 10 +-
18 files changed, 608 insertions(+), 17 deletions(-)
create mode 100644 Shentun.Sms.Client/CreateSmsTaskDto.cs
create mode 100644 Shentun.Sms.Client/Shentun.Sms.Client.csproj
create mode 100644 Shentun.Sms.Client/SmsClientHelper.cs
create mode 100644 Shentun.Sms.Client/SmsLoginInputDto.cs
create mode 100644 Shentun.Sms.Client/SmsLoginOutDataDto.cs
create mode 100644 Shentun.Sms.Client/SmsWebApiOutDto.cs
create mode 100644 src/Shentun.Utilities/JsonDateTimeConverter.cs
create mode 100644 src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplateTime.cs
create mode 100644 src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointScheduleTemplateTimeConfigure.cs
diff --git a/Shentun.Sms.Client/CreateSmsTaskDto.cs b/Shentun.Sms.Client/CreateSmsTaskDto.cs
new file mode 100644
index 0000000..bdff2a4
--- /dev/null
+++ b/Shentun.Sms.Client/CreateSmsTaskDto.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Shentun.Sms.Client
+{
+ public class CreateSmsTaskDto
+ {
+ ///
+ /// 短信类别ID
+ ///
+ public Guid SmsTypeId { get; set; }
+
+ ///
+ /// 人员ID
+ ///
+ public string PersonId { get; set; }
+
+ ///
+ /// 姓名
+ ///
+ public string PersonName { get; set; }
+
+ ///
+ /// 手机号国家代码
+ ///
+ public string CountryCode { get; set; }
+
+ ///
+ /// 手机号
+ ///
+ public string MobileTelephone { get; set; }
+
+ ///
+ /// 短信内容
+ ///
+ public string Content { get; set; }
+
+
+ ///
+ /// 应用ID
+ ///
+ public Guid SmsAppId { get; set; }
+
+
+ ///
+ /// 第三方系统唯一ID
+ ///
+ public string? ThirdId { get; set; }
+
+
+
+ ///
+ /// 任务周期类别
+ ///
+ public char TaskCycleType { get; set; }
+
+
+ ///
+ /// 任务表达式
+ ///
+ public string? TaskCorn { get; set; }
+
+
+ ///
+ /// 停止执行时间
+ ///
+ public string? StopTime { get; set; }
+
+
+ /////
+ ///// 是否启用
+ /////
+ //public char IsActive { get; set; } = 'Y';
+
+ ///
+ /// 发送者用户ID
+ ///
+ public string? SenderId { get; set; }
+
+ ///
+ /// 发送者用户名
+ ///
+ public string? SenderName { get; set; }
+
+
+ }
+}
diff --git a/Shentun.Sms.Client/Shentun.Sms.Client.csproj b/Shentun.Sms.Client/Shentun.Sms.Client.csproj
new file mode 100644
index 0000000..423b7f6
--- /dev/null
+++ b/Shentun.Sms.Client/Shentun.Sms.Client.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Shentun.Sms.Client/SmsClientHelper.cs b/Shentun.Sms.Client/SmsClientHelper.cs
new file mode 100644
index 0000000..1826789
--- /dev/null
+++ b/Shentun.Sms.Client/SmsClientHelper.cs
@@ -0,0 +1,263 @@
+using Microsoft.Extensions.Configuration;
+using Shentun.Utilities;
+using System;
+using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
+using System.Linq;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+
+namespace Shentun.Sms.Client
+{
+ public class SmsClientHelper
+ {
+ protected static IConfiguration? _appConfig;
+ private static string? _baseAddress;
+ private static string? _createSmsTaskUrl;
+ private static string? _accesToken;
+ private static string? _user;
+ private static string? _password;
+ private static string? _email;
+ static SmsClientHelper()
+ {
+ _appConfig = new ConfigurationBuilder()
+ .SetBasePath(DirectoryHelper.GetAppDirectory()) // 设置基础路径为当前目录
+ .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
+ .Build();
+ _baseAddress = _appConfig.GetSection("Sms")
+ .GetSection("BaseAddress").Value;
+ _createSmsTaskUrl = _appConfig.GetSection("Sms")
+ .GetSection("CreateSmsTaskUrl").Value;
+ _user = _appConfig.GetSection("Sms")
+ .GetSection("User").Value;
+ _password = _appConfig.GetSection("Sms")
+ .GetSection("Password").Value;
+ }
+
+ public async static Task CreateSmsTask(CreateSmsTaskDto createSmsTaskDto)
+ {
+ if (createSmsTaskDto == null)
+ {
+ throw new Exception("createSmsTaskDto参数不能为空");
+ }
+
+ if (createSmsTaskDto.MobileTelephone.Length != 11)
+ {
+
+ throw new Exception("手机号长度必须为11位");
+ }
+ if(string.IsNullOrWhiteSpace(createSmsTaskDto.PersonId))
+ {
+ throw new Exception("人员ID不能为空");
+
+ }
+ if (string.IsNullOrWhiteSpace(createSmsTaskDto.PersonName))
+ {
+ throw new Exception("姓名不能为空");
+
+ }
+ if (string.IsNullOrWhiteSpace(createSmsTaskDto.CountryCode))
+ {
+ throw new Exception("国家编码不能为空");
+
+ }
+ if (string.IsNullOrWhiteSpace(createSmsTaskDto.Content))
+ {
+ throw new Exception("短信内容不能为空");
+
+ }
+ if (createSmsTaskDto.SmsAppId == null || createSmsTaskDto.SmsAppId == Guid.Empty)
+ {
+ var smsAppIdStr = _appConfig.GetSection("Sms")
+ .GetSection("SmsAppId").Value;
+ if (!Guid.TryParse(smsAppIdStr, out var smsAppId))
+ {
+ throw new Exception("解析短信应用ID错误");
+ }
+ createSmsTaskDto.SmsAppId = smsAppId;
+ }
+
+ var reslut = await CallAppServiceAsync(_createSmsTaskUrl, createSmsTaskDto);
+ }
+
+ public async static Task CreateVerifySmsTask(CreateSmsTaskDto smsDto)
+ {
+ var verifySmsTypeIdStr = _appConfig.GetSection("Sms")
+ .GetSection("VerifySmsTypeId").Value;
+ if (!Guid.TryParse(verifySmsTypeIdStr, out var verifySmsTypeId))
+ {
+ throw new Exception("解析校验短信类别ID错误");
+ }
+ smsDto.SmsTypeId = verifySmsTypeId;
+ await CreateSmsTask(smsDto);
+ }
+ public async static Task CallAppServiceAsync(string url, TInput data, string method = "post")
+ {
+ if (string.IsNullOrWhiteSpace(_baseAddress))
+ {
+ throw new Exception("_baseAddress不能为空");
+ }
+ string baseAddress = _baseAddress;
+ await CheckLoginAsync();
+ using (var httpClientHandler = new HttpClientHandler())
+ {
+ using (var httpClient = new HttpClient(httpClientHandler))
+ {
+ httpClient.BaseAddress = new Uri(baseAddress);
+
+ httpClient.DefaultRequestHeaders.Accept.Add(
+ new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
+ httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accesToken);
+ var jsonOptions = new JsonSerializerOptions
+ {
+ WriteIndented = true, // 设置为true以便于可读性更好的JSON输出
+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+ // 如果你想要对日期进行格式化,可以使用JsonConverter
+ Converters = { new JsonDateTimeConverter("yyyy-MM-dd HH:mm:ss") }
+ };
+
+ var sendData = System.Text.Json.JsonSerializer.Serialize(data, jsonOptions);
+ using (HttpContent httpContent = new StringContent(sendData))
+ {
+ httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ HttpResponseMessage response = null;
+ if (method == "post")
+ {
+ response = await httpClient.PostAsync(url, httpContent);
+ }
+ else
+ {
+ response = await httpClient.GetAsync(url);
+ }
+
+ string result;
+ if (!response.IsSuccessStatusCode)
+ {
+ result = response.Content.ReadAsStringAsync().Result;
+ throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result);
+ }
+ result = await response.Content.ReadAsStringAsync();
+
+ var resultDto = System.Text.Json.JsonSerializer.Deserialize>(result,jsonOptions);
+ if (resultDto.Code == -1)
+ {
+ throw new Exception($"调用WebApi失败,返回-1,消息:" + resultDto.Message);
+ }
+ return resultDto.Data;
+ }
+
+ }
+ }
+ }
+ public async static Task> LoginAsync()
+ {
+ if (string.IsNullOrWhiteSpace(_user))
+ {
+ throw new Exception("SelfUser不能为空");
+ }
+ if (string.IsNullOrWhiteSpace(_password))
+ {
+ throw new Exception("SelfPassword不能为空");
+ }
+ var relult = await LoginAsync(_user, _password);
+ return relult;
+ }
+ public async static Task> LoginAsync(string userId, string password)
+ {
+ if (string.IsNullOrWhiteSpace(userId))
+ {
+ throw new Exception("用户ID不能为空");
+ }
+ if (string.IsNullOrWhiteSpace(password))
+ {
+ throw new Exception("密码不能为空");
+ }
+ using (var httpClientHandler = new HttpClientHandler())
+ {
+ using (var httpClient = new HttpClient(httpClientHandler))
+ {
+ httpClient.BaseAddress = new Uri(_baseAddress);
+
+ httpClient.DefaultRequestHeaders.Accept.Add(
+ new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
+ var url = "api/app/CustomerUser/UserLogin";
+ var jsonOptions = new JsonSerializerOptions
+ {
+ WriteIndented = true, // 设置为true以便于可读性更好的JSON输出
+ PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+ // 如果你想要对日期进行格式化,可以使用JsonConverter
+ Converters = { new JsonDateTimeConverter("yyyy-MM-dd HH:mm:ss") }
+ };
+ var loginUser = new SmsLoginInputDto()
+ {
+ UserName = userId,
+ Password = password
+ };
+ var sendData = System.Text.Json.JsonSerializer.Serialize(loginUser);
+ using (HttpContent httpContent = new StringContent(sendData))
+ {
+ httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ HttpResponseMessage response = await httpClient.PostAsync(url, httpContent);
+ string result;
+ if (!response.IsSuccessStatusCode)
+ {
+ result = response.Content.ReadAsStringAsync().Result;
+ throw new Exception("登录短信系统时http通信错误:" + response.StatusCode + ",结果:" + result);
+ }
+ result = await response.Content.ReadAsStringAsync();
+ var restultDto = System.Text.Json.JsonSerializer.Deserialize>(result, jsonOptions);
+ if (restultDto == null)
+ {
+ throw new Exception("返回结果是空");
+ }
+ if (restultDto.Code != 1)
+ {
+ throw new Exception($"短信登录失败{restultDto.Message}");
+ }
+ _accesToken = restultDto.Data.access_token;
+ return restultDto;
+ }
+
+ }
+ }
+ }
+
+ private async static Task CheckLoginAsync()
+ {
+ if (string.IsNullOrWhiteSpace(_accesToken))
+ {
+ await LoginAsync();
+ }
+ else
+ {
+ var handler = new JwtSecurityTokenHandler();
+ var payload = handler.ReadJwtToken(_accesToken).Payload;
+ var claims = payload.Claims;
+ var exp = claims.First(claim => claim.Type == "exp").Value;
+ if (exp == null)
+ {
+ await LoginAsync();
+ }
+ else
+ {
+ if (long.TryParse(exp, out var expires))
+ {
+ var expireTime = DateTimeOffset.FromUnixTimeSeconds(expires).LocalDateTime;
+ if (expireTime <= DateTime.Now)
+ {
+ await LoginAsync();
+ }
+ }
+ else
+ {
+ await LoginAsync();
+ }
+
+ }
+
+ }
+ }
+ }
+}
diff --git a/Shentun.Sms.Client/SmsLoginInputDto.cs b/Shentun.Sms.Client/SmsLoginInputDto.cs
new file mode 100644
index 0000000..332639d
--- /dev/null
+++ b/Shentun.Sms.Client/SmsLoginInputDto.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Shentun.Sms.Client
+{
+ public class SmsLoginInputDto
+ {
+ public string UserName { get; set; }
+ public string Password { get; set; }
+ }
+}
diff --git a/Shentun.Sms.Client/SmsLoginOutDataDto.cs b/Shentun.Sms.Client/SmsLoginOutDataDto.cs
new file mode 100644
index 0000000..bca27b6
--- /dev/null
+++ b/Shentun.Sms.Client/SmsLoginOutDataDto.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Shentun.Sms.Client
+{
+ public class SmsLoginOutDataDto
+ {
+ public string access_token { get; set; }
+ public string token_type { get; set; }
+ public int expires_in { get; set; }
+ public string refresh_token { get; set; }
+ }
+}
diff --git a/Shentun.Sms.Client/SmsWebApiOutDto.cs b/Shentun.Sms.Client/SmsWebApiOutDto.cs
new file mode 100644
index 0000000..dce7303
--- /dev/null
+++ b/Shentun.Sms.Client/SmsWebApiOutDto.cs
@@ -0,0 +1,17 @@
+using NPOI.SS.Formula.Functions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Shentun.Sms.Client
+{
+ public class SmsWebApiOutDto
+ {
+ public int Code { get; set; }
+ public string Message { get; set; }
+ public T? Data { get; set; }
+
+ }
+}
diff --git a/Shentun.WebPeis.sln b/Shentun.WebPeis.sln
index e05f60e..433558f 100644
--- a/Shentun.WebPeis.sln
+++ b/Shentun.WebPeis.sln
@@ -39,6 +39,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shentun.Utilities", "src\Sh
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shentun.WebApi.Service", "src\Shentun.WebApi.Service\Shentun.WebApi.Service.csproj", "{6625C4ED-DAF2-41BA-8499-58655E4C1D3C}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shentun.Sms.Client", "Shentun.Sms.Client\Shentun.Sms.Client.csproj", "{B45965B5-7A87-4163-9904-2A2EEC84EEDC}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -109,6 +111,10 @@ Global
{6625C4ED-DAF2-41BA-8499-58655E4C1D3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6625C4ED-DAF2-41BA-8499-58655E4C1D3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6625C4ED-DAF2-41BA-8499-58655E4C1D3C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B45965B5-7A87-4163-9904-2A2EEC84EEDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B45965B5-7A87-4163-9904-2A2EEC84EEDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B45965B5-7A87-4163-9904-2A2EEC84EEDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B45965B5-7A87-4163-9904-2A2EEC84EEDC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -130,6 +136,7 @@ Global
{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{99FB7F67-8EB4-4448-A831-39EE7E5F59F7} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{6625C4ED-DAF2-41BA-8499-58655E4C1D3C} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
+ {B45965B5-7A87-4163-9904-2A2EEC84EEDC} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}
diff --git a/src/Shentun.Utilities/JsonDateTimeConverter.cs b/src/Shentun.Utilities/JsonDateTimeConverter.cs
new file mode 100644
index 0000000..9e725ce
--- /dev/null
+++ b/src/Shentun.Utilities/JsonDateTimeConverter.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+
+namespace Shentun.Utilities
+{
+ public class JsonDateTimeConverter : System.Text.Json.Serialization.JsonConverter
+ {
+ private readonly string _dateFormat;
+
+ public JsonDateTimeConverter(string dateFormat)
+ {
+ _dateFormat = dateFormat;
+ }
+
+ public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+ return DateTime.ParseExact(reader.GetString(), _dateFormat, null);
+ }
+
+ public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
+ {
+ writer.WriteStringValue(value.ToUniversalTime().ToString(_dateFormat));
+ }
+ }
+
+}
diff --git a/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs b/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs
index a023757..61a1eb4 100644
--- a/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs
+++ b/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs
@@ -34,6 +34,8 @@ using Shentun.WebPeis.PatientRegisters;
using Microsoft.AspNetCore.Http;
using System.IO;
using Shentun.WebPeis.CustomerOrgs;
+using Shentun.Utilities.Enums;
+using Shentun.Sms.Client;
namespace Shentun.WebPeis.Persons
{
///
@@ -68,7 +70,7 @@ namespace Shentun.WebPeis.Persons
IRepository patientRegisterRepository,
IRepository patientRepository,
CacheService cacheService,
- IHttpContextAccessor httpContextAccessor,
+ //IHttpContextAccessor httpContextAccessor,
IRepository customerOrgRepository)
{
_repository = repository;
@@ -82,7 +84,7 @@ namespace Shentun.WebPeis.Persons
_patientRegisterRepository = patientRegisterRepository;
_patientRepository = patientRepository;
_cacheService = cacheService;
- _httpContextAccessor = httpContextAccessor;
+ //_httpContextAccessor = httpContextAccessor;
_customerOrgRepository = customerOrgRepository;
}
@@ -432,21 +434,22 @@ namespace Shentun.WebPeis.Persons
}
- private async Task SendSms(string phone, string msg)
+ public async Task SendVerifySms(CreateSmsTaskDto createSmsTaskDto)
{
- if (phone.Length == 11)
+ if(createSmsTaskDto == null)
{
-
- phone = "+86" + phone;
- }
- else
- {
- throw new Exception("手机号必须是11位长");
+ throw new UserFriendlyException("createSmsTaskDto参数不能为空");
}
- //发送短信
+
+
+ var message = Shentun.Utilities.Encrypt.RandomHelper.CreateRandom(Utilities.Enums.RandomType.Num, 6);
+ createSmsTaskDto.Content = message+"|1";
+ //发送短信
+ createSmsTaskDto.TaskCycleType = '0';
+ await SmsClientHelper.CreateVerifySmsTask(createSmsTaskDto);
//存储短信校验码
- _cache.Set(phone, msg);
+ _cache.Set(createSmsTaskDto.MobileTelephone, message);
}
}
}
diff --git a/src/Shentun.WebPeis.Application/Shentun.WebPeis.Application.csproj b/src/Shentun.WebPeis.Application/Shentun.WebPeis.Application.csproj
index 296d670..e3fff53 100644
--- a/src/Shentun.WebPeis.Application/Shentun.WebPeis.Application.csproj
+++ b/src/Shentun.WebPeis.Application/Shentun.WebPeis.Application.csproj
@@ -10,6 +10,7 @@
+
diff --git a/src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplate.cs b/src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplate.cs
index 5e77ef3..5f6e287 100644
--- a/src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplate.cs
+++ b/src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplate.cs
@@ -64,6 +64,9 @@ public class AppointScheduleTemplate : AuditedEntity, IHasConcurrencyStamp, ID
public string? ConcurrencyStamp { get; set; }
+
+ public virtual ICollection AppointScheduleTemplateTimes { get; set; } = new List();
+
public override object[] GetKeys()
{
return [AppointScheduleTemplateId];
diff --git a/src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplateTime.cs b/src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplateTime.cs
new file mode 100644
index 0000000..558424c
--- /dev/null
+++ b/src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplateTime.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Domain.Entities.Auditing;
+using Volo.Abp.Domain.Entities;
+
+namespace Shentun.WebPeis.Models
+{
+ public class AppointScheduleTemplateTime : AuditedEntity, IHasConcurrencyStamp
+ {
+ ///
+ /// 主键
+ ///
+ public Guid AppointScheduleTemplateTimeId { get; set; }
+ public Guid AppointScheduleTemplateId { get; set; }
+ ///
+ /// 数量限制
+ ///
+
+ public int NumberLimit { get; set; }
+
+
+ ///
+ /// 开始时间
+ ///
+
+ public TimeOnly StartTime { get; set; }
+ ///
+ /// 结束时间
+ ///
+
+ public TimeOnly StopTime { get; set; }
+
+ public string? ConcurrencyStamp { get; set; }
+
+ public virtual AppointScheduleTemplate AppointScheduleTemplate { get; set; } = null!;
+
+ public override object[] GetKeys()
+ {
+ return [AppointScheduleTemplateTimeId];
+ }
+ }
+}
diff --git a/src/Shentun.WebPeis.Domain/Shentun.WebPeis.Domain.csproj b/src/Shentun.WebPeis.Domain/Shentun.WebPeis.Domain.csproj
index 9c53e8f..65db471 100644
--- a/src/Shentun.WebPeis.Domain/Shentun.WebPeis.Domain.csproj
+++ b/src/Shentun.WebPeis.Domain/Shentun.WebPeis.Domain.csproj
@@ -14,6 +14,7 @@
+
diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointScheduleTemplateTimeConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointScheduleTemplateTimeConfigure.cs
new file mode 100644
index 0000000..7f114a4
--- /dev/null
+++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointScheduleTemplateTimeConfigure.cs
@@ -0,0 +1,48 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using Shentun.WebPeis.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Domain.Entities;
+
+namespace Shentun.WebPeis.Configures
+{
+ public class AppointScheduleTemplateTimeConfigure : IEntityTypeConfiguration
+ {
+ public void Configure(EntityTypeBuilder entity)
+ {
+ entity.HasKey(e => e.AppointScheduleTemplateTimeId).HasName("appoint_schedule_template_time_pkey");
+
+ entity.ToTable("appoint_schedule_template_time");
+
+ entity.HasIndex(e =>new object[] {e.AppointScheduleTemplateId,e.StartTime }, "ix_appoint_schedule_template_time").IsUnique();
+
+ entity.Property(e => e.AppointScheduleTemplateTimeId)
+ .ValueGeneratedNever()
+ .HasColumnName("appoint_schedule_template_time_id");
+ entity.Property(e => e.StartTime).HasColumnName("start_time");
+ entity.Property(e => e.StopTime).HasColumnName("stop_time");
+ entity.Property(e => e.ConcurrencyStamp)
+ .HasMaxLength(40)
+ .HasColumnName("concurrency_stamp");
+ entity.Property(e => e.CreationTime)
+ .HasColumnType("timestamp without time zone")
+ .HasColumnName("creation_time");
+ entity.Property(e => e.CreatorId).HasColumnName("creator_id");
+ entity.Property(e => e.LastModificationTime)
+ .HasColumnType("timestamp without time zone")
+ .HasColumnName("last_modification_time");
+ entity.Property(e => e.LastModifierId).HasColumnName("last_modifier_id");
+ entity.Property(e => e.NumberLimit).IsRequired().HasColumnName("number_limit");
+ entity.HasOne(d => d.AppointScheduleTemplate).WithMany(p => p.AppointScheduleTemplateTimes)
+ .HasForeignKey(d => d.AppointScheduleTemplateId)
+ .OnDelete(DeleteBehavior.Cascade)
+ .HasConstraintName("fk_appoint_schedule_template_time");
+
+
+ }
+ }
+}
diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs b/src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs
index e8bfaa5..1ce068f 100644
--- a/src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs
+++ b/src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs
@@ -114,6 +114,8 @@ public partial class WebPeisDbContext : AbpDbContext,
public virtual DbSet AppointScheduleTemplates { get; set; }
+ public virtual DbSet AppointScheduleTemplateTimes { get; set; }
+
public virtual DbSet AppointScheduleTimes { get; set; }
public virtual DbSet Asbitems { get; set; }
diff --git a/src/Shentun.WebPeis.HttpApi.Host/appsettings.json b/src/Shentun.WebPeis.HttpApi.Host/appsettings.json
index a4d3f8b..1d14582 100644
--- a/src/Shentun.WebPeis.HttpApi.Host/appsettings.json
+++ b/src/Shentun.WebPeis.HttpApi.Host/appsettings.json
@@ -46,5 +46,13 @@
"RequestPath": "/Report", //体检报告请求路径
"Alias": "Report" //体检报告别名
}
- ]
+ ],
+ "Sms": {
+ "BaseAddress": "http://62.156.10.86:44382",
+ "CreateSmsTaskUrl": "api/app/SmsTask/Create",
+ "User": "admin",
+ "Password": "888888",
+ "VerifySmsTypeId": "3a12e09d-438a-1d08-d4f0-712aef13708d",
+ "SmsAppId": "3a12e09f-8534-ec43-8c46-e61af0964ab6"
+ }
}
diff --git a/test/Shentun.WebPeis.Application.Tests/PersonAppServiceTest.cs b/test/Shentun.WebPeis.Application.Tests/PersonAppServiceTest.cs
index 4454e93..154af41 100644
--- a/test/Shentun.WebPeis.Application.Tests/PersonAppServiceTest.cs
+++ b/test/Shentun.WebPeis.Application.Tests/PersonAppServiceTest.cs
@@ -1,4 +1,5 @@
-using Shentun.WebPeis.Enums;
+using Shentun.Sms.Client;
+using Shentun.WebPeis.Enums;
using Shentun.WebPeis.Models;
using Shentun.WebPeis.Persons;
using Shentun.WebPeis.Wechats;
@@ -15,7 +16,7 @@ using Xunit.Abstractions;
namespace Shentun.WebPeis
{
- public abstract class PersonAppServiceTest : WebPeisApplicationTestBase
+ public abstract class PersonAppServiceTest : WebPeisApplicationTestBase
where TStartupModule : IAbpModule
{
private readonly IRepository _repository;
@@ -63,7 +64,7 @@ namespace Shentun.WebPeis
SexId = SexFlag.Male,
WechatOpenId = "obZGv5RhSNxxpkDwT0Xaf9Fzn8NM",
MaritalStatusId = MaritalStatusFlag.Married,
-
+
};
@@ -86,5 +87,21 @@ namespace Shentun.WebPeis
await unitOfWork.CompleteAsync();
}
}
+ [Fact]
+ public async Task SendVerifySms()
+ {
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
+ {
+ var createSmsTaskDto = new CreateSmsTaskDto()
+ {
+ MobileTelephone = "18911254911",
+ CountryCode = "86",
+ PersonId = "0001",
+ PersonName = "张三"
+ };
+ await _appService.SendVerifySms(createSmsTaskDto);
+ }
+
+ }
}
}
diff --git a/test/Shentun.WebPeis.Application.Tests/appsettings.json b/test/Shentun.WebPeis.Application.Tests/appsettings.json
index 4e4ec5e..6239e51 100644
--- a/test/Shentun.WebPeis.Application.Tests/appsettings.json
+++ b/test/Shentun.WebPeis.Application.Tests/appsettings.json
@@ -40,5 +40,13 @@
"RequestPath": "/Report", //体检报告请求路径
"Alias": "Report" //体检报告别名
}
- ]
+ ],
+ "Sms": {
+ "BaseAddress": "http://62.156.10.86:44383",
+ "CreateSmsTaskUrl": "api/app/SmsTask/Create",
+ "User": "admin",
+ "Password": "888888",
+ "VerifySmsTypeId": "3a12e09d-438a-1d08-d4f0-712aef13708d",
+ "SmsAppId": "3a12e09f-8534-ec43-8c46-e61af0964ab6"
+ }
}