package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBCity and its DTO TBCityDTO.
 */
@Mapper(componentModel = "spring", uses = {TBCountryMapper.class})
public interface TBCityMapper extends EntityMapper<TBCityDTO, TBCity> {

    @Mapping(source = "tbCountry.id", target = "tbCountryId")
    TBCityDTO toDto(TBCity tBCity);

    @Mapping(source = "tbCountryId", target = "tbCountry")
    TBCity toEntity(TBCityDTO tBCityDTO);

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