package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBMaintenanceDetails and its DTO TBMaintenanceDetailsDTO.
 */
@Mapper(componentModel = "spring", uses = {TBEquipmentOfCustomerMapper.class, TBMaintenanceScheduleMapper.class, TBDetailUserMapper.class})
public interface TBMaintenanceDetailsMapper extends EntityMapper<TBMaintenanceDetailsDTO, TBMaintenanceDetails> {

    @Mapping(source = "tbEquipmentOfCustomer.id", target = "tbEquipmentOfCustomerId")
    @Mapping(source = "tbMaintenanceSchedule.id", target = "tbMaintenanceScheduleId")
    @Mapping(source = "createdBy.id", target = "createdById")
    @Mapping(source = "modifiedBy.id", target = "modifiedById")
    @Mapping(source = "deletedBy.id", target = "deletedById")
    TBMaintenanceDetailsDTO toDto(TBMaintenanceDetails tBMaintenanceDetails);

    @Mapping(source = "tbEquipmentOfCustomerId", target = "tbEquipmentOfCustomer")
    @Mapping(source = "tbMaintenanceScheduleId", target = "tbMaintenanceSchedule")
    @Mapping(source = "createdById", target = "createdBy")
    @Mapping(source = "modifiedById", target = "modifiedBy")
    @Mapping(source = "deletedById", target = "deletedBy")
    TBMaintenanceDetails toEntity(TBMaintenanceDetailsDTO tBMaintenanceDetailsDTO);

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