using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure.Extention;
using System.ComponentModel.DataAnnotations;

namespace IRaCIS.Application.Contracts
{


    public class BasicDicView : AddOrEditBasicDic
    {

        public DateTime CreateTime { get; set; }
        public Guid CreateUserId { get; set; }
        public DateTime UpdateTime { get; set; }
        public Guid UpdateUserId { get; set; }

        public string ConfigType { get; set; } = String.Empty;

    }

    public class GetTrialConfigDictionaryListOutDto
    {

        public Guid Id { get; set; }

        public Guid DictionaryId { get; set; }

        public int ShowOrder { get; set; }

        public string Description { get; set; } = string.Empty;

        public string Code { get; set; }

        public string ParentCode { get; set; }

        public string ChildGroup { get; set; }

        public string Value { get; set; } = string.Empty;

        public string ValueCN { get; set; } = string.Empty;
    }


    public class AddOrEditBasicDic
    {
        public Guid? Id { get; set; }

        public string Code { get; set; } = String.Empty;


        public string Description { get; set; } = String.Empty;


        public string Value { get; set; } = String.Empty;

        public string ValueCN { get; set; } = String.Empty;


        public string ChildGroup { get; set; } = String.Empty;

        public int ChildCodeEnum { get; set; }


        public int ShowOrder { get; set; }


        //有父亲 就有值  
        public Guid? ParentId { get; set; }

        public bool IsEnable { get; set; }



        public DicDataTypeEnum DataTypeEnum { get; set; }

        //是配置的话,就有值
        public Guid? ConfigTypeId { get; set; }

    }

    public class GetCriterionDictionaryInDto
    {
        public Guid? ReadingCriterionId { get; set; }

        public string DictionaryCode { get; set; } = string.Empty;


        public List<string> DictionaryCodeList { get; set; } = new List<string>();
    }

    public class GetBasicDataAllSelectInDto
    {
        public Guid? TrialReadingCriterionId { get; set; }
    }


    public class GetTrialCriterionDictionaryListInDto
    {
        [NotDefault]
        public Guid TrialCriterionId { get; set; }
    }
    public class GetCriterionDictionaryListInDto
    {
        [NotDefault]
        public Guid SystemCriterionId { get; set; }
    }
    public class GetCriterionDictionaryListOutDto
    {
        public Guid Id { get; set; }
        public string Code { get; set; } = string.Empty;

        public int Count { get; set; }
        public int ShowOrder { get; set; }

        public string Description { get; set; } = string.Empty;
    }


    public class BasicDicSelectCopy:BasicDicSelect
    {

    }
    public class BasicDicSelect
    {
        public Guid Id { get; set; }
        public string Code { get; set; } = string.Empty;

        public string ValueCN { get; set; } = string.Empty;
        public string Value { get; set; } = string.Empty;

        public string Description { get; set; } = string.Empty;

        public int ShowOrder { get; set; }

        public Guid? ParentId { get; set; }
        public string ParentCode { get; set; } = string.Empty;
        public int? ParentChildCodeEnum { get; set; }


        public string ChildGroup { get; set; } = string.Empty;

        public DicDataTypeEnum DataTypeEnum { get; set; }

        public CrterionDictionaryGroup CrterionDictionaryGroup { get; set; } = IRaCIS.Core.Domain.Share.CrterionDictionaryGroup.General;

       public bool IsEnumInt => System.Text.RegularExpressions.Regex.IsMatch(Code, @"^[-+]?\d*$") && DataTypeEnum== DicDataTypeEnum.Enum;


    }

    public class BasicDicQuery:PageInput
    {
        public string? keyInfo { get; set; }

        public string? Code { get; set; }


        public DicDataTypeEnum? DataTypeEnum { get; set; }

        public Guid? ConfigTypeId { get; set; }

    }





    public class AddBasicDicAndChild
    {
        [NotDefault]
        public Guid ConfigTypeId { get; set; }

        public bool IsEnable { get; set; }

        public string Code { get; set; } = String.Empty;

        public int ShowOrder { get; set; }
        public string Description { get; set; } = String.Empty;

        public DicDataTypeEnum DataTypeEnum { get; set; }


        public List<AddBasicDicChild> ChildList { get; set; } = new List<AddBasicDicChild>();
    }


    public class AddBasicDicChild
    {
        public string Code { get; set; } = String.Empty;
        public string Value { get; set; } = String.Empty;

        public string ValueCN { get; set; } = String.Empty;

        public string ChildGroup { get; set; } = String.Empty;

        public int ShowOrder { get; set; }

        public string Description { get; set; } = String.Empty;

        public bool IsEnable { get; set; } = true;
    }


















    public class DicViewModelDTO : AddOrUpdateDicDTO
    {
       
    }


    public class AddOrUpdateDicDTO
    {
        public Guid? Id { get; set; }
        public string KeyName { get; set; } = String.Empty;
        public string Value { get; set; } = String.Empty;
        public string Description { get; set; } = String.Empty;
        public string ValueCN { get; set; } = String.Empty;
        public int ShowOrder { get; set; }
        public string Type { get; set; } = String.Empty;
    }

    public class DicQueryDTO : PageInput
    {
        public string KeyName { get; set; } = String.Empty;
    }

    public class KeyNameType
    {
        public Guid KeyId { get; set; }
        public string KeyName { get; set; } = String.Empty;
        public string Type { get; set; } = String.Empty;
    }

    public class DicResultDTO
    {
        public Dictionary<string, Dictionary<Guid, string>> DicList = new Dictionary<string, Dictionary<Guid, string>>();
    }


    public class TrialDictionaryView
    {
        public Guid? Id { get; set; }
        public string KeyName { get; set; } = String.Empty;
        public string Value { get; set; } = String.Empty;
        public int ShowOrder { get; set; }
    }

    public class TrialDicSelect
    {
        public TrialDictionaryView[] Phase { get; set; } = new TrialDictionaryView[0];
        public TrialDictionaryView[] IndicationType { get; set; } = new TrialDictionaryView[0];
        public TrialDictionaryView[] DeclarationType { get; set; } = new TrialDictionaryView[0];
    }
}