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.DictType;
import com.jeeplus.sys.service.dto.DictTypeDTO;
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 DictTypeWrapperImpl implements DictTypeWrapper {

    @Override
    public DictType toEntity(DictTypeDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DictType dictType = new DictType ( );

        dictType.setTenantId ( arg0TenantDTOId ( arg0 ) );
        dictType.setCreateById ( arg0CreateById ( arg0 ) );
        dictType.setUpdateById ( arg0UpdateById ( arg0 ) );
        dictType.setId ( arg0.getId ( ) );
        dictType.setCreateTime ( arg0.getCreateTime ( ) );
        dictType.setUpdateTime ( arg0.getUpdateTime ( ) );
        dictType.setDelFlag ( arg0.getDelFlag ( ) );
        dictType.setType ( arg0.getType ( ) );
        dictType.setRemarks ( arg0.getRemarks ( ) );

        return dictType;
    }

    @Override
    public DictTypeDTO toDTO(DictType arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DictTypeDTO dictTypeDTO = new DictTypeDTO ( );

        dictTypeDTO.setTenantDTO ( dictTypeToTenantDTO ( arg0 ) );
        dictTypeDTO.setCreateBy ( dictTypeToUserDTO ( arg0 ) );
        dictTypeDTO.setUpdateBy ( dictTypeToUserDTO1 ( arg0 ) );
        dictTypeDTO.setId ( arg0.getId ( ) );
        dictTypeDTO.setCreateTime ( arg0.getCreateTime ( ) );
        dictTypeDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        dictTypeDTO.setDelFlag ( arg0.getDelFlag ( ) );
        dictTypeDTO.setType ( arg0.getType ( ) );
        dictTypeDTO.setRemarks ( arg0.getRemarks ( ) );

        return dictTypeDTO;
    }

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

        List <DictType> list = new ArrayList <DictType> ( arg0.size ( ) );
        for (DictTypeDTO dictTypeDTO : arg0) {
            list.add ( toEntity ( dictTypeDTO ) );
        }

        return list;
    }

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

        List <DictTypeDTO> list = new ArrayList <DictTypeDTO> ( arg0.size ( ) );
        for (DictType dictType : arg0) {
            list.add ( toDTO ( dictType ) );
        }

        return list;
    }

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

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

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

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

        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(DictTypeDTO dictTypeDTO) {
        if ( dictTypeDTO == null ) {
            return null;
        }
        TenantDTO tenantDTO = dictTypeDTO.getTenantDTO ( );
        if ( tenantDTO == null ) {
            return null;
        }
        String id = tenantDTO.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

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

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

    protected TenantDTO dictTypeToTenantDTO(DictType dictType) {
        if ( dictType == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( dictType.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO dictTypeToUserDTO(DictType dictType) {
        if ( dictType == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dictType.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO dictTypeToUserDTO1(DictType dictType) {
        if ( dictType == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dictType.getUpdateById ( ) );

        return userDTO;
    }
}
