package com.jeeplus.sys.service.mapstruct;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.sys.domain.Cert;
import com.jeeplus.sys.service.dto.CertDTO;
import com.jeeplus.sys.service.dto.UserDTO;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Generated;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2023-01-11T12:38:05+0800",
    comments = "version: 1.4.1.Final, compiler: javac, environment: Java 1.8.0_181 (Oracle Corporation)"
)
@Component
public class CertWrapperImpl implements CertWrapper {

    @Override
    public Cert toEntity(CertDTO dto) {
        if ( dto == null ) {
            return null;
        }

        Cert cert = new Cert();

        cert.setCreateBy( dtoCreateById( dto ) );
        cert.setUpdateBy( dtoUpdateById( dto ) );
        cert.setId( dto.getId() );
        cert.setCreateDate( dto.getCreateDate() );
        cert.setUpdateDate( dto.getUpdateDate() );
        cert.setDelFlag( dto.getDelFlag() );
        cert.setRemarks( dto.getRemarks() );
        cert.setUserId( dto.getUserId() );
        cert.setType( dto.getType() );
        cert.setNo( dto.getNo() );
        cert.setAuthorities( dto.getAuthorities() );
        cert.setIssuedDate( dto.getIssuedDate() );
        cert.setEnrollDate( dto.getEnrollDate() );
        cert.setExpireDate( dto.getExpireDate() );
        cert.setEnrollCertNo( dto.getEnrollCertNo() );
        cert.setProfession( dto.getProfession() );
        cert.setFileUrl( dto.getFileUrl() );

        return cert;
    }

    @Override
    public CertDTO toDTO(Cert entity) {
        if ( entity == null ) {
            return null;
        }

        CertDTO certDTO = new CertDTO();

        certDTO.setCreateBy( certToUserDTO( entity ) );
        certDTO.setUpdateBy( certToUserDTO1( entity ) );
        certDTO.setId( entity.getId() );
        certDTO.setCreateDate( entity.getCreateDate() );
        certDTO.setUpdateDate( entity.getUpdateDate() );
        certDTO.setDelFlag( entity.getDelFlag() );
        certDTO.setRemarks( entity.getRemarks() );
        certDTO.setUserId( entity.getUserId() );
        certDTO.setType( entity.getType() );
        certDTO.setNo( entity.getNo() );
        certDTO.setAuthorities( entity.getAuthorities() );
        certDTO.setIssuedDate( entity.getIssuedDate() );
        certDTO.setEnrollDate( entity.getEnrollDate() );
        certDTO.setExpireDate( entity.getExpireDate() );
        certDTO.setEnrollCertNo( entity.getEnrollCertNo() );
        certDTO.setProfession( entity.getProfession() );
        certDTO.setFileUrl( entity.getFileUrl() );

        return certDTO;
    }

    @Override
    public List<Cert> toEntity(List<CertDTO> dtoList) {
        if ( dtoList == null ) {
            return null;
        }

        List<Cert> list = new ArrayList<Cert>( dtoList.size() );
        for ( CertDTO certDTO : dtoList ) {
            list.add( toEntity( certDTO ) );
        }

        return list;
    }

    @Override
    public List<CertDTO> toDTO(List<Cert> entityList) {
        if ( entityList == null ) {
            return null;
        }

        List<CertDTO> list = new ArrayList<CertDTO>( entityList.size() );
        for ( Cert cert : entityList ) {
            list.add( toDTO( cert ) );
        }

        return list;
    }

    @Override
    public Page<Cert> toEntity(Page<CertDTO> page) {
        if ( page == null ) {
            return null;
        }

        Page<Cert> page1 = new Page<Cert>();

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

        return page1;
    }

    @Override
    public Page<CertDTO> toDTO(Page<Cert> page) {
        if ( page == null ) {
            return null;
        }

        Page<CertDTO> page1 = new Page<CertDTO>();

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

        return page1;
    }

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

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

    protected UserDTO certToUserDTO(Cert cert) {
        if ( cert == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO();

        userDTO.setId( cert.getCreateBy() );

        return userDTO;
    }

    protected UserDTO certToUserDTO1(Cert cert) {
        if ( cert == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO();

        userDTO.setId( cert.getUpdateBy() );

        return userDTO;
    }
}
