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.User;
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:54+0800",
        comments = "version: 1.4.1.Final, compiler: javac, environment: Java 1.8.0_221 (Oracle Corporation)"
)
@Component
public class UserWrapperImpl implements UserWrapper {

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

        List <User> list = new ArrayList <User> ( arg0.size ( ) );
        for (UserDTO userDTO : arg0) {
            list.add ( toEntity ( userDTO ) );
        }

        return list;
    }

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

        List <UserDTO> list = new ArrayList <UserDTO> ( arg0.size ( ) );
        for (User user : arg0) {
            list.add ( toDTO ( user ) );
        }

        return list;
    }

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

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

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

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

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

        User user = new User ( );

        user.setTenantId ( dtoTenantDTOId ( dto ) );
        user.setCompanyId ( dtoCompanyDTOId ( dto ) );
        user.setOfficeId ( dtoOfficeDTOId ( dto ) );
        user.setCreateById ( dtoCreateById ( dto ) );
        user.setUpdateById ( dtoUpdateById ( dto ) );
        user.setId ( dto.getId ( ) );
        user.setCreateTime ( dto.getCreateTime ( ) );
        user.setUpdateTime ( dto.getUpdateTime ( ) );
        user.setDelFlag ( dto.getDelFlag ( ) );
        user.setLoginName ( dto.getLoginName ( ) );
        user.setPassword ( dto.getPassword ( ) );
        user.setNo ( dto.getNo ( ) );
        user.setName ( dto.getName ( ) );
        user.setEmail ( dto.getEmail ( ) );
        user.setPhone ( dto.getPhone ( ) );
        user.setMobile ( dto.getMobile ( ) );
        user.setLoginIp ( dto.getLoginIp ( ) );
        user.setLoginDate ( dto.getLoginDate ( ) );
        user.setLoginFlag ( dto.getLoginFlag ( ) );
        user.setPhoto ( dto.getPhoto ( ) );
        user.setQrCode ( dto.getQrCode ( ) );
        user.setSign ( dto.getSign ( ) );
        user.setRemarks ( dto.getRemarks ( ) );

        return user;
    }

    @Override
    public UserDTO toDTO(User entity) {
        if ( entity == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setTenantDTO ( userToTenantDTO ( entity ) );
        userDTO.setCompanyDTO ( userToOfficeDTO ( entity ) );
        userDTO.setOfficeDTO ( userToOfficeDTO1 ( entity ) );
        userDTO.setCreateBy ( userToUserDTO ( entity ) );
        userDTO.setUpdateBy ( userToUserDTO1 ( entity ) );
        userDTO.setId ( entity.getId ( ) );
        userDTO.setCreateTime ( entity.getCreateTime ( ) );
        userDTO.setUpdateTime ( entity.getUpdateTime ( ) );
        userDTO.setDelFlag ( entity.getDelFlag ( ) );
        userDTO.setLoginName ( entity.getLoginName ( ) );
        userDTO.setPassword ( entity.getPassword ( ) );
        userDTO.setName ( entity.getName ( ) );
        userDTO.setNo ( entity.getNo ( ) );
        userDTO.setEmail ( entity.getEmail ( ) );
        userDTO.setPhone ( entity.getPhone ( ) );
        userDTO.setMobile ( entity.getMobile ( ) );
        userDTO.setLoginIp ( entity.getLoginIp ( ) );
        userDTO.setLoginDate ( entity.getLoginDate ( ) );
        userDTO.setLoginFlag ( entity.getLoginFlag ( ) );
        userDTO.setPhoto ( entity.getPhoto ( ) );
        userDTO.setQrCode ( entity.getQrCode ( ) );
        userDTO.setSign ( entity.getSign ( ) );
        userDTO.setRemarks ( entity.getRemarks ( ) );

        return userDTO;
    }

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

    private String dtoCompanyDTOId(UserDTO userDTO) {
        if ( userDTO == null ) {
            return null;
        }
        OfficeDTO companyDTO = userDTO.getCompanyDTO ( );
        if ( companyDTO == null ) {
            return null;
        }
        String id = companyDTO.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

    private String dtoOfficeDTOId(UserDTO userDTO) {
        if ( userDTO == null ) {
            return null;
        }
        OfficeDTO officeDTO = userDTO.getOfficeDTO ( );
        if ( officeDTO == null ) {
            return null;
        }
        String id = officeDTO.getId ( );
        if ( id == null ) {
            return null;
        }
        return id;
    }

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

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

    protected TenantDTO userToTenantDTO(User user) {
        if ( user == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( user.getTenantId ( ) );

        return tenantDTO;
    }

    protected OfficeDTO userToOfficeDTO(User user) {
        if ( user == null ) {
            return null;
        }

        OfficeDTO officeDTO = new OfficeDTO ( );

        officeDTO.setId ( user.getCompanyId ( ) );

        return officeDTO;
    }

    protected OfficeDTO userToOfficeDTO1(User user) {
        if ( user == null ) {
            return null;
        }

        OfficeDTO officeDTO = new OfficeDTO ( );

        officeDTO.setId ( user.getOfficeId ( ) );

        return officeDTO;
    }

    protected UserDTO userToUserDTO(User user) {
        if ( user == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( user.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO userToUserDTO1(User user) {
        if ( user == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( user.getUpdateById ( ) );

        return userDTO;
    }
}
