package com.jeeplus.sys.service.mapstruct;

import com.jeeplus.core.dto.DragNode;
import com.jeeplus.sys.domain.Office;
import com.jeeplus.sys.service.dto.OfficeDTO;
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:53+0800",
        comments = "version: 1.4.1.Final, compiler: javac, environment: Java 1.8.0_221 (Oracle Corporation)"
)
@Component
public class OfficeWrapperImpl implements OfficeWrapper {

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

        Office office = new Office ( );

        office.setId ( arg0.getId ( ) );
        office.setCreateTime ( arg0.getCreateTime ( ) );
        office.setCreateById ( arg0.getCreateById ( ) );
        office.setUpdateTime ( arg0.getUpdateTime ( ) );
        office.setUpdateById ( arg0.getUpdateById ( ) );
        office.setDelFlag ( arg0.getDelFlag ( ) );
        office.setTenantId ( arg0.getTenantId ( ) );
        office.setParentId ( arg0.getParentId ( ) );
        office.setParentIds ( arg0.getParentIds ( ) );
        office.setName ( arg0.getName ( ) );
        office.setSort ( arg0.getSort ( ) );
        List <Office> list = arg0.getChildren ( );
        if ( list != null ) {
            office.setChildren ( new ArrayList <Office> ( list ) );
        }
        office.setArea ( arg0.getArea ( ) );
        office.setCode ( arg0.getCode ( ) );
        office.setType ( arg0.getType ( ) );
        office.setGrade ( arg0.getGrade ( ) );
        office.setAddress ( arg0.getAddress ( ) );
        office.setZipCode ( arg0.getZipCode ( ) );
        office.setMaster ( arg0.getMaster ( ) );
        office.setPhone ( arg0.getPhone ( ) );
        office.setFax ( arg0.getFax ( ) );
        office.setEmail ( arg0.getEmail ( ) );
        office.setUseable ( arg0.getUseable ( ) );
        office.setRemarks ( arg0.getRemarks ( ) );

