package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

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

    @Mapping(source = "tbCity.id", target = "tbCityId")
    TBDistrictDTO toDto(TBDistrict tBDistrict);

    @Mapping(source = "tbCityId", target = "tbCity")
    TBDistrict toEntity(TBDistrictDTO tBDistrictDTO);

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