From a6cfb49ba8fb52ff7c6eb1e52b678c9687d1063c Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 12 Apr 2024 15:32:34 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=85=A8=E5=B1=80=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Filter/JsonTimeSpanConverter.cs | 24 +++++++++++++++ .../PeisHttpApiHostModule.cs | 30 ++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/Shentun.Peis.HttpApi.Host/Filter/JsonTimeSpanConverter.cs diff --git a/src/Shentun.Peis.HttpApi.Host/Filter/JsonTimeSpanConverter.cs b/src/Shentun.Peis.HttpApi.Host/Filter/JsonTimeSpanConverter.cs new file mode 100644 index 0000000..900df86 --- /dev/null +++ b/src/Shentun.Peis.HttpApi.Host/Filter/JsonTimeSpanConverter.cs @@ -0,0 +1,24 @@ +using System.Text.Json; +using System; +using System.Text.Json.Serialization; + +namespace Shentun.Peis.Filter +{ + /// + /// 转换时间 + /// + public class JsonTimeSpanConverter : JsonConverter + { + public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + var value = reader.GetString(); + return TimeSpan.TryParse(value, out var timeSpan) ? timeSpan : new TimeSpan(); + } + + public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options) + { + var timeSpanString = value.ToString(); + writer.WriteStringValue(timeSpanString); + } + } +} diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs index 4a698ce..aaf9bdb 100644 --- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs +++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs @@ -52,6 +52,9 @@ using Microsoft.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Http; using Shentun.Peis.Filter; using Shentun.Peis.VirtualPath; +using System.Text.Encodings.Web; +using System.Text.Unicode; +using Volo.Abp.Json; namespace Shentun.Peis; [DependsOn( @@ -104,7 +107,7 @@ public class PeisHttpApiHostModule : AbpModule ConfigureCors(context, configuration); ConfigureSwaggerServices(context, configuration); - + ConfigureJsonOptions(); //全局配置api返回值中的日期默认格式 //密码策略配置 context.Services.Configure(opt => @@ -178,6 +181,31 @@ public class PeisHttpApiHostModule : AbpModule } + /// + /// 全局转换日期格式 + /// + private void ConfigureJsonOptions() + { + //context.Services.AddControllers().AddJsonOptions(options => + //{ + // options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); + // options.JsonSerializerOptions.PropertyNamingPolicy = null; + //}); + Configure(x => + { + x.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); + x.JsonSerializerOptions.PropertyNamingPolicy = null; + x.JsonSerializerOptions.Converters.Add(new JsonTimeSpanConverter()); + }); + + Configure(x => + { + x.DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + }); + } + + + private void ConfigureAuthentication(ServiceConfigurationContext context) { context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme); From b9cfade714ceb743193018065781286140cc3283 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 12 Apr 2024 17:23:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Shentun.Peis.Application.csproj | 1 - .../PeisHttpApiHostModule.cs | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Shentun.Peis.Application/Shentun.Peis.Application.csproj b/src/Shentun.Peis.Application/Shentun.Peis.Application.csproj index 0a95698..ca2ad41 100644 --- a/src/Shentun.Peis.Application/Shentun.Peis.Application.csproj +++ b/src/Shentun.Peis.Application/Shentun.Peis.Application.csproj @@ -22,7 +22,6 @@ - diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs index aaf9bdb..fcaa56d 100644 --- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs +++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs @@ -191,12 +191,12 @@ public class PeisHttpApiHostModule : AbpModule // options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); // options.JsonSerializerOptions.PropertyNamingPolicy = null; //}); - Configure(x => - { - x.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); - x.JsonSerializerOptions.PropertyNamingPolicy = null; - x.JsonSerializerOptions.Converters.Add(new JsonTimeSpanConverter()); - }); + //Configure(x => + //{ + // x.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); + // //x.JsonSerializerOptions.PropertyNamingPolicy = null; + // x.JsonSerializerOptions.Converters.Add(new JsonTimeSpanConverter()); + //}); Configure(x => { From 627355dae6941ec2c66c26dc52e818424630d7c9 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 12 Apr 2024 17:27:38 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Books/HelloAAppService.cs | 8 +-- .../Books/QiNiuDemo.cs | 67 ------------------- 2 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 src/Shentun.Peis.Application/Books/QiNiuDemo.cs diff --git a/src/Shentun.Peis.Application/Books/HelloAAppService.cs b/src/Shentun.Peis.Application/Books/HelloAAppService.cs index 26812ee..32682f2 100644 --- a/src/Shentun.Peis.Application/Books/HelloAAppService.cs +++ b/src/Shentun.Peis.Application/Books/HelloAAppService.cs @@ -53,13 +53,7 @@ namespace Shentun.Peis.Books } - - public async void Sa() - { - var s1 = await _helloARepository.FindAsync(m => m.AName == "45645454"); - - QiNiuHelper.Upload_QiNiu(); - } + public async Task> GetListAsync() { diff --git a/src/Shentun.Peis.Application/Books/QiNiuDemo.cs b/src/Shentun.Peis.Application/Books/QiNiuDemo.cs deleted file mode 100644 index 28d3099..0000000 --- a/src/Shentun.Peis.Application/Books/QiNiuDemo.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Application.Services; -using System.IO; -using Aliyun.OSS; -using System.Security.AccessControl; - -namespace Shentun.Peis.Books -{ - - - public static class QiNiuHelper - { - - // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM - // 用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 - - const string accessKeyId = "LTAI5tBNDdiV7JudVvaQhU1t"; - const string accessKeySecret = "sA6k0TbeX8w2cv7YhcTed7wyt0EBdN"; - - // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint - // 填写为https://oss-cn-hangzhou.aliyuncs.com。 - const string endpoint = "https://oss-cn-beijing.aliyuncs.com"; - - // 填写Bucket名称。 - const string bucketName = "whdshake"; - - public static void Upload_QiNiu() - { - - - // 填写Object完整路径。Object完整路径中不能包含Bucket名称。 - // 即:objectName为文件上传到阿里云OSS上的文件夹路径 - var objectName = "imgae/222.png"; - - // 填写本地文件的完整路径。如果未指定本地路径, - // 则默认从示例程序所属项目对应本地路径中上传文件。 - var localFilename = @"D:\aaa.png"; - - //System.Web.HttpContext.Current.Server.MapPath("imgae.png"); - // 创建OssClient实例。 - var client = new Aliyun.OSS.OssClient(endpoint, accessKeyId, accessKeySecret); - try - { - // 上传文件。 - client.PutObject(bucketName, objectName, localFilename); - Console.WriteLine("1"); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - - } - - - } - - - - - - -} From 9f5cb3766cc8b3af69b6907ed0da95f9f9b69404 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 12 Apr 2024 17:49:07 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E9=A2=84=E7=99=BB=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PatientRegisterAppService.cs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index b274233..6ecf9f1 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -679,6 +679,7 @@ namespace Shentun.Peis.PatientRegisters /// /// [HttpPost("api/patientregister/createreturninfo")] + [RemoteService(false)] public async Task CreateReturnInfoAsync(CreatePatientRegisterDto input) { throw new UserFriendlyException("改接口已经禁止使用"); @@ -1011,19 +1012,19 @@ namespace Shentun.Peis.PatientRegisters sumquery = sumquery.Where(m => m.a.CompleteFlag == input.CompleteFlag); - if (input.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration && input.IsFilterPreRegistration != null && input.IsFilterPreRegistration == 'Y') - { - //直接过滤 - sumquery = sumquery.Where(m => m.a.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration); - } + //if (input.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration && input.IsFilterPreRegistration != null && input.IsFilterPreRegistration == 'Y') + //{ + // //直接过滤 + // sumquery = sumquery.Where(m => m.a.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration); + //} } else { - if (input.IsFilterPreRegistration != null && input.IsFilterPreRegistration == 'Y') - { - //直接过滤 - sumquery = sumquery.Where(m => m.a.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration); - } + //if (input.IsFilterPreRegistration != null && input.IsFilterPreRegistration == 'Y') + //{ + //直接过滤 + sumquery = sumquery.Where(m => m.a.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration); + //} } if (input.IsAudit != null) @@ -2499,7 +2500,7 @@ namespace Shentun.Peis.PatientRegisters patientRegisterList.ForEach(f => { f.IsMedicalStart = 'Y'; - f.MedicalStartDate =DateTime.Now; + f.MedicalStartDate = DateTime.Now; } );