package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

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

    @Mapping(source = "tbEquipmentType.id", target = "tbEquipmentTypeId")
    @Mapping(source = "tbEquipmentType.name", target = "tbEquipmentTypeName")
    @Mapping(target = "inventory", ignore = true)
    @Mapping(target = "guide", ignore = true)
    @Mapping(target = "guideDel", ignore = true)
    @Mapping(source = "createdBy.id", target = "createdById")
    @Mapping(source = "modifiedBy.id", target = "modifiedById")
    @Mapping(source = "deletedBy.id", target = "deletedById")
    @Mapping(source = "tbCustomer.id", target = "tbCustomerId")
    TBEquipmentDTO toDto(TBEquipment tBEquipment);

    @Mapping(source = "tbEquipmentTypeId", target = "tbEquipmentType")
    @Mapping(source = "createdById", target = "createdBy")
    @Mapping(source = "modifiedById", target = "modifiedBy")
    @Mapping(source = "deletedById", target = "deletedBy")
    @Mapping(source = "tbCustomerId", target = "tbCustomer")
    TBEquipment toEntity(TBEquipmentDTO tBEquipmentDTO);

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