package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBGuidelineDetails and its DTO TBGuidelineDetailsDTO.
 */
@Mapper(componentModel = "spring", uses = {TBGuidelineMapper.class, TBGuidelinePeriodMapper.class})
public interface TBGuidelineDetailsMapper extends EntityMapper<TBGuidelineDetailsDTO, TBGuidelineDetails> {

    @Mapping(source = "tbGuideline.id", target = "tbGuidelineId")
    @Mapping(source = "tbGuidelinePeriod.id", target = "tbGuidelinePeriodId")
    @Mapping(source = "tbGuideline.tbCustomer.id", target = "tbCustomerId")
    @Mapping(source = "tbGuidelinePeriod.name", target = "tbGuidelinePeriodName")
    TBGuidelineDetailsDTO toDto(TBGuidelineDetails tBGuidelineDetails);

    @Mapping(source = "tbGuidelineId", target = "tbGuideline")
    @Mapping(source = "tbGuidelinePeriodId", target = "tbGuidelinePeriod")
    TBGuidelineDetails toEntity(TBGuidelineDetailsDTO tBGuidelineDetailsDTO);

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