package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBSupplies and its DTO TBSuppliesDTO.
 */
@Mapper(componentModel = "spring", uses = {TBSuppliesTypeMapper.class, TBDetailUserMapper.class, TBCustomerMapper.class, TBGuidelineMapper.class})
public interface TBSuppliesMapper extends EntityMapper<TBSuppliesDTO, TBSupplies> {

    @Mapping(source = "tbSuppliesType.id", target = "tbSuppliesTypeId")
    @Mapping(source = "tbSuppliesType.name", target = "tbSuppliesTypeName")
    @Mapping(source = "tbSuppliesType.description", target = "tbSuppliesTypeDescription")
    @Mapping(target = "inventory", ignore = true)
    @Mapping(source = "createdBy.id", target = "createdById")
    @Mapping(source = "modifiedBy.id", target = "modifiedById")
    @Mapping(source = "deletedBy.id", target = "deletedById")
    @Mapping(source = "tbCustomer.id", target = "tbCustomerId")
    TBSuppliesDTO toDto(TBSupplies tBSupplies);

    @Mapping(source = "tbSuppliesTypeId", target = "tbSuppliesType")
    @Mapping(source = "createdById", target = "createdBy")
    @Mapping(source = "modifiedById", target = "modifiedBy")
    @Mapping(source = "deletedById", target = "deletedBy")
    @Mapping(source = "tbCustomerId", target = "tbCustomer")
    @Mapping(target = "tbGuidelines", ignore = true)
    TBSupplies toEntity(TBSuppliesDTO tBSuppliesDTO);

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