diff --git a/IRaCIS.Core.API/Controllers/DownLoadController.cs b/IRaCIS.Core.API/Controllers/DownLoadController.cs index f02a0ba3..cb12affd 100644 --- a/IRaCIS.Core.API/Controllers/DownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/DownLoadController.cs @@ -14,6 +14,7 @@ using System; using System.IO; using System.Linq; using System.Threading.Tasks; +using IRaCIS.Core.Domain.Share; using Microsoft.EntityFrameworkCore; namespace IRaCIS.Core.API.Controllers diff --git a/IRaCIS.Core.API/Controllers/StudyController.cs b/IRaCIS.Core.API/Controllers/StudyController.cs index bd1d11dc..e4b6f9d3 100644 --- a/IRaCIS.Core.API/Controllers/StudyController.cs +++ b/IRaCIS.Core.API/Controllers/StudyController.cs @@ -21,6 +21,7 @@ using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Application.Service.Inspection.Interface; using Newtonsoft.Json; using IRaCIS.Core.Application.Service.Inspection.DTO; +using IRaCIS.Core.Domain.Share; namespace IRaCIS.Api.Controllers { diff --git a/IRaCIS.Core.API/_ServiceExtensions/AutofacModuleSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/AutofacModuleSetup.cs index 9e65f3c6..a544bcd4 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/AutofacModuleSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/AutofacModuleSetup.cs @@ -1,18 +1,17 @@ using Autofac; using Autofac.Extras.DynamicProxy; -using IRaCIS.Application.Interfaces; -using IRaCIS.Application.Services; using IRaCIS.Core.API.Utility.AOP; using IRaCIS.Core.Application; using IRaCIS.Core.Application.AOP; using IRaCIS.Core.Application.BackGroundJob; using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Infra.EFCore.AuthUser; using Microsoft.AspNetCore.Http; using Panda.DynamicWebApi; using System; using System.Linq; using System.Reflection; +using IRaCIS.Core.Domain.Models; +using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.API @@ -56,8 +55,9 @@ namespace IRaCIS.Core.API containerBuilder.RegisterAssemblyTypes(infrastructure).AsImplementedInterfaces(); containerBuilder.RegisterType().As().SingleInstance(); + containerBuilder.RegisterType().As().InstancePerLifetimeScope(); + //containerBuilder.RegisterType().InstancePerLifetimeScope(); - containerBuilder.RegisterType().SingleInstance(); diff --git a/IRaCIS.Core.API/_ServiceExtensions/Serilog/HttpContextEnricher.cs b/IRaCIS.Core.API/_ServiceExtensions/Serilog/HttpContextEnricher.cs index b4ca797d..494598f8 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/Serilog/HttpContextEnricher.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/Serilog/HttpContextEnricher.cs @@ -1,5 +1,4 @@ -using IRaCIS.Core.Infra.EFCore.AuthUser; -using IRaCIS.Core.Infrastructure; +using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Infrastructure.Extention; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; @@ -9,6 +8,7 @@ using System; using System.IO; using System.Text; using System.Threading.Tasks; +using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.API { diff --git a/IRaCIS.Core.Application/Auth/TokenService.cs b/IRaCIS.Core.Application/Auth/TokenService.cs index a31a0994..bb40d200 100644 --- a/IRaCIS.Core.Application/Auth/TokenService.cs +++ b/IRaCIS.Core.Application/Auth/TokenService.cs @@ -1,7 +1,6 @@ using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Infra.EFCore.AuthUser; using Microsoft.Extensions.Options; namespace IRaCIS.Core.Application.Auth diff --git a/IRaCIS.Core.Application/BaseService.cs b/IRaCIS.Core.Application/BaseService.cs index 7864328a..9101ffa8 100644 --- a/IRaCIS.Core.Application/BaseService.cs +++ b/IRaCIS.Core.Application/BaseService.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.Localization; using Panda.DynamicWebApi; using Panda.DynamicWebApi.Attributes; using System.Diagnostics.CodeAnalysis; +using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.Application { diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 09132fed..f3a8d1bd 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -1652,7 +1652,7 @@ 构造函数注入 - + 构造函数注入 diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportHelper.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportHelper.cs index bcca83db..8753024f 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportHelper.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportHelper.cs @@ -38,7 +38,7 @@ public static class ExcelExportHelper return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { - FileDownloadName = $"{exportFileNamePrefix}_{doc.Name.Substring(0,doc.Name.LastIndexOf('.'))}{DateTime.Now.ToString("yyyy-MM-dd:hh:mm:ss")}.xlsx" + FileDownloadName = $"{exportFileNamePrefix}_{doc.Name.Substring(0,doc.Name.LastIndexOf('.'))}——{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx" }; #endregion diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index 6a93b15d..729d37e8 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -13,6 +13,8 @@ namespace IRaCIS.Application.Services [HttpPost] public string Get(testModel testModel) { + + var c = _repository.Where().Select(t=>t.MappedValue).First(); CultureInfo culture = CultureInfo.CurrentUICulture; var a = 123; diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs b/IRaCIS.Core.Domain.Share/AuthUser/IUserInfo.cs similarity index 90% rename from IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs rename to IRaCIS.Core.Domain.Share/AuthUser/IUserInfo.cs index f1624312..a9ac3109 100644 --- a/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs +++ b/IRaCIS.Core.Domain.Share/AuthUser/IUserInfo.cs @@ -1,7 +1,6 @@ using System; -using Microsoft.AspNetCore.Mvc.ApiExplorer; -namespace IRaCIS.Core.Infra.EFCore +namespace IRaCIS.Core.Domain.Share { /// /// 用户信息接口 diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs b/IRaCIS.Core.Domain.Share/AuthUser/UserInfo.cs similarity index 98% rename from IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs rename to IRaCIS.Core.Domain.Share/AuthUser/UserInfo.cs index c18544af..9adda62c 100644 --- a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs +++ b/IRaCIS.Core.Domain.Share/AuthUser/UserInfo.cs @@ -2,7 +2,7 @@ using IRaCIS.Core.Domain.Share; using Microsoft.AspNetCore.Http; -namespace IRaCIS.Core.Infra.EFCore.AuthUser +namespace IRaCIS.Core.Domain.Share { /// /// 用户信息 @@ -190,7 +190,7 @@ namespace IRaCIS.Core.Infra.EFCore.AuthUser { var lan = _accessor?.HttpContext?.Request?.Headers["Accept-Language"]; - if ( !string.IsNullOrEmpty(lan.Value)) + if ( lan is not null && !string.IsNullOrEmpty(lan.Value)) { return lan.Value == "en-US,en;q=0.5".ToString(); } diff --git a/IRaCIS.Core.Domain/Common/Dictionary.cs b/IRaCIS.Core.Domain/Common/Dictionary.cs index 3a8aeac0..7cfe4f36 100644 --- a/IRaCIS.Core.Domain/Common/Dictionary.cs +++ b/IRaCIS.Core.Domain/Common/Dictionary.cs @@ -9,21 +9,26 @@ namespace IRaCIS.Core.Domain.Models [Table("Dictionary")] public partial class Dictionary : Entity, IAuditUpdate, IAuditAdd { + private readonly IUserInfo _userInfo; public List DoctorDicRelationList { get; set; } = new List(); + // + public Dictionary() + { + + } + + public Dictionary(IUserInfo userInfo ) + { + _userInfo = userInfo; + } - - [StringLength(50)] - public string KeyName { get; set; } = string.Empty; - - - [StringLength(100)] + [Column("Value")] public string Value { get; set; } = string.Empty; - - [StringLength(100)] + [Column("ValueCN")] public string ValueCN { get; set; } = string.Empty; @@ -59,5 +64,16 @@ namespace IRaCIS.Core.Domain.Models [ForeignKey("ParentId")] public Dictionary Parent { get; set; } + + + [StringLength(50)] + public string KeyName { get; set; } = string.Empty; + + + // + [NotMapped] + public string MappedValue => _userInfo.IsEn_Us ? Value : ValueCN; + + } } diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 00c9034c..cb4c5ae9 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -8,6 +8,8 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.ChangeTracking; using System.Reflection; +using IRaCIS.Core.Domain.Share; +using UserTypeGroup = IRaCIS.Core.Domain.Models.UserTypeGroup; namespace IRaCIS.Core.Infra.EFCore { @@ -25,6 +27,8 @@ namespace IRaCIS.Core.Infra.EFCore _userInfo = userInfo; //_configuration = configuration; } + + //比数据库上下文构造函数先执行 不能构造函数注入的方式使用配置文件 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { @@ -52,8 +56,13 @@ namespace IRaCIS.Core.Infra.EFCore base.OnModelCreating(modelBuilder); - modelBuilder.Entity() - .HasQueryFilter(t => t.IsDeleted == false); + //modelBuilder.Entity().Ignore(t => t.MappedValue); + //modelBuilder.Entity().Property(t => t.MappedValue).HasComputedColumnSql(_userInfo.IsEn_Us? "[Value]":"[ValueCN]"); + + //modelBuilder.Entity().Property(t => t.MappedValue).HasColumnName(_userInfo.IsEn_Us ? "Value" : "ValueCN").UsePropertyAccessMode(PropertyAccessMode.Property); + + //modelBuilder.Entity() + // .HasQueryFilter(t => t.IsDeleted == false); // 软删除配置 foreach (var entityType in modelBuilder.Model.GetEntityTypes())