using Hotline.KnowledgeBase;
using Hotline.Share.Dtos.Knowledge;
using Mapster;

namespace Hotline.Application.Mappers;

public class KnowledgeMapperConfigs : IRegister
{
    public void Register(TypeAdapterConfig config)
    {
        #region Knowledge
        config.NewConfig<KnowledgeApply, KnowledgeApplyHandlePageDto>()
            .Map(d => d.CreationName, x => x.User.Name)
            .Map(d => d.CreationOrgName, x => x.SystemOrganize.Name);

        config.NewConfig<Hotline.KnowledgeBase.Knowledge, KnowledgeDataDto>()
            .Map(d => d.CreatorName, x => x.User.Name)
            .Map(d => d.HotspotName, x => x.HotspotType.HotSpotFullName)
            ;

        config.NewConfig<Hotline.KnowledgeBase.Knowledge, KnowledgeApprovalDataDto>()
            .Map(d => d.CreatorName, x => x.User.Name)
            .Map(d => d.CreateBMName, x => x.SystemOrganize.Name);

        config.NewConfig<KnowledgeWorkFlow, KnowledgeApprovalDataDto>()
            .Map(d => d.CreatorName, x => x.User.Name)
            .Map(d => d.CreateBMName, x => x.SystemOrganize.Name)
            .Map(d => d.Id, x => x.Knowledge.Id)
            .Map(d => d.Title, x => x.Knowledge.Title)
            .Map(d => d.PageView, x => x.Knowledge.PageView)
            .Map(d => d.Status, x => x.Knowledge.Status)
            .Map(d => d.WorkflowModuleStatus, x => x.WorkflowModuleStatus)
            .Map(d => d.CurrentStepTime, x => x.Workflow.ActualHandleTime);

        config.NewConfig<KnowledgeWorkFlow, KnowledgeDeleteApplyDataDto>()
            .Map(d => d.Id, x => x.Knowledge.Id)
            .Map(d => d.Title, x => x.Knowledge.Title)
            .Map(d => d.HotspotName, x => x.Knowledge.HotspotType.HotSpotFullName)
            .Map(d => d.CreatorName, x => x.User.Name)
            .Map(d => d.CreationBMName, x => x.SystemOrganize.Name)
            .Map(d => d.PageView, x => x.Knowledge.PageView)
            .Map(d => d.Status, x => x.Knowledge.Status)
            .Map(d => d.WorkFlowApplyStatus, x => x.WorkFlowApplyStatus);

        config.NewConfig<Hotline.KnowledgeBase.Knowledge, KnowledgeSendDto>()
            .Map(d => d.CategoryCode, x => x.HotspotType.ProvinceCode)
            .Map(d => d.CategoryName, x => x.HotspotType.HotSpotName)
            .Map(d => d.PublishPerson, x => x.User.Name)
            .Map(d => d.OuName, x => x.SystemOrganize.Name)
            .Map(d => d.KName, x => x.Title)
            .Map(d => d.KContent, x => x.Content)
            .Map(d => d.CreatDate, x => x.OnShelfTime)
            .Map(d => d.BeginDate, x => x.OnShelfTime)
            .Map(d => d.DisableDate, x => x.ExpiredTime)
            .Map(d => d.UID, x => x.Code)
            ;
        #endregion
    }
}