package com.jeeplus.mail.service.mapstruct;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.mail.domain.MailCompose;
import com.jeeplus.mail.service.dto.MailComposeDTO;
import com.jeeplus.mail.service.dto.MailDTO;
import com.jeeplus.sys.service.dto.UserDTO;
import org.springframework.stereotype.Component;

import javax.annotation.Generated;
import java.util.ArrayList;
import java.util.List;

@Generated(
        value = "org.mapstruct.ap.MappingProcessor",
        date = "2022-08-18T16:46:54+0800",
        comments = "version: 1.4.1.Final, compiler: javac, environment: Java 1.8.0_221 (Oracle Corporation)"
)
@Component
public class MailComposeWrapperImpl implements MailComposeWrapper {

    @Override
    public List <MailCompose> toEntity(List <MailComposeDTO> arg0) {
        if ( arg0 == null ) {
            return null;
        }

        List <MailCompose> list = new ArrayList <MailCompose> ( arg0.size ( ) );
        for (MailComposeDTO mailComposeDTO : arg0) {
            list.add ( toEntity ( mailComposeDTO ) );
        }

        return list;
    }

    @Override
    public List <MailComposeDTO> toDTO(List <MailCompose> arg0) {
        if ( arg0 == null ) {
            return null;
        }

        List <MailComposeDTO> list = new ArrayList <MailComposeDTO> ( arg0.size ( ) );
        for (MailCompose mailCompose : arg0) {
            list.add ( toDTO ( mailCompose ) );
        }

        return list;
    }

    @Override
    public Page <MailCompose> toEntity(Page <MailComposeDTO> arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Page <MailCompose> page = new Page <MailCompose> ( );

        page.setPages ( arg0.getPages ( ) );
        page.setRecords ( toEntity ( arg0.getRecords ( ) ) );
        page.setTotal ( arg0.getTotal ( ) );
        page.setSize ( arg0.getSize ( ) );
        page.setCurrent ( arg0.getCurrent ( ) );
        page.setSearchCount ( arg0.isSearchCount ( ) );
        page.setOptimizeCountSql ( arg0.isOptimizeCountSql ( ) );
        page.setHitCount ( arg0.isHitCount ( ) );
        List <OrderItem> list1 = arg0.getOrders ( );
        if ( list1 != null ) {
            page.setOrders ( new ArrayList <OrderItem> ( list1 ) );
        }
        page.setCountId ( arg0.getCountId ( ) );
        page.setMaxLimit ( arg0.getMaxLimit ( ) );

        return page;
    }

    @Override
    public Page <MailComposeDTO> toDTO(Page <MailCompose> arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Page <MailComposeDTO> page = new Page <MailComposeDTO> ( );

        page.setPages ( arg0.getPages ( ) );
        page.setRecords ( toDTO ( arg0.getRecords ( ) ) );
        page.setTotal ( arg0.getTotal ( ) );
        page.setSize ( arg0.getSize ( ) );
        page.setCurrent ( arg0.getCurrent ( ) );
        page.setSearchCount ( arg0.isSearchCount ( ) );
        page.setOptimizeCountSql ( arg0.isOptimizeCountSql ( ) );
        page.setHitCount ( arg0.isHitCount ( ) );
        List <OrderItem> list1 = arg0.getOrders ( );
        if ( list1 != null ) {
            page.setOrders ( new ArrayList <OrderItem> ( list1 ) );
        }
        page.setCountId ( arg0.getCountId ( ) );
        page.setMaxLimit ( arg0.getMaxLimit ( ) );

        return page;
    }

    @Override
    public MailCompose toEntity(MailComposeDTO dto) {
        if ( dto == null ) {
            return null;
        }

        MailCompose mailCompose = new MailCompose ( );

        mailCompose.setMailId ( dtoMailDTOId ( dto ) );
        mailCompose.setSenderId ( dtoSenderId ( dto ) );
        mailCompose.setCreateById ( dtoCreateById ( dto ) );
        mailCompose.setUpdateById ( dtoUpdateById ( dto ) );
        mailCompose.setId ( dto.getId ( ) );
        mailCompose.setCreateTime ( dto.getCreateTime ( ) );
        mailCompose.setUpdateTime ( dto.getUpdateTime ( ) );
        mailCompose.setDelFlag ( dto.getDelFlag ( ) );
        mailCompose.setStatus ( dto.getStatus ( ) );
        mailCompose.setReceiverIds ( dto.getReceiverIds ( ) );
        mailCompose.setSendTime ( dto.getSendTime ( ) );

        return mailCompose;
    }

    @Override
    public MailComposeDTO toDTO(MailCompose entity) {
        if ( entity == null ) {
            return null;
        }

        MailComposeDTO mailComposeDTO = new MailComposeDTO ( );

        mailComposeDTO.setMailDTO ( mailComposeToMailDTO ( entity ) );
        mailComposeDTO.setSender ( mailComposeToUserDTO ( entity ) );
        mailComposeDTO.setCreateBy ( mailComposeToUserDTO1 ( entity ) );
        mailComposeDTO.setUpdateBy ( mailComposeToUserDTO2 ( entity ) );
        mailComposeDTO.setId ( entity.getId ( ) );
        mailComposeDTO.setCreateTime ( entity.getCreateTime ( ) );
        mailComposeDTO.setUpdateTime ( entity.getUpdateTime ( ) );
        mailComposeDTO.setDelFlag ( entity.getDelFlag ( ) );
        mailComposeDTO.setStatus ( entity.getStatus ( ) );
        mailComposeDTO.setReceiverIds ( entity.getReceiverIds ( ) );
        mailComposeDTO.setSendTime ( entity.getSendTime ( ) );

        return mailComposeDTO;
    }

    private String dtoMailDTOId(MailComposeDTO mailComposeDTO) {
        if ( mailComposeDTO == null ) {
            return null;
        }
        MailDTO mailDTO = mailComposeDTO.getMailDTO ( );
        if ( mailDTO == null ) {
            return null;
        }
        String id = mailDTO.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private String dtoSenderId(MailComposeDTO mailComposeDTO) {
        if ( mailComposeDTO == null ) {
            return null;
        }
        UserDTO sender = mailComposeDTO.getSender ( );
        if ( sender == null ) {
            return null;
        }
        String id = sender.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private String dtoCreateById(MailComposeDTO mailComposeDTO) {
        if ( mailComposeDTO == null ) {
            return null;
        }
        UserDTO createBy = mailComposeDTO.getCreateBy ( );
        if ( createBy == null ) {
            return null;
        }
        String id = createBy.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private String dtoUpdateById(MailComposeDTO mailComposeDTO) {
        if ( mailComposeDTO == null ) {
            return null;
        }
        UserDTO updateBy = mailComposeDTO.getUpdateBy ( );
        if ( updateBy == null ) {
            return null;
        }
        String id = updateBy.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    protected MailDTO mailComposeToMailDTO(MailCompose mailCompose) {
        if ( mailCompose == null ) {
            return null;
        }

        MailDTO mailDTO = new MailDTO ( );

        mailDTO.setId ( mailCompose.getMailId ( ) );

        return mailDTO;
    }

    protected UserDTO mailComposeToUserDTO(MailCompose mailCompose) {
        if ( mailCompose == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( mailCompose.getSenderId ( ) );

        return userDTO;
    }

    protected UserDTO mailComposeToUserDTO1(MailCompose mailCompose) {
        if ( mailCompose == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( mailCompose.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO mailComposeToUserDTO2(MailCompose mailCompose) {
        if ( mailCompose == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( mailCompose.getUpdateById ( ) );

        return userDTO;
    }
}
