package vn.azteam.tpf.service.mapper;

import vn.azteam.tpf.domain.*;
import vn.azteam.tpf.service.dto.TBVendorDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity TBVendor and its DTO TBVendorDTO.
 */
@Mapper(componentModel = "spring", uses = {TBDetailUserMapper.class, TBAddressMapper.class, TBCustomerMapper.class})
public interface TBVendorMapper extends EntityMapper<TBVendorDTO, TBVendor> {

    @Mapping(source = "createdBy.id", target = "createdById")
    @Mapping(source = "modifiedBy.id", target = "modifiedById")
    @Mapping(source = "deletedBy.id", target = "deletedById")
    @Mapping(source = "tbAddress.id", target = "tbAddressId")
    @Mapping(source = "tbCustomer.id", target = "tbCustomerId")
    TBVendorDTO toDto(TBVendor tBVendor);

    @Mapping(source = "createdById", target = "createdBy")
    @Mapping(source = "modifiedById", target = "modifiedBy")
    @Mapping(source = "deletedById", target = "deletedBy")
    @Mapping(source = "tbAddressId", target = "tbAddress")
    @Mapping(source = "tbCustomerId", target = "tbCustomer")
    TBVendor toEntity(TBVendorDTO tBVendorDTO);

    default TBVendor fromId(Long id) {
        if (id == null) {
            return null;
        }
        TBVendor tBVendor = new TBVendor();
        tBVendor.setId(id);
        return tBVendor;
    }
}
