diff --git a/IRaCIS.Core.Domain/Allocation/SubjectUser.cs b/IRaCIS.Core.Domain/Allocation/SubjectUser.cs
index 5a901de12..88680dc39 100644
--- a/IRaCIS.Core.Domain/Allocation/SubjectUser.cs
+++ b/IRaCIS.Core.Domain/Allocation/SubjectUser.cs
@@ -8,15 +8,15 @@ using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Collections.Generic;
+using System.ComponentModel;
namespace IRaCIS.Core.Domain.Models
{
- ///
- ///SubjectUser
- ///
- [Table("SubjectUser")]
- public class SubjectUser : BaseFullAuditEntity
- {
+
+ [Description("受试者某标准阅片用户中间关系表")]
+ [Table("SubjectUser")]
+ public class SubjectUser : BaseFullAuditEntity
+ {
#region 导航属性
[JsonIgnore]
@@ -38,27 +38,27 @@ namespace IRaCIS.Core.Domain.Models
public Guid TrialId { get; set; }
- public Guid TrialReadingCriterionId { get; set; }
-
- public DateTime? AssignTime { get; set; }
+ public Guid TrialReadingCriterionId { 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; }
}
-}
+}
diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs
index 2a7d20bec..446560df0 100644
--- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs
+++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs
@@ -21,6 +21,11 @@ using System.Threading.Tasks;
namespace IRaCIS.Core.Infra.EFCore.Common
{
+ public interface IAuditingData
+ {
+
+ Task InsertAddEntitys(List entitys);
+ }
public static class AuditOpt
{
public static readonly string Add = "Add";
diff --git a/IRaCIS.Core.Infra.EFCore/Common/IAuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/IAuditingData.cs
deleted file mode 100644
index 4c4debaab..000000000
--- a/IRaCIS.Core.Infra.EFCore/Common/IAuditingData.cs
+++ /dev/null
@@ -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 entitys);
-
- Task InsertAddEntitys(List entitys);
- }
-}
diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
index 7f83a3957..33cc1c13e 100644
--- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
+++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
@@ -22,6 +22,9 @@ using EntityFramework.Exceptions.Common;
using System.Data;
using IRaCIS.Core.Infrastructure;
using System.Reflection.Metadata;
+using System.Collections.Generic;
+using System.ComponentModel;
+using Microsoft.VisualBasic;
namespace IRaCIS.Core.Infra.EFCore
{
@@ -75,7 +78,8 @@ namespace IRaCIS.Core.Infra.EFCore
builder.HasNoKey();
});
-
+
+
//遍历实体模型手动配置
var typesToRegister = Assembly.GetExecutingAssembly().GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null);
foreach (var type in typesToRegister)
@@ -86,7 +90,6 @@ namespace IRaCIS.Core.Infra.EFCore
base.OnModelCreating(modelBuilder);
-
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
// 软删除配置
@@ -100,8 +103,6 @@ namespace IRaCIS.Core.Infra.EFCore
{
modelBuilder.Entity(entityType.ClrType).Property(nameof(Entity.Id)).HasValueGenerator();
}
-
-
}
}
@@ -116,11 +117,71 @@ namespace IRaCIS.Core.Infra.EFCore
{
return Set().FromSqlRaw($"EXEC dbo.procGetTableColumn {tableName}");
}
+
+ ///
+ /// 直接获取代码定义的模型,以及表上定义的Description 获取表信息 以及备注
+ ///
+ ///
+ public List GetContextTablesList()
+ {
+ var tableList = new List();
+
+ foreach (var entityType in this.Model.GetEntityTypes())
+ {
+ var clrType = entityType.ClrType;
+ var tableName = entityType.GetTableName();
+
+ var tableDescription = clrType.GetCustomAttribute()?.Description ?? string.Empty;
+
+ tableList.Add(new TableList
+ {
+ Name = tableName,
+ Remake = tableDescription,
+ });
+ }
+
+ return tableList;
+ }
+
+ ///
+ /// 直接获取代码定义的某个表的属性,以及属性上定义的Description 获取备注
+ ///
+ ///
+ public List GetContextTableColumnList(string tableName)
+ {
+ var tableColumList = new List();
+
+ 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()?.Description ?? string.Empty;
+
+ tableColumList.Add(new TableList
+ {
+ Name = tableName,
+ Remake = columnDescription,
+ });
+ }
+
+
+
+ return tableColumList;
+ }
#endregion
public override async Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
{
+
// 采用触发器的方式 设置 CreateUserId CreateTime UpdateTime UpdateUserId 稽查实体里面没有这四个字段的值 因为先后顺序的原因
await AddAudit();
@@ -271,7 +332,6 @@ namespace IRaCIS.Core.Infra.EFCore
public virtual DbSet ReadingQuestionTrial { get; set; }
- //public virtual DbSet ReadingClinicalDataView { get; set; }
public virtual DbSet ReadingClinicalDataPDF { get; set; }
public virtual DbSet ReadingConsistentClinicalData { get; set; }
diff --git a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt
index 248a2d82a..cdca2030c 100644
--- a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt
+++ b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt
@@ -40,16 +40,15 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace IRaCIS.Core.Domain.Models
{
- ///
- ///<#=tableName#>
- ///
+
+ [Description("ע: <#=tableName#>")]
[Table("<#=tableName#>")]
public class <#=tableName#> : BaseFullAuditEntity
{
<# var excludedColumns = new[] { "CreateUserId", "Id", "UpdateUserId", "CreateTime", "UpdateTime", "DeleteUserId", "IsDeleted", "DeletedTime" };#>
<# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){ #>
<# if (!excludedColumns.Contains(column.ColumnName)){ #>
- /// <#= column.Remark == "" ? column.ColumnName : column.Remark.Replace("\r\n"," ") #>
+ [Description("<#= column.Remark == "" ? "" : column.Remark.Replace("\r\n"," ") #>")]
public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
<#}#>
<#}#>