package com.cdm.module.promotion.convert.diy;

import com.cdm.framework.common.pojo.PageResult;
import com.cdm.module.promotion.controller.admin.diy.vo.page.DiyPagePropertyRespVO;
import com.cdm.module.promotion.controller.admin.diy.vo.template.DiyTemplateCreateReqVO;
import com.cdm.module.promotion.controller.admin.diy.vo.template.DiyTemplatePropertyRespVO;
import com.cdm.module.promotion.controller.admin.diy.vo.template.DiyTemplatePropertyUpdateRequestVO;
import com.cdm.module.promotion.controller.admin.diy.vo.template.DiyTemplateRespVO;
import com.cdm.module.promotion.controller.admin.diy.vo.template.DiyTemplateUpdateReqVO;
import com.cdm.module.promotion.controller.app.diy.vo.AppDiyTemplatePropertyRespVO;
import com.cdm.module.promotion.dal.dataobject.diy.DiyPageDO;
import com.cdm.module.promotion.dal.dataobject.diy.DiyTemplateDO;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.processing.Generated;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2023-12-21T17:57:32+0800",
    comments = "version: 1.5.5.Final, compiler: javac, environment: Java 17.0.3 (JetBrains s.r.o.)"
)
public class DiyTemplateConvertImpl implements DiyTemplateConvert {

    @Override
    public DiyTemplateDO convert(DiyTemplateCreateReqVO bean) {
        if ( bean == null ) {
            return null;
        }

        DiyTemplateDO.DiyTemplateDOBuilder diyTemplateDO = DiyTemplateDO.builder();

        diyTemplateDO.name( bean.getName() );
        diyTemplateDO.remark( bean.getRemark() );
        List<String> list = bean.getPreviewImageUrls();
        if ( list != null ) {
            diyTemplateDO.previewImageUrls( new ArrayList<String>( list ) );
        }

        return diyTemplateDO.build();
    }

    @Override
    public DiyTemplateDO convert(DiyTemplateUpdateReqVO bean) {
        if ( bean == null ) {
            return null;
        }

        DiyTemplateDO.DiyTemplateDOBuilder diyTemplateDO = DiyTemplateDO.builder();

        diyTemplateDO.id( bean.getId() );
        diyTemplateDO.name( bean.getName() );
        diyTemplateDO.remark( bean.getRemark() );
        List<String> list = bean.getPreviewImageUrls();
        if ( list != null ) {
            diyTemplateDO.previewImageUrls( new ArrayList<String>( list ) );
        }

        return diyTemplateDO.build();
    }

    @Override
    public DiyTemplateRespVO convert(DiyTemplateDO bean) {
        if ( bean == null ) {
            return null;
        }

        DiyTemplateRespVO diyTemplateRespVO = new DiyTemplateRespVO();

        diyTemplateRespVO.setName( bean.getName() );
        diyTemplateRespVO.setRemark( bean.getRemark() );
        List<String> list = bean.getPreviewImageUrls();
        if ( list != null ) {
            diyTemplateRespVO.setPreviewImageUrls( new ArrayList<String>( list ) );
        }
        diyTemplateRespVO.setId( bean.getId() );
        diyTemplateRespVO.setCreateTime( bean.getCreateTime() );
        diyTemplateRespVO.setUsed( bean.getUsed() );
        diyTemplateRespVO.setUsedTime( bean.getUsedTime() );

        return diyTemplateRespVO;
    }

    @Override
    public List<DiyTemplateRespVO> convertList(List<DiyTemplateDO> list) {
        if ( list == null ) {
            return null;
        }

        List<DiyTemplateRespVO> list1 = new ArrayList<DiyTemplateRespVO>( list.size() );
        for ( DiyTemplateDO diyTemplateDO : list ) {
            list1.add( convert( diyTemplateDO ) );
        }

        return list1;
    }

    @Override
    public PageResult<DiyTemplateRespVO> convertPage(PageResult<DiyTemplateDO> page) {
        if ( page == null ) {
            return null;
        }

        PageResult<DiyTemplateRespVO> pageResult = new PageResult<DiyTemplateRespVO>();

        pageResult.setList( convertList( page.getList() ) );
        pageResult.setTotal( page.getTotal() );

        return pageResult;
    }

