package com.jeeplus.notify.service.mapstruct;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.notify.domain.Notify;
import com.jeeplus.notify.service.dto.NotifyDTO;
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 NotifyWrapperImpl implements NotifyWrapper {

    @Override
    public Notify toEntity(NotifyDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Notify notify = new Notify ( );

        notify.setTenantId ( arg0TenantDTOId ( arg0 ) );
        notify.setCreateById ( arg0CreateById ( arg0 ) );
        notify.setUpdateById ( arg0UpdateById ( arg0 ) );
        notify.setId ( arg0.getId ( ) );
        notify.setCreateTime ( arg0.getCreateTime ( ) );
        notify.setUpdateTime ( arg0.getUpdateTime ( ) );
        notify.setDelFlag ( arg0.getDelFlag ( ) );
        notify.setType ( arg0.getType ( ) );
        notify.setTitle ( arg0.getTitle ( ) );
        notify.setContent ( arg0.getContent ( ) );
        notify.setFiles ( arg0.getFiles ( ) );
        notify.setStatus ( arg0.getStatus ( ) );

        return notify;
    }

    @Override
    public NotifyDTO toDTO(Notify arg0) {
        if ( arg0 == null ) {
            return null;
        }

        NotifyDTO notifyDTO = new NotifyDTO ( );

        notifyDTO.setTenantDTO ( notifyToTenantDTO ( arg0 ) );
        notifyDTO.setCreateBy ( notifyToUserDTO ( arg0 ) );
        notifyDTO.setUpdateBy ( notifyToUserDTO1 ( arg0 ) );
        notifyDTO.setId ( arg0.getId ( ) );
        notifyDTO.setCreateTime ( arg0.getCreateTime ( ) );
        notifyDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        notifyDTO.setDelFlag ( arg0.getDelFlag ( ) );
        notifyDTO.setType ( arg0.getType ( ) );
        notifyDTO.setTitle ( arg0.getTitle ( ) );
        notifyDTO.setContent ( arg0.getContent ( ) );
        notifyDTO.setFiles ( arg0.getFiles ( ) );
        notifyDTO.setStatus ( arg0.getStatus ( ) );

        return notifyDTO;
    }

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

        List <Notify> list = new ArrayList <Notify> ( arg0.size ( ) );
        for (NotifyDTO notifyDTO : arg0) {
            list.add ( toEntity ( notifyDTO ) );
        }

        return list;
    }

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

        List <NotifyDTO> list = new ArrayList <NotifyDTO> ( arg0.size ( ) );
        for (Notify notify : arg0) {
            list.add ( toDTO ( notify ) );
        }

        return list;
    }

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

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

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

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

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

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

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

    protected TenantDTO notifyToTenantDTO(Notify notify) {
        if ( notify == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( notify.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO notifyToUserDTO(Notify notify) {
        if ( notify == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( notify.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO notifyToUserDTO1(Notify notify) {
        if ( notify == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( notify.getUpdateById ( ) );

        return userDTO;
    }
}
