using APT.BaseData.Domain.Entities;
using APT.Infrastructure.EF.Map;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace APT.BaseData.Data.Mapping
{
	public class PFPageEditMap : TreeEntityBaseMap<T_PF_PAGE_EDIT>
    {
		public override void Configure(EntityTypeBuilder<T_PF_PAGE_EDIT> builder)
		{
			base.Configure(builder);
			builder.Property(t => t.EDIT_NAME).HasMaxLength(200);
			builder.Property(t => t.LABEL_NAME).HasMaxLength(200);
			builder.Property(t => t.API_URL).HasMaxLength(200);
			builder.Property(t => t.QUERY_API_URL).HasMaxLength(200);
			builder.Property(t => t.BATCH_QUERY_API).HasMaxLength(200);
			builder.Property(t => t.BATCH_UPDATE_API).HasMaxLength(200);
			
			builder.HasMany(t => t.Nav_Columns).
				WithOne(t => t.Nav_PageEdit).HasForeignKey(i => i.PAGE_EDIT_ID).OnDelete(DeleteBehavior.Restrict);
			builder.HasOne(t => t.Nav_PageForm).
				WithMany().HasForeignKey(t => t.PAGE_FORM_ID).OnDelete(DeleteBehavior.Restrict);
			builder.Property(t => t.CODE).HasMaxLength(100);
			builder.Property(t => t.SORT_FIELDS).HasMaxLength(100);
			builder.Property(t => t.NAV_ROW_CLASS_FILTER).HasMaxLength(100);
			builder.Property(t => t.SORT_ORDERS).HasMaxLength(100);
			builder.Property(t => t.PARENT_COPY_FIELD).HasMaxLength(300);
			builder.Property(t => t.CHILD_SET_FIELD).HasMaxLength(300);
			builder.Property(t => t.CUSTOM_PARAMS).HasMaxLength(600);
			builder.Property(t => t.SUB_TABLE_CONDITION).HasMaxLength(600);
			builder.Property(t => t.CODE_FIELD_NAME).HasMaxLength(200); 
			builder.HasOne(t => t.Nav_ParamScheme).
					WithMany(t=>t.Nav_PageEdits).HasForeignKey(t => t.PARAM_SCHEME_ID).OnDelete(DeleteBehavior.Restrict);
		}
		 
    }
}
