package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBEquipmentHistory and its DTO TBEquipmentHistoryDTO.
 */
@Mapper(componentModel = "spring", uses = {TBCommandMapper.class, TBEquipmentOfCustomerMapper.class, TBDetailUserMapper.class})
public interface TBEquipmentHistoryMapper extends EntityMapper<TBEquipmentHistoryDTO, TBEquipmentHistory> {

    @Mapping(source = "tbCommand.id", target = "tbCommandId")
    @Mapping(source = "tbDetailUser.id", target = "tbDetailUserId")
    @Mapping(source = "tbEquipmentOfCustomer.id", target = "tbEquipmentOfCustomerId")
    @Mapping(source = "tbEquipmentOfCustomer.name", target = "deviceName")
    @Mapping(source = "tbCommand.description", target = "tbCommandDescription")
    TBEquipmentHistoryDTO toDto(TBEquipmentHistory tBEquipmentHistory);

    @Mapping(source = "tbCommandId", target = "tbCommand")
    @Mapping(source = "tbDetailUserId", target = "tbDetailUser")
    @Mapping(source = "tbEquipmentOfCustomerId", target = "tbEquipmentOfCustomer")
    TBEquipmentHistory toEntity(TBEquipmentHistoryDTO tBEquipmentHistoryDTO);

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