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 PFPageTreeMap : APTEntityBaseMap<T_PF_PAGE_TREE>
    {
		public override void Configure(EntityTypeBuilder<T_PF_PAGE_TREE> builder)
		{
			base.Configure(builder);
			builder.Property(t => t.LABEL_NAME).HasMaxLength(200);
			builder.Property(t => t.QUERY_API_URL).HasMaxLength(200);
			builder.Property(t => t.BATCH_DEL_API_URL).HasMaxLength(200);
			//builder.Property(t => t.PICTURE_CODE).HasMaxLength(600);
			builder.Property(t => t.SELECT_CONDITION).HasMaxLength(600);
			builder.Property(t => t.SORT).HasMaxLength(50);
			builder.Property(t => t.TREE_SELECTED_PARAM).HasMaxLength(50);
			builder.HasMany(t => t.Nav_Columns).
				WithOne(t => t.Nav_PageTree).HasForeignKey(i => i.PAGE_TREE_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.RELATION_FIELD).HasMaxLength(200);
			builder.Property(t => t.TREE_SELECTED_PARAM).HasMaxLength(200);
			builder.Property(t => t.CUSTOM_PARAMS).HasMaxLength(600); 
		}  
    }
}
