package com.jeeplus.sys.service.mapstruct;

import com.jeeplus.core.dto.DragNode;
import com.jeeplus.sys.domain.Area;
import com.jeeplus.sys.service.dto.AreaDTO;
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 AreaWrapperImpl implements AreaWrapper {

    @Override
    public Area toEntity(AreaDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Area area = new Area ( );

        area.setParentId ( arg0ParentId ( arg0 ) );
        area.setCreateById ( arg0CreateById ( arg0 ) );
        area.setUpdateById ( arg0UpdateById ( arg0 ) );
        area.setId ( arg0.getId ( ) );
        area.setCreateTime ( arg0.getCreateTime ( ) );
        area.setUpdateTime ( arg0.getUpdateTime ( ) );
        area.setDelFlag ( arg0.getDelFlag ( ) );
        area.setParentIds ( arg0.getParentIds ( ) );
        area.setName ( arg0.getName ( ) );
        area.setSort ( arg0.getSort ( ) );
        area.setChildren ( toEntity ( arg0.getChildren ( ) ) );
        area.setCode ( arg0.getCode ( ) );
        area.setType ( arg0.getType ( ) );
        area.setRemarks ( arg0.getRemarks ( ) );

        return area;
    }

    @Override
    public AreaDTO toDTO(Area arg0) {
        if ( arg0 == null ) {
            return null;
        }

        AreaDTO areaDTO = new AreaDTO ( );

        areaDTO.setParent ( areaToAreaDTO ( arg0 ) );
        areaDTO.setCreateBy ( areaToUserDTO ( arg0 ) );
        areaDTO.setUpdateBy ( areaToUserDTO1 ( arg0 ) );
        areaDTO.setId ( arg0.getId ( ) );
        areaDTO.setCreateTime ( arg0.getCreateTime ( ) );
        areaDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        areaDTO.setDelFlag ( arg0.getDelFlag ( ) );
        areaDTO.setChildren ( toDTO ( arg0.getChildren ( ) ) );
        areaDTO.setParentIds ( arg0.getParentIds ( ) );
        areaDTO.setName ( arg0.getName ( ) );
        areaDTO.setSort ( arg0.getSort ( ) );
        areaDTO.setCode ( arg0.getCode ( ) );
        areaDTO.setType ( arg0.getType ( ) );
        areaDTO.setRemarks ( arg0.getRemarks ( ) );

        return areaDTO;
    }

    @Override
    public Area copyEntity(Area arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Area area = new Area ( );

        area.setId ( arg0.getId ( ) );
        area.setCreateTime ( arg0.getCreateTime ( ) );
        area.setCreateById ( arg0.getCreateById ( ) );
        area.setUpdateTime ( arg0.getUpdateTime ( ) );
        area.setUpdateById ( arg0.getUpdateById ( ) );
        area.setDelFlag ( arg0.getDelFlag ( ) );
        area.setTenantId ( arg0.getTenantId ( ) );
        area.setParentId ( arg0.getParentId ( ) );
        area.setParentIds ( arg0.getParentIds ( ) );
        area.setName ( arg0.getName ( ) );
        area.setSort ( arg0.getSort ( ) );
        List <Area> list = arg0.getChildren ( );
        if ( list != null ) {
            area.setChildren ( new ArrayList <Area> ( list ) );
        }
        area.setCode ( arg0.getCode ( ) );
        area.setType ( arg0.getType ( ) );
        area.setRemarks ( arg0.getRemarks ( ) );

        return area;
    }

    @Override
    public AreaDTO copyDTO(AreaDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        AreaDTO areaDTO = new AreaDTO ( );

        areaDTO.setId ( arg0.getId ( ) );
        areaDTO.setCreateTime ( arg0.getCreateTime ( ) );
        areaDTO.setCreateBy ( arg0.getCreateBy ( ) );
        areaDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        areaDTO.setUpdateBy ( arg0.getUpdateBy ( ) );
        areaDTO.setDelFlag ( arg0.getDelFlag ( ) );
        areaDTO.setTenantDTO ( arg0.getTenantDTO ( ) );
        areaDTO.setParent ( copyDTO ( arg0.getParent ( ) ) );
        List <AreaDTO> list = arg0.getChildren ( );
        if ( list != null ) {
            areaDTO.setChildren ( new ArrayList <AreaDTO> ( list ) );
        }
        areaDTO.setParentIds ( arg0.getParentIds ( ) );
        areaDTO.setName ( arg0.getName ( ) );
        areaDTO.setSort ( arg0.getSort ( ) );
        areaDTO.setCode ( arg0.getCode ( ) );
        areaDTO.setType ( arg0.getType ( ) );
        areaDTO.setRemarks ( arg0.getRemarks ( ) );

        return areaDTO;
    }

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

        List <Area> list = new ArrayList <Area> ( arg0.size ( ) );
        for (AreaDTO areaDTO : arg0) {
            list.add ( toEntity ( areaDTO ) );
        }

        return list;
    }

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

        List <AreaDTO> list = new ArrayList <AreaDTO> ( arg0.size ( ) );
        for (Area area : arg0) {
            list.add ( toDTO ( area ) );
        }

        return list;
    }

    @Override
    public DragNode <Area> toEntity(DragNode <AreaDTO> arg0) {
        if ( arg0 == null ) {
            return null;
        }

        DragNode <Area> dragNode = new DragNode <Area> ( );

        dragNode.setDraggingNode ( toEntity ( arg0.getDraggingNode ( ) ) );
        dragNode.setDropNode ( toEntity ( arg0.getDropNode ( ) ) );
        dragNode.setDropType ( arg0.getDropType ( ) );

        return dragNode;
    }

    private String arg0ParentId(AreaDTO areaDTO) {
        if ( areaDTO == null ) {
            return null;
        }
        AreaDTO parent = areaDTO.getParent ( );
        if ( parent == null ) {
            return null;
        }
        String id = parent.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

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

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

    protected AreaDTO areaToAreaDTO(Area area) {
        if ( area == null ) {
            return null;
        }

        AreaDTO areaDTO = new AreaDTO ( );

        areaDTO.setId ( area.getParentId ( ) );

        return areaDTO;
    }

    protected UserDTO areaToUserDTO(Area area) {
        if ( area == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( area.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO areaToUserDTO1(Area area) {
        if ( area == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( area.getUpdateById ( ) );

        return userDTO;
    }
}
