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.Role;
import com.jeeplus.sys.service.dto.RoleDTO;
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 RoleWrapperImpl implements RoleWrapper {

    @Override
    public Role toEntity(RoleDTO arg0) {
        if ( arg0 == null ) {
            return null;
        }

        Role role = new Role ( );

        role.setTenantId ( arg0TenantDTOId ( arg0 ) );
        role.setCreateById ( arg0CreateById ( arg0 ) );
        role.setUpdateById ( arg0UpdateById ( arg0 ) );
        role.setId ( arg0.getId ( ) );
        role.setCreateTime ( arg0.getCreateTime ( ) );
        role.setUpdateTime ( arg0.getUpdateTime ( ) );
        role.setDelFlag ( arg0.getDelFlag ( ) );
        role.setName ( arg0.getName ( ) );
        role.setEnName ( arg0.getEnName ( ) );
        role.setSysData ( arg0.getSysData ( ) );
        role.setUseable ( arg0.getUseable ( ) );
        role.setRemarks ( arg0.getRemarks ( ) );

        return role;
    }

    @Override
    public RoleDTO toDTO(Role arg0) {
        if ( arg0 == null ) {
            return null;
        }

        RoleDTO roleDTO = new RoleDTO ( );

        roleDTO.setTenantDTO ( roleToTenantDTO ( arg0 ) );
        roleDTO.setCreateBy ( roleToUserDTO ( arg0 ) );
        roleDTO.setUpdateBy ( roleToUserDTO1 ( arg0 ) );
        roleDTO.setId ( arg0.getId ( ) );
        roleDTO.setCreateTime ( arg0.getCreateTime ( ) );
        roleDTO.setUpdateTime ( arg0.getUpdateTime ( ) );
        roleDTO.setDelFlag ( arg0.getDelFlag ( ) );
        roleDTO.setName ( arg0.getName ( ) );
        roleDTO.setEnName ( arg0.getEnName ( ) );
        roleDTO.setSysData ( arg0.getSysData ( ) );
        roleDTO.setUseable ( arg0.getUseable ( ) );
        roleDTO.setRemarks ( arg0.getRemarks ( ) );

        return roleDTO;
    }

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

        List <Role> list = new ArrayList <Role> ( arg0.size ( ) );
        for (RoleDTO roleDTO : arg0) {
            list.add ( toEntity ( roleDTO ) );
        }

        return list;
    }

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

        List <RoleDTO> list = new ArrayList <RoleDTO> ( arg0.size ( ) );
        for (Role role : arg0) {
            list.add ( toDTO ( role ) );
        }

        return list;
    }

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

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

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

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

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

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

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

    protected TenantDTO roleToTenantDTO(Role role) {
        if ( role == null ) {
            return null;
        }

        TenantDTO tenantDTO = new TenantDTO ( );

        tenantDTO.setId ( role.getTenantId ( ) );

        return tenantDTO;
    }

    protected UserDTO roleToUserDTO(Role role) {
        if ( role == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( role.getCreateById ( ) );

        return userDTO;
    }

    protected UserDTO roleToUserDTO1(Role role) {
        if ( role == null ) {
            return null;
        }

        UserDTO userDTO = new UserDTO ( );

        userDTO.setId ( role.getUpdateById ( ) );

        return userDTO;
    }
}
