package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBSuppliesUsingDetails and its DTO TBSuppliesUsingDetailsDTO.
 */
@Mapper(componentModel = "spring", uses = {TBSuppliesInWarehouseMapper.class,
                                            TBEquipmentOfCustomerMapper.class,
                                            TBActivityMapper.class,
                                            TBGuidelineActivityMapper.class,
                                            TBBlockDetailsMapper.class,
                                            TBEntityMapper.class,
                                            TBBlockDetailsMapper.class})
public interface TBSuppliesUsingDetailsMapper extends EntityMapper<TBSuppliesUsingDetailsDTO, TBSuppliesUsingDetails> {

    @Mapping(source = "tbSuppliesInWarehouse.id", target = "tbSuppliesInWarehouseId")
    @Mapping(source = "tbSuppliesInWarehouse.tbSupplies.name", target = "supplyName")
    @Mapping(source = "tbSuppliesInWarehouse.tbSupplies.unit", target = "supplyUnit")
    @Mapping(source = "tbEquipmentOfCustomer.id", target = "tbEquipmentOfCustomerId")
    @Mapping(source = "tbEquipmentOfCustomer.name", target = "equipmentName")
    @Mapping(source = "tbActivity.id", target = "tbActivityId")
    @Mapping(source = "tbGuidelineActivity.id", target = "tbGuidelineActivityId")
    @Mapping(source = "tbSuppliesInWarehouse.tbEntity.id", target = "tbEntityId")
    @Mapping(source = "tbSuppliesInWarehouse.tbEntity.name", target = "tbEntityName")
    @Mapping(source = "tbBlockDetails.id", target = "tbBlockDetailsId")
    @Mapping(source = "tbBlockDetails.code", target = "tbBlockDetailsCode")
    TBSuppliesUsingDetailsDTO toDto(TBSuppliesUsingDetails tBSuppliesUsingDetails);

    @Mapping(source = "tbBlockDetailsId", target = "tbBlockDetails")
    @Mapping(source = "tbSuppliesInWarehouseId", target = "tbSuppliesInWarehouse")
    @Mapping(source = "tbEquipmentOfCustomerId", target = "tbEquipmentOfCustomer")
    @Mapping(source = "tbActivityId", target = "tbActivity")
    @Mapping(source = "tbGuidelineActivityId", target = "tbGuidelineActivity")
    TBSuppliesUsingDetails toEntity(TBSuppliesUsingDetailsDTO tBSuppliesUsingDetailsDTO);

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