        return office;
    }

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

        OfficeDTO officeDTO = new OfficeDTO ( );

        officeDTO.setId ( arg0.getId ( ) );
        officeDTO.setCreateTime ( arg0.getCreateTime ( ) );
        officeDTO.setCreateBy ( arg0.getCreateBy ( ) );
        officeDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        officeDTO.setUpdateBy ( arg0.getUpdateBy ( ) );
        officeDTO.setDelFlag ( arg0.getDelFlag ( ) );
        officeDTO.setTenantDTO ( arg0.getTenantDTO ( ) );
        officeDTO.setParent ( copyDTO ( arg0.getParent ( ) ) );
        List <OfficeDTO> list = arg0.getChildren ( );
        if ( list != null ) {
            officeDTO.setChildren ( new ArrayList <OfficeDTO> ( list ) );
        }
        officeDTO.setParentIds ( arg0.getParentIds ( ) );
        officeDTO.setName ( arg0.getName ( ) );
        officeDTO.setSort ( arg0.getSort ( ) );
        officeDTO.setArea ( arg0.getArea ( ) );
        officeDTO.setCode ( arg0.getCode ( ) );
        officeDTO.setType ( arg0.getType ( ) );
        officeDTO.setGrade ( arg0.getGrade ( ) );
        officeDTO.setAddress ( arg0.getAddress ( ) );
        officeDTO.setZipCode ( arg0.getZipCode ( ) );
        officeDTO.setMaster ( arg0.getMaster ( ) );
        officeDTO.setPhone ( arg0.getPhone ( ) );
        officeDTO.setFax ( arg0.getFax ( ) );
        officeDTO.setEmail ( arg0.getEmail ( ) );
        officeDTO.setUseable ( arg0.getUseable ( ) );
        officeDTO.setRemarks ( arg0.getRemarks ( ) );
        List <String> list1 = arg0.getChildDeptList ( );
        if ( list1 != null ) {
            officeDTO.setChildDeptList ( new ArrayList <String> ( list1 ) );
        }
        officeDTO.setDisabled ( arg0.isDisabled ( ) );

        return officeDTO;
    }

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

        List <Office> list = new ArrayList <Office> ( arg0.size ( ) );
        for (OfficeDTO officeDTO : arg0) {
            list.add ( toEntity ( officeDTO ) );
        }

        return list;
    }

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

        List <OfficeDTO> list = new ArrayList <OfficeDTO> ( arg0.size ( ) );
        for (Office office : arg0) {
            list.add ( toDTO ( office ) );
        }

        return list;
    }

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

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

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

        return dragNode;
    }

    @Override
    public Office toEntity(OfficeDTO dto) {
        if ( dto == null ) {
            return null;
        }

        Office office = new Office ( );

        office.setTenantId ( dtoTenantDTOId ( dto ) );
        office.setParentId ( dtoParentId ( dto ) );
        office.setCreateById ( dtoCreateById ( dto ) );
        office.setUpdateById ( dtoUpdateById ( dto ) );
        office.setId ( dto.getId ( ) );
        office.setCreateTime ( dto.getCreateTime ( ) );
        office.setUpdateTime ( dto.getUpdateTime ( ) );
        office.setDelFlag ( dto.getDelFlag ( ) );
        office.setParentIds ( dto.getParentIds ( ) );
        office.setName ( dto.getName ( ) );
        office.setSort ( dto.getSort ( ) );
        office.setChildren ( toEntity ( dto.getChildren ( ) ) );
        office.setArea ( dto.getArea ( ) );
        office.setCode ( dto.getCode ( ) );
        office.setType ( dto.getType ( ) );
        office.setGrade ( dto.getGrade ( ) );
        office.setAddress ( dto.getAddress ( ) );
        office.setZipCode ( dto.getZipCode ( ) );
        office.setMaster ( dto.getMaster ( ) );
        office.setPhone ( dto.getPhone ( ) );
        office.setFax ( dto.getFax ( ) );
        office.setEmail ( dto.getEmail ( ) );
        office.setUseable ( dto.getUseable ( ) );
        office.setRemarks ( dto.getRemarks ( ) );

        return office;
    }

    @Override
    public OfficeDTO toDTO(Office entity) {
        if ( entity == null ) {
            return null;
        }

        OfficeDTO officeDTO = new OfficeDTO ( );

        officeDTO.setTenantDTO ( officeToTenantDTO ( entity ) );
        officeDTO.setParent ( officeToOfficeDTO ( entity ) );
        officeDTO.setCreateBy ( officeToUserDTO ( entity ) );
        officeDTO.setUpdateBy ( officeToUserDTO1 ( entity ) );
        officeDTO.setId ( entity.getId ( ) );
        officeDTO.setCreateTime ( entity.getCreateTime ( ) );
        officeDTO.setUpdateTime ( entity.getUpdateTime ( ) );
        officeDTO.setDelFlag ( entity.getDelFlag ( ) );
        officeDTO.setChildren ( toDTO ( entity.getChildren ( ) ) );
        officeDTO.setParentIds ( entity.getParentIds ( ) );
        officeDTO.setName ( entity.getName ( ) );
        officeDTO.setSort ( entity.getSort ( ) );
        officeDTO.setArea ( entity.getArea ( ) );
        officeDTO.setCode ( entity.getCode ( ) );
        officeDTO.setType ( entity.getType ( ) );
        officeDTO.setGrade ( entity.getGrade ( ) );
        officeDTO.setAddress ( entity.getAddress ( ) );
        officeDTO.setZipCode ( entity.getZipCode ( ) );
        officeDTO.setMaster ( entity.getMaster ( ) );
        officeDTO.setPhone ( entity.getPhone ( ) );
        officeDTO.setFax ( entity.getFax ( ) );
        officeDTO.setEmail ( entity.getEmail ( ) );
        officeDTO.setUseable ( entity.getUseable ( ) );
        officeDTO.setRemarks ( entity.getRemarks ( ) );

        return officeDTO;
    }

    private String dtoTenantDTOId(OfficeDTO officeDTO) {
        if ( officeDTO == null ) {
            return null;
        }
        TenantDTO tenantDTO = officeDTO.getTenantDTO ( );
        if ( tenantDTO == null ) {
            return null;
        }
        String id = tenantDTO.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private String dtoParentId(OfficeDTO officeDTO) {
        if ( officeDTO == null ) {
            return null;
        }
        OfficeDTO parent = officeDTO.getParent ( );
        if ( parent == null ) {
            return null;
        }
        String id = parent.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

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

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

    protected TenantDTO officeToTenantDTO(Office office) {
        if ( office == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( office.getTenantId ( ) );

        return tenantDTO;
    }

    protected OfficeDTO officeToOfficeDTO(Office office) {
        if ( office == null ) {
            return null;
        }

        OfficeDTO officeDTO = new OfficeDTO ( );

        officeDTO.setId ( office.getParentId ( ) );

        return officeDTO;
    }

    protected UserDTO officeToUserDTO(Office office) {
        if ( office == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( office.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO officeToUserDTO1(Office office) {
        if ( office == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( office.getUpdateById ( ) );

        return userDTO;
    }
}
