package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

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

    @Mapping(source = "tbDistrict.id", target = "tbDistrictId")
    TBWardDTO toDto(TBWard tBWard);

    @Mapping(source = "tbDistrictId", target = "tbDistrict")
    TBWard toEntity(TBWardDTO tBWardDTO);

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