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.DataRule;
import com.jeeplus.sys.service.dto.DataRuleDTO;
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 DataRuleWrapperImpl implements DataRuleWrapper {

    @Override
    public DataRule toEntity(DataRuleDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DataRule dataRule = new DataRule ( );

        dataRule.setTenantId ( arg0TenantDTOId ( arg0 ) );
        dataRule.setCreateById ( arg0CreateById ( arg0 ) );
        dataRule.setUpdateById ( arg0UpdateById ( arg0 ) );
        dataRule.setId ( arg0.getId ( ) );
        dataRule.setCreateTime ( arg0.getCreateTime ( ) );
        dataRule.setUpdateTime ( arg0.getUpdateTime ( ) );
        dataRule.setDelFlag ( arg0.getDelFlag ( ) );
        dataRule.setMenuId ( arg0.getMenuId ( ) );
        dataRule.setName ( arg0.getName ( ) );
        dataRule.setClassName ( arg0.getClassName ( ) );
        dataRule.setField ( arg0.getField ( ) );
        dataRule.setExpress ( arg0.getExpress ( ) );
        dataRule.setValue ( arg0.getValue ( ) );
        dataRule.setSqlSegment ( arg0.getSqlSegment ( ) );
        dataRule.setRemarks ( arg0.getRemarks ( ) );

        return dataRule;
    }

    @Override
    public DataRuleDTO toDTO(DataRule arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DataRuleDTO dataRuleDTO = new DataRuleDTO ( );

        dataRuleDTO.setTenantDTO ( dataRuleToTenantDTO ( arg0 ) );
        dataRuleDTO.setCreateBy ( dataRuleToUserDTO ( arg0 ) );
        dataRuleDTO.setUpdateBy ( dataRuleToUserDTO1 ( arg0 ) );
        dataRuleDTO.setId ( arg0.getId ( ) );
        dataRuleDTO.setCreateTime ( arg0.getCreateTime ( ) );
        dataRuleDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        dataRuleDTO.setDelFlag ( arg0.getDelFlag ( ) );
        dataRuleDTO.setMenuId ( arg0.getMenuId ( ) );
        dataRuleDTO.setName ( arg0.getName ( ) );
        dataRuleDTO.setClassName ( arg0.getClassName ( ) );
        dataRuleDTO.setField ( arg0.getField ( ) );
        dataRuleDTO.setExpress ( arg0.getExpress ( ) );
        dataRuleDTO.setValue ( arg0.getValue ( ) );
        dataRuleDTO.setSqlSegment ( arg0.getSqlSegment ( ) );
        dataRuleDTO.setRemarks ( arg0.getRemarks ( ) );

        return dataRuleDTO;
    }

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

        List <DataRule> list = new ArrayList <DataRule> ( arg0.size ( ) );
        for (DataRuleDTO dataRuleDTO : arg0) {
            list.add ( toEntity ( dataRuleDTO ) );
        }

        return list;
    }

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

        List <DataRuleDTO> list = new ArrayList <DataRuleDTO> ( arg0.size ( ) );
        for (DataRule dataRule : arg0) {
            list.add ( toDTO ( dataRule ) );
        }

        return list;
    }

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

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

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

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

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

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

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

    protected TenantDTO dataRuleToTenantDTO(DataRule dataRule) {
        if ( dataRule == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( dataRule.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO dataRuleToUserDTO(DataRule dataRule) {
        if ( dataRule == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dataRule.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO dataRuleToUserDTO1(DataRule dataRule) {
        if ( dataRule == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dataRule.getUpdateById ( ) );

        return userDTO;
    }
}
