package vn.azteam.tpf.service.mapper;

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

import org.mapstruct.*;

/**
 * Mapper for the entity TBFunction and its DTO TBFunctionDTO.
 */
@Mapper(componentModel = "spring", uses = {TBFunctionGroupMapper.class})
public interface TBFunctionMapper extends EntityMapper<TBFunctionDTO, TBFunction> {

    @Mapping(source = "tbFunctionGroup.id", target = "tbFunctionGroupId")
    TBFunctionDTO toDto(TBFunction tBFunction);

    @Mapping(source = "tbFunctionGroupId", target = "tbFunctionGroup")
    TBFunction toEntity(TBFunctionDTO tBFunctionDTO);

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