package cn.ey.biz.module.system.convert.engagement.business;

import cn.ey.biz.common.pojo.PageResult;
import cn.ey.biz.module.system.controller.engagement.business.vo.EngagementBusinessCreateReqVO;
import cn.ey.biz.module.system.controller.engagement.business.vo.EngagementBusinessCreateRespVO;
import cn.ey.biz.module.system.controller.engagement.business.vo.EngagementBusinessLogRespVO;
import cn.ey.biz.module.system.dal.dataobject.engagement.business.SystemEngagementBusinessFieldDO;
import cn.ey.biz.module.system.dal.dataobject.engagement.business.SystemEngagementBusinessFieldLogDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;


@Mapper
public interface EngagementBusinessFieldConvert {

    EngagementBusinessFieldConvert INSTANCE = Mappers.getMapper(EngagementBusinessFieldConvert.class);


    @Mappings({
            @Mapping(expression = "java(BusinessFieldConverter.listToJson(reqVO.getConsultingCore()))", target = "consultingCore"),
            @Mapping(expression = "java(BusinessFieldConverter.listToJson(reqVO.getConsultingFso()))", target = "consultingFso"),
            @Mapping(expression = "java(BusinessFieldConverter.listToJson(reqVO.getAssuranceCore()))", target = "assuranceCore"),
            @Mapping(expression = "java(BusinessFieldConverter.listToJson(reqVO.getAssuranceFso()))", target = "assuranceFso"),
            @Mapping(expression = "java(BusinessFieldConverter.listToJson(reqVO.getTaxCore()))", target = "taxCore"),
            @Mapping(expression = "java(BusinessFieldConverter.listToJson(reqVO.getTaxFso()))", target = "taxFso"),
            @Mapping(expression = "java(BusinessFieldConverter.listToJson(reqVO.getSatCore()))", target = "satCore"),
            @Mapping(expression = "java(BusinessFieldConverter.listToJson(reqVO.getSatFso()))", target = "satFso"),
    })
    SystemEngagementBusinessFieldDO voConvertDo(EngagementBusinessCreateReqVO reqVO);


    @Mappings({
            @Mapping(expression = "java(BusinessFieldConverter.jsonToList(engagementBusinessFieldDO.getConsultingCore()))", target = "consultingCore"),
            @Mapping(expression = "java(BusinessFieldConverter.jsonToList(engagementBusinessFieldDO.getConsultingFso()))", target = "consultingFso"),
            @Mapping(expression = "java(BusinessFieldConverter.jsonToList(engagementBusinessFieldDO.getAssuranceCore()))", target = "assuranceCore"),
            @Mapping(expression = "java(BusinessFieldConverter.jsonToList(engagementBusinessFieldDO.getAssuranceFso()))", target = "assuranceFso"),
            @Mapping(expression = "java(BusinessFieldConverter.jsonToList(engagementBusinessFieldDO.getTaxCore()))", target = "taxCore"),
            @Mapping(expression = "java(BusinessFieldConverter.jsonToList(engagementBusinessFieldDO.getTaxFso()))", target = "taxFso"),
            @Mapping(expression = "java(BusinessFieldConverter.jsonToList(engagementBusinessFieldDO.getSatCore()))", target = "satCore"),
            @Mapping(expression = "java(BusinessFieldConverter.jsonToList(engagementBusinessFieldDO.getSatFso()))", target = "satFso"),
    })
    EngagementBusinessCreateRespVO doConvertVo(SystemEngagementBusinessFieldDO engagementBusinessFieldDO);


    List<EngagementBusinessCreateRespVO> doConvertVoList(List<SystemEngagementBusinessFieldDO> businessFieldDOS);

    PageResult<EngagementBusinessLogRespVO> pageDoConvertVo(PageResult<SystemEngagementBusinessFieldLogDO> pageResult);

    @Mappings({
            @Mapping(expression = "java(BusinessFieldConverter.stringToJson(systemEngagementBusinessFieldLogDO.getOriginalDataLogs()))", target = "originalData"),
            @Mapping(expression = "java(BusinessFieldConverter.stringToJson(systemEngagementBusinessFieldLogDO.getCurrentDataLogs()))", target = "currentData"),
    })
    EngagementBusinessLogRespVO  logDoConvertToVo(SystemEngagementBusinessFieldLogDO systemEngagementBusinessFieldLogDO);
}
