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.Tenant;
import com.jeeplus.sys.service.dto.TenantDTO;
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 TenantWrapperImpl implements TenantWrapper {

    @Override
    public Tenant toEntity(TenantDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Tenant tenant = new Tenant ( );

        tenant.setTenantId ( arg0TenantDTOId ( arg0 ) );
        tenant.setCreateById ( arg0CreateById ( arg0 ) );
        tenant.setUpdateById ( arg0UpdateById ( arg0 ) );
        tenant.setCreateTime ( arg0.getCreateTime ( ) );
        tenant.setUpdateTime ( arg0.getUpdateTime ( ) );
        tenant.setDelFlag ( arg0.getDelFlag ( ) );
        tenant.setId ( arg0.getId ( ) );
        tenant.setColor ( arg0.getColor ( ) );
        tenant.setName ( arg0.getName ( ) );
        tenant.setBeginDate ( arg0.getBeginDate ( ) );
        tenant.setEndDate ( arg0.getEndDate ( ) );
        tenant.setStatus ( arg0.getStatus ( ) );
        tenant.setDomain ( arg0.getDomain ( ) );

        return tenant;
    }

    @Override
    public TenantDTO toDTO(Tenant arg0) {
        if ( arg0 == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setTenantDTO ( tenantToTenantDTO ( arg0 ) );
        tenantDTO.setCreateBy ( tenantToUserDTO ( arg0 ) );
        tenantDTO.setUpdateBy ( tenantToUserDTO1 ( arg0 ) );
        tenantDTO.setId ( arg0.getId ( ) );
        tenantDTO.setCreateTime ( arg0.getCreateTime ( ) );
        tenantDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        tenantDTO.setDelFlag ( arg0.getDelFlag ( ) );
        tenantDTO.setName ( arg0.getName ( ) );
        tenantDTO.setColor ( arg0.getColor ( ) );
        tenantDTO.setBeginDate ( arg0.getBeginDate ( ) );
        tenantDTO.setEndDate ( arg0.getEndDate ( ) );
        tenantDTO.setStatus ( arg0.getStatus ( ) );
        tenantDTO.setDomain ( arg0.getDomain ( ) );

        return tenantDTO;
    }

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

        List <Tenant> list = new ArrayList <Tenant> ( arg0.size ( ) );
        for (TenantDTO tenantDTO : arg0) {
            list.add ( toEntity ( tenantDTO ) );
        }

        return list;
    }

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

        List <TenantDTO> list = new ArrayList <TenantDTO> ( arg0.size ( ) );
        for (Tenant tenant : arg0) {
            list.add ( toDTO ( tenant ) );
        }

        return list;
    }

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

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

        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 <TenantDTO> toDTO(Page <Tenant> arg0) {
        if ( arg0 == null ) {
            return null;
        }

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

        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;
    }

    private String arg0TenantDTOId(TenantDTO tenantDTO) {
        if ( tenantDTO == null ) {
            return null;
        }
        TenantDTO tenantDTO1 = tenantDTO.getTenantDTO ( );
        if ( tenantDTO1 == null ) {
            return null;
        }
        String id = tenantDTO1.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private String arg0CreateById(TenantDTO tenantDTO) {
        if ( tenantDTO == null ) {
            return null;
        }
        UserDTO createBy = tenantDTO.getCreateBy ( );
        if ( createBy == null ) {
            return null;
        }
        String id = createBy.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private String arg0UpdateById(TenantDTO tenantDTO) {
        if ( tenantDTO == null ) {
            return null;
        }
        UserDTO updateBy = tenantDTO.getUpdateBy ( );
        if ( updateBy == null ) {
            return null;
        }
        String id = updateBy.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    protected TenantDTO tenantToTenantDTO(Tenant tenant) {
        if ( tenant == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( tenant.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO tenantToUserDTO(Tenant tenant) {
        if ( tenant == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( tenant.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO tenantToUserDTO1(Tenant tenant) {
        if ( tenant == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( tenant.getUpdateById ( ) );

        return userDTO;
    }
}
