package com.jeeplus.echarts.service.mapstruct;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.echarts.domain.Dashboard;
import com.jeeplus.echarts.service.dto.DashboardDTO;
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 DashboardWrapperImpl implements DashboardWrapper {

    @Override
    public Dashboard toEntity(DashboardDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Dashboard dashboard = new Dashboard ( );

        dashboard.setTenantId ( arg0TenantDTOId ( arg0 ) );
        dashboard.setCreateById ( arg0CreateById ( arg0 ) );
        dashboard.setUpdateById ( arg0UpdateById ( arg0 ) );
        dashboard.setId ( arg0.getId ( ) );
        dashboard.setCreateTime ( arg0.getCreateTime ( ) );
        dashboard.setUpdateTime ( arg0.getUpdateTime ( ) );
        dashboard.setDelFlag ( arg0.getDelFlag ( ) );
        dashboard.setName ( arg0.getName ( ) );
        dashboard.setGrid ( arg0.getGrid ( ) );
        dashboard.setRemarks ( arg0.getRemarks ( ) );

        return dashboard;
    }

    @Override
    public DashboardDTO toDTO(Dashboard arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DashboardDTO dashboardDTO = new DashboardDTO ( );

        dashboardDTO.setTenantDTO ( dashboardToTenantDTO ( arg0 ) );
        dashboardDTO.setCreateBy ( dashboardToUserDTO ( arg0 ) );
        dashboardDTO.setUpdateBy ( dashboardToUserDTO1 ( arg0 ) );
        dashboardDTO.setId ( arg0.getId ( ) );
        dashboardDTO.setCreateTime ( arg0.getCreateTime ( ) );
        dashboardDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        dashboardDTO.setDelFlag ( arg0.getDelFlag ( ) );
        dashboardDTO.setName ( arg0.getName ( ) );
        dashboardDTO.setGrid ( arg0.getGrid ( ) );
        dashboardDTO.setRemarks ( arg0.getRemarks ( ) );

        return dashboardDTO;
    }

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

        List <Dashboard> list = new ArrayList <Dashboard> ( arg0.size ( ) );
        for (DashboardDTO dashboardDTO : arg0) {
            list.add ( toEntity ( dashboardDTO ) );
        }

        return list;
    }

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

        List <DashboardDTO> list = new ArrayList <DashboardDTO> ( arg0.size ( ) );
        for (Dashboard dashboard : arg0) {
            list.add ( toDTO ( dashboard ) );
        }

        return list;
    }

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

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

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

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

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

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

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

    protected TenantDTO dashboardToTenantDTO(Dashboard dashboard) {
        if ( dashboard == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( dashboard.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO dashboardToUserDTO(Dashboard dashboard) {
        if ( dashboard == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dashboard.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO dashboardToUserDTO1(Dashboard dashboard) {
        if ( dashboard == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dashboard.getUpdateById ( ) );

        return userDTO;
    }
}
