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.Language;
import com.jeeplus.sys.service.dto.LanguageDTO;
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 LanguageWrapperImpl implements LanguageWrapper {

    @Override
    public Language toEntity(LanguageDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Language language = new Language ( );

        language.setTenantId ( arg0TenantDTOId ( arg0 ) );
        language.setCreateById ( arg0CreateById ( arg0 ) );
        language.setUpdateById ( arg0UpdateById ( arg0 ) );
        language.setId ( arg0.getId ( ) );
        language.setCreateTime ( arg0.getCreateTime ( ) );
        language.setUpdateTime ( arg0.getUpdateTime ( ) );
        language.setDelFlag ( arg0.getDelFlag ( ) );
        language.setCode ( arg0.getCode ( ) );
        language.setZh ( arg0.getZh ( ) );
        language.setEn ( arg0.getEn ( ) );
        language.setJa ( arg0.getJa ( ) );

        return language;
    }

    @Override
    public LanguageDTO toDTO(Language arg0) {
        if ( arg0 == null ) {
            return null;
        }

        LanguageDTO languageDTO = new LanguageDTO ( );

        languageDTO.setTenantDTO ( languageToTenantDTO ( arg0 ) );
        languageDTO.setCreateBy ( languageToUserDTO ( arg0 ) );
        languageDTO.setUpdateBy ( languageToUserDTO1 ( arg0 ) );
        languageDTO.setId ( arg0.getId ( ) );
        languageDTO.setCreateTime ( arg0.getCreateTime ( ) );
        languageDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        languageDTO.setDelFlag ( arg0.getDelFlag ( ) );
        languageDTO.setCode ( arg0.getCode ( ) );
        languageDTO.setZh ( arg0.getZh ( ) );
        languageDTO.setEn ( arg0.getEn ( ) );
        languageDTO.setJa ( arg0.getJa ( ) );

        return languageDTO;
    }

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

        List <Language> list = new ArrayList <Language> ( arg0.size ( ) );
        for (LanguageDTO languageDTO : arg0) {
            list.add ( toEntity ( languageDTO ) );
        }

        return list;
    }

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

        List <LanguageDTO> list = new ArrayList <LanguageDTO> ( arg0.size ( ) );
        for (Language language : arg0) {
            list.add ( toDTO ( language ) );
        }

        return list;
    }

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

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

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

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

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

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

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

    protected TenantDTO languageToTenantDTO(Language language) {
        if ( language == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( language.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO languageToUserDTO(Language language) {
        if ( language == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( language.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO languageToUserDTO1(Language language) {
        if ( language == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( language.getUpdateById ( ) );

        return userDTO;
    }
}
