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.Desk;
import com.jeeplus.sys.service.dto.DeskDTO;
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 DeskWrapperImpl implements DeskWrapper {

    @Override
    public Desk toEntity(DeskDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Desk desk = new Desk ( );

        desk.setTenantId ( arg0TenantDTOId ( arg0 ) );
        desk.setCreateById ( arg0CreateById ( arg0 ) );
        desk.setUpdateById ( arg0UpdateById ( arg0 ) );
        desk.setId ( arg0.getId ( ) );
        desk.setCreateTime ( arg0.getCreateTime ( ) );
        desk.setUpdateTime ( arg0.getUpdateTime ( ) );
        desk.setDelFlag ( arg0.getDelFlag ( ) );
        desk.setGrid ( arg0.getGrid ( ) );

        return desk;
    }

    @Override
    public DeskDTO toDTO(Desk arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DeskDTO deskDTO = new DeskDTO ( );

        deskDTO.setTenantDTO ( deskToTenantDTO ( arg0 ) );
        deskDTO.setCreateBy ( deskToUserDTO ( arg0 ) );
        deskDTO.setUpdateBy ( deskToUserDTO1 ( arg0 ) );
        deskDTO.setId ( arg0.getId ( ) );
        deskDTO.setCreateTime ( arg0.getCreateTime ( ) );
        deskDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        deskDTO.setDelFlag ( arg0.getDelFlag ( ) );
        deskDTO.setGrid ( arg0.getGrid ( ) );

        return deskDTO;
    }

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

        List <Desk> list = new ArrayList <Desk> ( arg0.size ( ) );
        for (DeskDTO deskDTO : arg0) {
            list.add ( toEntity ( deskDTO ) );
        }

        return list;
    }

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

        List <DeskDTO> list = new ArrayList <DeskDTO> ( arg0.size ( ) );
        for (Desk desk : arg0) {
            list.add ( toDTO ( desk ) );
        }

        return list;
    }

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

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

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

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

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

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

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

    protected TenantDTO deskToTenantDTO(Desk desk) {
        if ( desk == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( desk.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO deskToUserDTO(Desk desk) {
        if ( desk == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( desk.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO deskToUserDTO1(Desk desk) {
        if ( desk == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( desk.getUpdateById ( ) );

        return userDTO;
    }
}
