package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBLimits and its DTO TBLimitsDTO.
 */
@Mapper(componentModel = "spring", uses = {TBGuidelineDetailsMapper.class, TBObjectParameterMapper.class, TBEnvironmentalParameterMapper.class})
public interface TBLimitsMapper extends EntityMapper<TBLimitsDTO, TBLimits> {

    @Mapping(source = "tbGuidelineDetails.id", target = "tbGuidelineDetailsId")
    @Mapping(source = "tbObjectParameter.id", target = "tbObjectParameterId")
    @Mapping(source = "tbEnvironmentalParameter.id", target = "tbEnvironmentalParameterId")
    @Mapping(source = "tbEnvironmentalParameter.name", target = "environmentName")
    @Mapping(source = "tbEnvironmentalParameter.unit", target = "environmentUnit")
    TBLimitsDTO toDto(TBLimits tBLimits);

    @Mapping(source = "tbGuidelineDetailsId", target = "tbGuidelineDetails")
    @Mapping(source = "tbObjectParameterId", target = "tbObjectParameter")
    @Mapping(source = "tbEnvironmentalParameterId", target = "tbEnvironmentalParameter")
    TBLimits toEntity(TBLimitsDTO tBLimitsDTO);

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