package com.jeeplus.datav.service.mapstruct;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.datav.domain.DataMap;
import com.jeeplus.datav.service.dto.DataMapDTO;
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 DataMapWrapperImpl implements DataMapWrapper {

    @Override
    public DataMap toEntity(DataMapDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DataMap dataMap = new DataMap ( );

        dataMap.setTenantId ( arg0TenantDTOId ( arg0 ) );
        dataMap.setCreateById ( arg0CreateById ( arg0 ) );
        dataMap.setUpdateById ( arg0UpdateById ( arg0 ) );
        dataMap.setId ( arg0.getId ( ) );
        dataMap.setCreateTime ( arg0.getCreateTime ( ) );
        dataMap.setUpdateTime ( arg0.getUpdateTime ( ) );
        dataMap.setDelFlag ( arg0.getDelFlag ( ) );
        dataMap.setName ( arg0.getName ( ) );
        dataMap.setData ( arg0.getData ( ) );
        dataMap.setRemarks ( arg0.getRemarks ( ) );

        return dataMap;
    }

    @Override
    public DataMapDTO toDTO(DataMap arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DataMapDTO dataMapDTO = new DataMapDTO ( );

        dataMapDTO.setTenantDTO ( dataMapToTenantDTO ( arg0 ) );
        dataMapDTO.setCreateBy ( dataMapToUserDTO ( arg0 ) );
        dataMapDTO.setUpdateBy ( dataMapToUserDTO1 ( arg0 ) );
        dataMapDTO.setId ( arg0.getId ( ) );
        dataMapDTO.setCreateTime ( arg0.getCreateTime ( ) );
        dataMapDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        dataMapDTO.setDelFlag ( arg0.getDelFlag ( ) );
        dataMapDTO.setName ( arg0.getName ( ) );
        dataMapDTO.setData ( arg0.getData ( ) );
        dataMapDTO.setRemarks ( arg0.getRemarks ( ) );

        return dataMapDTO;
    }

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

        List <DataMap> list = new ArrayList <DataMap> ( arg0.size ( ) );
        for (DataMapDTO dataMapDTO : arg0) {
            list.add ( toEntity ( dataMapDTO ) );
        }

        return list;
    }

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

        List <DataMapDTO> list = new ArrayList <DataMapDTO> ( arg0.size ( ) );
        for (DataMap dataMap : arg0) {
            list.add ( toDTO ( dataMap ) );
        }

        return list;
    }

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

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

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

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

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

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

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

    protected TenantDTO dataMapToTenantDTO(DataMap dataMap) {
        if ( dataMap == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( dataMap.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO dataMapToUserDTO(DataMap dataMap) {
        if ( dataMap == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dataMap.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO dataMapToUserDTO1(DataMap dataMap) {
        if ( dataMap == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dataMap.getUpdateById ( ) );

        return userDTO;
    }
}
