package com.jeeplus.database.datamodel.service.mapstruct;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.database.datamodel.domain.DataParam;
import com.jeeplus.database.datamodel.service.dto.DataParamDTO;
import com.jeeplus.database.datamodel.service.dto.DataSetDTO;
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 DataParamWrapperImpl implements DataParamWrapper {

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

        List <DataParam> list = new ArrayList <DataParam> ( arg0.size ( ) );
        for (DataParamDTO dataParamDTO : arg0) {
            list.add ( toEntity ( dataParamDTO ) );
        }

        return list;
    }

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

        List <DataParamDTO> list = new ArrayList <DataParamDTO> ( arg0.size ( ) );
        for (DataParam dataParam : arg0) {
            list.add ( toDTO ( dataParam ) );
        }

        return list;
    }

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

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

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

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

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

    @Override
    public DataParam toEntity(DataParamDTO dto) {
        if ( dto == null ) {
            return null;
        }

        DataParam dataParam = new DataParam ( );

        dataParam.setDataSetId ( dtoDataSetDTOId ( dto ) );
        dataParam.setCreateById ( dtoCreateById ( dto ) );
        dataParam.setUpdateById ( dtoUpdateById ( dto ) );
        dataParam.setId ( dto.getId ( ) );
        dataParam.setCreateTime ( dto.getCreateTime ( ) );
        dataParam.setUpdateTime ( dto.getUpdateTime ( ) );
        dataParam.setDelFlag ( dto.getDelFlag ( ) );
        dataParam.setField ( dto.getField ( ) );
        dataParam.setDefaultValue ( dto.getDefaultValue ( ) );
        dataParam.setSort ( dto.getSort ( ) );

        return dataParam;
    }

    @Override
    public DataParamDTO toDTO(DataParam entity) {
        if ( entity == null ) {
            return null;
        }

        DataParamDTO dataParamDTO = new DataParamDTO ( );

        dataParamDTO.setDataSetDTO ( dataParamToDataSetDTO ( entity ) );
        dataParamDTO.setCreateBy ( dataParamToUserDTO ( entity ) );
        dataParamDTO.setUpdateBy ( dataParamToUserDTO1 ( entity ) );
        dataParamDTO.setId ( entity.getId ( ) );
        dataParamDTO.setCreateTime ( entity.getCreateTime ( ) );
        dataParamDTO.setUpdateTime ( entity.getUpdateTime ( ) );
        dataParamDTO.setDelFlag ( entity.getDelFlag ( ) );
        dataParamDTO.setField ( entity.getField ( ) );
        dataParamDTO.setDefaultValue ( entity.getDefaultValue ( ) );
        dataParamDTO.setSort ( entity.getSort ( ) );

        return dataParamDTO;
    }

    private String dtoDataSetDTOId(DataParamDTO dataParamDTO) {
        if ( dataParamDTO == null ) {
            return null;
        }
        DataSetDTO dataSetDTO = dataParamDTO.getDataSetDTO ( );
        if ( dataSetDTO == null ) {
            return null;
        }
        String id = dataSetDTO.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

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

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

    protected DataSetDTO dataParamToDataSetDTO(DataParam dataParam) {
        if ( dataParam == null ) {
            return null;
        }

        DataSetDTO dataSetDTO = new DataSetDTO ( );

        dataSetDTO.setId ( dataParam.getDataSetId ( ) );

        return dataSetDTO;
    }

    protected UserDTO dataParamToUserDTO(DataParam dataParam) {
        if ( dataParam == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dataParam.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO dataParamToUserDTO1(DataParam dataParam) {
        if ( dataParam == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dataParam.getUpdateById ( ) );

        return userDTO;
    }
}