    @Override
    public DiyTemplatePropertyRespVO convertPropertyVo(DiyTemplateDO diyTemplate, List<DiyPageDO> pages) {
        if ( diyTemplate == null && pages == null ) {
            return null;
        }

        DiyTemplatePropertyRespVO diyTemplatePropertyRespVO = new DiyTemplatePropertyRespVO();

        if ( diyTemplate != null ) {
            diyTemplatePropertyRespVO.setName( diyTemplate.getName() );
            diyTemplatePropertyRespVO.setRemark( diyTemplate.getRemark() );
            List<String> list = diyTemplate.getPreviewImageUrls();
            if ( list != null ) {
                diyTemplatePropertyRespVO.setPreviewImageUrls( new ArrayList<String>( list ) );
            }
            diyTemplatePropertyRespVO.setId( diyTemplate.getId() );
            diyTemplatePropertyRespVO.setProperty( diyTemplate.getProperty() );
        }
        diyTemplatePropertyRespVO.setPages( diyPageDOListToDiyPagePropertyRespVOList( pages ) );

        return diyTemplatePropertyRespVO;
    }

    @Override
    public AppDiyTemplatePropertyRespVO convertPropertyVo2(DiyTemplateDO diyTemplate, String home, String user) {
        if ( diyTemplate == null && home == null && user == null ) {
            return null;
        }

        AppDiyTemplatePropertyRespVO appDiyTemplatePropertyRespVO = new AppDiyTemplatePropertyRespVO();

        if ( diyTemplate != null ) {
            appDiyTemplatePropertyRespVO.setId( diyTemplate.getId() );
            appDiyTemplatePropertyRespVO.setName( diyTemplate.getName() );
            appDiyTemplatePropertyRespVO.setProperty( diyTemplate.getProperty() );
        }
        appDiyTemplatePropertyRespVO.setHome( home );
        appDiyTemplatePropertyRespVO.setUser( user );

        return appDiyTemplatePropertyRespVO;
    }

    @Override
    public DiyTemplateDO convert(DiyTemplatePropertyUpdateRequestVO updateReqVO) {
        if ( updateReqVO == null ) {
            return null;
        }

        DiyTemplateDO.DiyTemplateDOBuilder diyTemplateDO = DiyTemplateDO.builder();

        diyTemplateDO.id( updateReqVO.getId() );
        diyTemplateDO.property( updateReqVO.getProperty() );

        return diyTemplateDO.build();
    }

    protected DiyPagePropertyRespVO diyPageDOToDiyPagePropertyRespVO(DiyPageDO diyPageDO) {
        if ( diyPageDO == null ) {
            return null;
        }

        DiyPagePropertyRespVO diyPagePropertyRespVO = new DiyPagePropertyRespVO();

        diyPagePropertyRespVO.setTemplateId( diyPageDO.getTemplateId() );
        diyPagePropertyRespVO.setName( diyPageDO.getName() );
        diyPagePropertyRespVO.setRemark( diyPageDO.getRemark() );
        List<String> list = diyPageDO.getPreviewImageUrls();
        if ( list != null ) {
            diyPagePropertyRespVO.setPreviewImageUrls( new ArrayList<String>( list ) );
        }
        diyPagePropertyRespVO.setId( diyPageDO.getId() );
        diyPagePropertyRespVO.setProperty( diyPageDO.getProperty() );

        return diyPagePropertyRespVO;
    }

    protected List<DiyPagePropertyRespVO> diyPageDOListToDiyPagePropertyRespVOList(List<DiyPageDO> list) {
        if ( list == null ) {
            return null;
        }

        List<DiyPagePropertyRespVO> list1 = new ArrayList<DiyPagePropertyRespVO>( list.size() );
        for ( DiyPageDO diyPageDO : list ) {
            list1.add( diyPageDOToDiyPagePropertyRespVO( diyPageDO ) );
        }

        return list1;
    }
}
