预备优化掉存储过程
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
7dc40fbc5c
commit
5ccfe70f97
|
@ -8,15 +8,15 @@ using IRaCIS.Core.Domain.Share;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Domain.Models
|
namespace IRaCIS.Core.Domain.Models
|
||||||
{
|
{
|
||||||
///<summary>
|
|
||||||
///SubjectUser
|
[Description("受试者某标准阅片用户中间关系表")]
|
||||||
///</summary>
|
[Table("SubjectUser")]
|
||||||
[Table("SubjectUser")]
|
public class SubjectUser : BaseFullAuditEntity
|
||||||
public class SubjectUser : BaseFullAuditEntity
|
{
|
||||||
{
|
|
||||||
|
|
||||||
#region 导航属性
|
#region 导航属性
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
|
@ -38,27 +38,27 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
|
|
||||||
public Guid TrialId { get; set; }
|
public Guid TrialId { get; set; }
|
||||||
|
|
||||||
public Guid TrialReadingCriterionId { get; set; }
|
public Guid TrialReadingCriterionId { get; set; }
|
||||||
|
|
||||||
public DateTime? AssignTime { get; set; }
|
|
||||||
|
|
||||||
public Guid SubjectId { get; set; }
|
public DateTime? AssignTime { get; set; }
|
||||||
|
|
||||||
public Subject Subject { get; set; }
|
public Guid SubjectId { get; set; }
|
||||||
|
|
||||||
|
public Subject Subject { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public Guid DoctorUserId { get; set; }
|
public Guid DoctorUserId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public Arm ArmEnum { get; set; }
|
public Arm ArmEnum { get; set; }
|
||||||
|
|
||||||
public bool IsConfirmed { get; set; } = true;
|
public bool IsConfirmed { get; set; } = true;
|
||||||
|
|
||||||
//该属性有值 说明该医生被替换了 分配的时候 要过滤掉
|
//该属性有值 说明该医生被替换了 分配的时候 要过滤掉
|
||||||
public Guid? OrignalSubjectUserId { get; set; }
|
public Guid? OrignalSubjectUserId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,11 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infra.EFCore.Common
|
namespace IRaCIS.Core.Infra.EFCore.Common
|
||||||
{
|
{
|
||||||
|
public interface IAuditingData
|
||||||
|
{
|
||||||
|
|
||||||
|
Task InsertAddEntitys(List<EntityEntry> entitys);
|
||||||
|
}
|
||||||
public static class AuditOpt
|
public static class AuditOpt
|
||||||
{
|
{
|
||||||
public static readonly string Add = "Add";
|
public static readonly string Add = "Add";
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infra.EFCore.Common
|
|
||||||
{
|
|
||||||
public interface IAuditingData
|
|
||||||
{
|
|
||||||
//Task IncomingEntitys(List<EntityEntry> entitys);
|
|
||||||
|
|
||||||
Task InsertAddEntitys(List<EntityEntry> entitys);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,6 +22,9 @@ using EntityFramework.Exceptions.Common;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using IRaCIS.Core.Infrastructure;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using System.Reflection.Metadata;
|
using System.Reflection.Metadata;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using Microsoft.VisualBasic;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infra.EFCore
|
namespace IRaCIS.Core.Infra.EFCore
|
||||||
{
|
{
|
||||||
|
@ -75,7 +78,8 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
builder.HasNoKey();
|
builder.HasNoKey();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//遍历实体模型手动配置
|
//遍历实体模型手动配置
|
||||||
var typesToRegister = Assembly.GetExecutingAssembly().GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null);
|
var typesToRegister = Assembly.GetExecutingAssembly().GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null);
|
||||||
foreach (var type in typesToRegister)
|
foreach (var type in typesToRegister)
|
||||||
|
@ -86,7 +90,6 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
|
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
|
|
||||||
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
|
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
|
||||||
{
|
{
|
||||||
// 软删除配置
|
// 软删除配置
|
||||||
|
@ -100,8 +103,6 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
{
|
{
|
||||||
modelBuilder.Entity(entityType.ClrType).Property<Guid>(nameof(Entity.Id)).HasValueGenerator<MySequentialGuidValueGenerator>();
|
modelBuilder.Entity(entityType.ClrType).Property<Guid>(nameof(Entity.Id)).HasValueGenerator<MySequentialGuidValueGenerator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -116,11 +117,71 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
{
|
{
|
||||||
return Set<TableList>().FromSqlRaw($"EXEC dbo.procGetTableColumn {tableName}");
|
return Set<TableList>().FromSqlRaw($"EXEC dbo.procGetTableColumn {tableName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 直接获取代码定义的模型,以及表上定义的Description 获取表信息 以及备注
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<TableList> GetContextTablesList()
|
||||||
|
{
|
||||||
|
var tableList = new List<TableList>();
|
||||||
|
|
||||||
|
foreach (var entityType in this.Model.GetEntityTypes())
|
||||||
|
{
|
||||||
|
var clrType = entityType.ClrType;
|
||||||
|
var tableName = entityType.GetTableName();
|
||||||
|
|
||||||
|
var tableDescription = clrType.GetCustomAttribute<DescriptionAttribute>()?.Description ?? string.Empty;
|
||||||
|
|
||||||
|
tableList.Add(new TableList
|
||||||
|
{
|
||||||
|
Name = tableName,
|
||||||
|
Remake = tableDescription,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return tableList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 直接获取代码定义的某个表的属性,以及属性上定义的Description 获取备注
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<TableList> GetContextTableColumnList(string tableName)
|
||||||
|
{
|
||||||
|
var tableColumList = new List<TableList>();
|
||||||
|
|
||||||
|
var entityType = this.Model.GetEntityTypes().FirstOrDefault(t => t.GetTableName().ToLower() == tableName.ToLower());
|
||||||
|
|
||||||
|
if (entityType == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Table '{tableName}' not found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var clrType = entityType.ClrType;
|
||||||
|
|
||||||
|
foreach (var property in entityType.GetProperties())
|
||||||
|
{
|
||||||
|
var columnName = property.GetColumnName();
|
||||||
|
var columnDescription = clrType.GetProperty(property.Name)?.GetCustomAttribute<DescriptionAttribute>()?.Description ?? string.Empty;
|
||||||
|
|
||||||
|
tableColumList.Add(new TableList
|
||||||
|
{
|
||||||
|
Name = tableName,
|
||||||
|
Remake = columnDescription,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return tableColumList;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||||
{
|
{
|
||||||
|
|
||||||
// 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因
|
// 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因
|
||||||
await AddAudit();
|
await AddAudit();
|
||||||
|
|
||||||
|
@ -271,7 +332,6 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
|
|
||||||
public virtual DbSet<ReadingQuestionTrial> ReadingQuestionTrial { get; set; }
|
public virtual DbSet<ReadingQuestionTrial> ReadingQuestionTrial { get; set; }
|
||||||
|
|
||||||
//public virtual DbSet<ReadingClinicalDataView> ReadingClinicalDataView { get; set; }
|
|
||||||
|
|
||||||
public virtual DbSet<ReadingClinicalDataPDF> ReadingClinicalDataPDF { get; set; }
|
public virtual DbSet<ReadingClinicalDataPDF> ReadingClinicalDataPDF { get; set; }
|
||||||
public virtual DbSet<ReadingConsistentClinicalData> ReadingConsistentClinicalData { get; set; }
|
public virtual DbSet<ReadingConsistentClinicalData> ReadingConsistentClinicalData { get; set; }
|
||||||
|
|
|
@ -40,16 +40,15 @@ using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
namespace IRaCIS.Core.Domain.Models
|
namespace IRaCIS.Core.Domain.Models
|
||||||
{
|
{
|
||||||
///<summary>
|
|
||||||
///<#=tableName#>
|
[Description("备注: <#=tableName#>")]
|
||||||
///</summary>
|
|
||||||
[Table("<#=tableName#>")]
|
[Table("<#=tableName#>")]
|
||||||
public class <#=tableName#> : BaseFullAuditEntity
|
public class <#=tableName#> : BaseFullAuditEntity
|
||||||
{
|
{
|
||||||
<# var excludedColumns = new[] { "CreateUserId", "Id", "UpdateUserId", "CreateTime", "UpdateTime", "DeleteUserId", "IsDeleted", "DeletedTime" };#>
|
<# var excludedColumns = new[] { "CreateUserId", "Id", "UpdateUserId", "CreateTime", "UpdateTime", "DeleteUserId", "IsDeleted", "DeletedTime" };#>
|
||||||
<# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){ #>
|
<# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){ #>
|
||||||
<# if (!excludedColumns.Contains(column.ColumnName)){ #>
|
<# if (!excludedColumns.Contains(column.ColumnName)){ #>
|
||||||
/// <summary> <#= column.Remark == "" ? column.ColumnName : column.Remark.Replace("\r\n"," ") #> </summary>
|
[Description("<#= column.Remark == "" ? "" : column.Remark.Replace("\r\n"," ") #>")]
|
||||||
public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
|
public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
|
||||||
<#}#>
|
<#}#>
|
||||||
<#}#>
|
<#}#>
|
||||||
|
|
Loading…
Reference in New Issue