using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Shentun.Peis.EntityFrameworkCore; using Shentun.Peis.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Shentun.Peis.DbMapping { internal class ItemDbMapping : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder entity) { entity.HasComment("项目设置"); entity.Property(t => t.DisplayName).HasComment("名称").IsRequired(); entity.Property(t => t.EnglishShortName).HasComment("英文缩写"); entity.Property(t => t.ItemTypeId).HasComment("项目类别").IsRequired().IsFixedLength(); entity.Property(t => t.Price).HasComment("价格").IsRequired().HasDefaultValueSql("0"); entity.Property(t => t.PriceItemId).HasComment("价表项目编码"); entity.Property(t => t.UnitId).HasComment("单位"); entity.Property(t => t.DefaultResult).HasComment("默认结果"); entity.Property(t => t.ReferenceRangeTypeFlag). HasComment("参考范围类别0-无参考范围,1-数字型,2-字符型,3-性激素").IsRequired(). HasDefaultValueSql("'0'::bpchar"); entity.Property(t => t.IsProduceSummary).HasComment("是生成小结").IsRequired().HasDefaultValueSql("'Y'"); entity.Property(t => t.IsNameIntoSummary).HasComment("名称进入小结").IsRequired().HasDefaultValueSql("'N'"); entity.Property(t => t.IsDiagnosisFunction).HasComment("启用诊断函数").IsRequired().HasDefaultValueSql("'N'"); entity.Property(t => t.DiagnosisFunction).HasComment("诊断函数"); entity.Property(t => t.IsCalculationItem).HasComment("是计算项目").IsRequired().HasDefaultValueSql("'N'"); entity.Property(t => t.CalculationFunction).HasComment("计算函数"); entity.Property(t => t.IsContinueProcess).HasComment("是继续处理").IsRequired().HasDefaultValueSql("'Y'"); entity.Property(t => t.ResultTemplateTypeFlag).HasComment("结果模板类别标志").HasDefaultValueSql("0"); entity.Property(t => t.InputCheck).HasComment("输入结果校验公式"); entity.Property(t => t.IsActive).HasComment("启用").IsRequired().HasDefaultValueSql("'Y'"); entity.Property(t => t.LineModeFlag).HasComment("项目结果行模式").HasDefaultValue('2').IsRequired(); entity.Property(t => t.IsCriticalValueFunction).HasComment("是否启用危急值函数").IsRequired().HasDefaultValueSql("'N'"); entity.Property(t => t.CriticalValueFunction).HasComment("危急值函数"); entity.Property(t => t.IsFollowUpFunction).HasComment("是否启用随访函数").IsRequired().HasDefaultValueSql("'N'"); entity.Property(t => t.FollowUpFunction).HasComment("随访函数"); entity.Property(e => e.Id).IsFixedLength(); //entity.Property(e => e.CreationTime).HasDefaultValueSql("(date(timezone('UTC-8'::text, now())) - 1)"); //entity.Property(e => e.LastModificationTime).HasDefaultValueSql("(date(timezone('UTC-8'::text, now())) - 1)"); //entity.Property(e => e.PriceItemId).IsFixedLength(); //entity.Property(e => e.UnitId).IsFixedLength(); entity.HasOne(d => d.ItemType) .WithMany(p => p.Items) .HasForeignKey(d => d.ItemTypeId) .HasConstraintName("fk_item_item_type"); entity.ConfigureByConvention(); } } }