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.Log;
import com.jeeplus.sys.service.dto.LogDTO;
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 LogWrapperImpl implements LogWrapper {

    @Override
    public Log toEntity(LogDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Log log = new Log ( );

        log.setTenantId ( arg0TenantDTOId ( arg0 ) );
        log.setCreateById ( arg0CreateById ( arg0 ) );
        log.setUpdateById ( arg0UpdateById ( arg0 ) );
        log.setId ( arg0.getId ( ) );
        log.setCreateTime ( arg0.getCreateTime ( ) );
        log.setDelFlag ( arg0.getDelFlag ( ) );
        log.setType ( arg0.getType ( ) );
        log.setTitle ( arg0.getTitle ( ) );
        log.setRemoteAddr ( arg0.getRemoteAddr ( ) );
        log.setRequestUri ( arg0.getRequestUri ( ) );
        log.setRequestType ( arg0.getRequestType ( ) );
        log.setMethod ( arg0.getMethod ( ) );
        log.setParams ( arg0.getParams ( ) );
        log.setResult ( arg0.getResult ( ) );
        log.setUserAgent ( arg0.getUserAgent ( ) );
        log.setException ( arg0.getException ( ) );
        log.setRecordTime ( arg0.getRecordTime ( ) );
        log.setUpdateTime ( arg0.getUpdateTime ( ) );
        log.setRemarks ( arg0.getRemarks ( ) );

        return log;
    }

    @Override
    public LogDTO toDTO(Log arg0) {
        if ( arg0 == null ) {
            return null;
        }

        LogDTO logDTO = new LogDTO ( );

        logDTO.setTenantDTO ( logToTenantDTO ( arg0 ) );
        logDTO.setCreateBy ( logToUserDTO ( arg0 ) );
        logDTO.setUpdateBy ( logToUserDTO1 ( arg0 ) );
        logDTO.setId ( arg0.getId ( ) );
        logDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        logDTO.setDelFlag ( arg0.getDelFlag ( ) );
        logDTO.setType ( arg0.getType ( ) );
        logDTO.setTitle ( arg0.getTitle ( ) );
        logDTO.setRemoteAddr ( arg0.getRemoteAddr ( ) );
        logDTO.setRequestUri ( arg0.getRequestUri ( ) );
        logDTO.setRequestType ( arg0.getRequestType ( ) );
        logDTO.setMethod ( arg0.getMethod ( ) );
        logDTO.setParams ( arg0.getParams ( ) );
        logDTO.setResult ( arg0.getResult ( ) );
        logDTO.setUserAgent ( arg0.getUserAgent ( ) );
        logDTO.setException ( arg0.getException ( ) );
        logDTO.setRecordTime ( arg0.getRecordTime ( ) );
        logDTO.setCreateTime ( arg0.getCreateTime ( ) );
        logDTO.setRemarks ( arg0.getRemarks ( ) );

        return logDTO;
    }

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

        List <Log> list = new ArrayList <Log> ( arg0.size ( ) );
        for (LogDTO logDTO : arg0) {
            list.add ( toEntity ( logDTO ) );
        }

        return list;
    }

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

        List <LogDTO> list = new ArrayList <LogDTO> ( arg0.size ( ) );
        for (Log log : arg0) {
            list.add ( toDTO ( log ) );
        }

        return list;
    }

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

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

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

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

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

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

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

    protected TenantDTO logToTenantDTO(Log log) {
        if ( log == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( log.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO logToUserDTO(Log log) {
        if ( log == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( log.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO logToUserDTO1(Log log) {
        if ( log == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( log.getUpdateById ( ) );

        return userDTO;
    }
}
