package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBEnvironmentUpdate and its DTO TBEnvironmentUpdateDTO.
 */
@Mapper(componentModel = "spring", uses = {TBEnvironmentalParameterMapper.class, TBActivityMapper.class, TBEquipmentOfCustomerMapper.class})
public interface TBEnvironmentUpdateMapper extends EntityMapper<TBEnvironmentUpdateDTO, TBEnvironmentUpdate> {

    @Mapping(source = "tbEnvironmentalParameter.id", target = "tbEnvironmentalId")
    @Mapping(source = "tbEnvironmentalParameter.name", target = "tbEnvironmentalName")
    @Mapping(source = "tbEnvironmentalParameter.unit", target = "tbEnvironmentalUnit")
    @Mapping(source = "tbEnvironmentalParameter.description", target = "tbEnvironmentalDescription")
    @Mapping(source = "tbActivity.id", target = "tbActivityId")
    @Mapping(source = "tbEquipmentOfCustomer.id", target = "tbEquipmentOfCustomerId")
    @Mapping(source = "tbEquipmentOfCustomer.name", target = "tbEquipmentOfCustomerName")
    TBEnvironmentUpdateDTO toDto(TBEnvironmentUpdate tBEnvironmentUpdate);

    @Mapping(source = "tbEnvironmentalId", target = "tbEnvironmentalParameter")
    @Mapping(source = "tbActivityId", target = "tbActivity")
    @Mapping(source = "tbEquipmentOfCustomerId", target = "tbEquipmentOfCustomer")
    TBEnvironmentUpdate toEntity(TBEnvironmentUpdateDTO tBEnvironmentUpdateDTO);

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