package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;
/**
 * Mapper for the entity TBBlockDetails and its DTO TBBlockDetailsDTO.
 */
@Mapper(componentModel = "spring", uses = {TBSuppliesInWarehouseMapper.class, TBEntityMapper.class, TBSuppliesMapper.class})
public interface TBBlockDetailsMapper extends EntityMapper<TBBlockDetailsDTO, TBBlockDetails> {

    @Mapping(source = "tbSuppliesInWarehouse.id", target = "tbSuppliesInWarehouseId")
    @Mapping(source = "tbSuppliesInWarehouse.tbEntity.id", target = "tbEntityId")
    @Mapping(source = "tbSuppliesInWarehouse.tbEntity.name", target = "tbEntityName")
    @Mapping(source = "tbSuppliesInWarehouse.tbSupplies.id", target = "tbSuppliesId")
    @Mapping(source = "tbSuppliesInWarehouse.tbSupplies.unit", target = "tbSuppliesUnit")
    TBBlockDetailsDTO toDto(TBBlockDetails tbBlockDetails);

    @Mapping(source = "tbSuppliesInWarehouseId", target = "tbSuppliesInWarehouse")
    TBBlockDetails toEntity(TBBlockDetailsDTO tbBlockDetailsDTO);

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