package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBEquipmentOfCustomer and its DTO TBEquipmentOfCustomerDTO.
 */
@Mapper(componentModel = "spring", uses = {
    TBEquipmentMapper.class,
    TBCustomerMapper.class,
    TBEntityMapper.class,
    TBDetailUserMapper.class
})
public interface TBEquipmentOfCustomerMapper extends EntityMapper<TBEquipmentOfCustomerDTO, TBEquipmentOfCustomer> {

    @Mapping(source = "tbEquipment.id", target = "tbEquipmentId")
    @Mapping(source = "tbEquipment.name", target = "tbEquipmentName")
    @Mapping(source = "tbEntity.id", target = "tbEntityId")
    @Mapping(source = "tbCustomer.id", target = "tbCustomerId")
    @Mapping(source = "createdBy.id", target = "createdById")
    @Mapping(source = "modifiedBy.id", target = "modifiedById")
    @Mapping(source = "deletedBy.id", target = "deletedById")
    @Mapping(source = "tbEquipment.tbEquipmentType.name", target = "equipmentTypeName")
    @Mapping(source = "tbEquipment.tbEquipmentType.id", target = "equipmentTypeId")
    @Mapping(source = "tbEquipment.manufacturer", target = "manufacturer")
    @Mapping(source = "tbEquipment.sku", target = "sku")
    @Mapping(target = "location", ignore = true)
    TBEquipmentOfCustomerDTO toDto(TBEquipmentOfCustomer tBEquipmentOfCustomer);

    @Mapping(source = "tbCustomerId", target = "tbCustomer")
    @Mapping(source = "tbEquipmentId", target = "tbEquipment")
    @Mapping(source = "tbEntityId", target = "tbEntity")
    @Mapping(source = "createdById", target = "createdBy")
    @Mapping(source = "modifiedById", target = "modifiedBy")
    @Mapping(source = "deletedById", target = "deletedBy")
    TBEquipmentOfCustomer toEntity(TBEquipmentOfCustomerDTO tBEquipmentOfCustomerDTO);

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