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.DataScreen;
import com.jeeplus.datav.service.dto.DataScreenCategoryDTO;
import com.jeeplus.datav.service.dto.DataScreenDTO;
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 DataScreenWrapperImpl implements DataScreenWrapper {

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

        List <DataScreen> list = new ArrayList <DataScreen> ( arg0.size ( ) );
        for (DataScreenDTO dataScreenDTO : arg0) {
            list.add ( toEntity ( dataScreenDTO ) );
        }

        return list;
    }

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

        List <DataScreenDTO> list = new ArrayList <DataScreenDTO> ( arg0.size ( ) );
        for (DataScreen dataScreen : arg0) {
            list.add ( toDTO ( dataScreen ) );
        }

        return list;
    }

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

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

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

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

        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 DataScreen toEntity(DataScreenDTO dto) {
        if ( dto == null ) {
            return null;
        }

        DataScreen dataScreen = new DataScreen ( );

        dataScreen.setCategoryId ( dtoCategoryId ( dto ) );
        dataScreen.setCreateById ( dtoCreateById ( dto ) );
        dataScreen.setUpdateById ( dtoUpdateById ( dto ) );
        dataScreen.setId ( dto.getId ( ) );
        dataScreen.setCreateTime ( dto.getCreateTime ( ) );
        dataScreen.setUpdateTime ( dto.getUpdateTime ( ) );
        dataScreen.setDelFlag ( dto.getDelFlag ( ) );
        dataScreen.setComponent ( dto.getComponent ( ) );
        dataScreen.setDetail ( dto.getDetail ( ) );
        dataScreen.setStatus ( dto.getStatus ( ) );
        dataScreen.setName ( dto.getName ( ) );
        dataScreen.setScreenShot ( dto.getScreenShot ( ) );
        dataScreen.setBackgroundUrl ( dto.getBackgroundUrl ( ) );
        dataScreen.setRemarks ( dto.getRemarks ( ) );

        return dataScreen;
    }

    @Override
    public DataScreenDTO toDTO(DataScreen entity) {
        if ( entity == null ) {
            return null;
        }

        DataScreenDTO dataScreenDTO = new DataScreenDTO ( );

        dataScreenDTO.setCategory ( dataScreenToDataScreenCategoryDTO ( entity ) );
        dataScreenDTO.setCreateBy ( dataScreenToUserDTO ( entity ) );
        dataScreenDTO.setUpdateBy ( dataScreenToUserDTO1 ( entity ) );
        dataScreenDTO.setId ( entity.getId ( ) );
        dataScreenDTO.setCreateTime ( entity.getCreateTime ( ) );
        dataScreenDTO.setUpdateTime ( entity.getUpdateTime ( ) );
        dataScreenDTO.setDelFlag ( entity.getDelFlag ( ) );
        dataScreenDTO.setComponent ( entity.getComponent ( ) );
        dataScreenDTO.setDetail ( entity.getDetail ( ) );
        dataScreenDTO.setStatus ( entity.getStatus ( ) );
        dataScreenDTO.setName ( entity.getName ( ) );
        dataScreenDTO.setScreenShot ( entity.getScreenShot ( ) );
        dataScreenDTO.setBackgroundUrl ( entity.getBackgroundUrl ( ) );
        dataScreenDTO.setRemarks ( entity.getRemarks ( ) );

        return dataScreenDTO;
    }

    private String dtoCategoryId(DataScreenDTO dataScreenDTO) {
        if ( dataScreenDTO == null ) {
            return null;
        }
        DataScreenCategoryDTO category = dataScreenDTO.getCategory ( );
        if ( category == null ) {
            return null;
        }
        String id = category.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

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

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

    protected DataScreenCategoryDTO dataScreenToDataScreenCategoryDTO(DataScreen dataScreen) {
        if ( dataScreen == null ) {
            return null;
        }

        DataScreenCategoryDTO dataScreenCategoryDTO = new DataScreenCategoryDTO ( );

        dataScreenCategoryDTO.setId ( dataScreen.getCategoryId ( ) );

        return dataScreenCategoryDTO;
    }

    protected UserDTO dataScreenToUserDTO(DataScreen dataScreen) {
        if ( dataScreen == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dataScreen.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO dataScreenToUserDTO1(DataScreen dataScreen) {
        if ( dataScreen == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( dataScreen.getUpdateById ( ) );

        return userDTO;
    }
}
