package com.bares.service.mapper;

import com.bares.domain.*;
import com.bares.service.dto.CategoriaDTO;

import org.mapstruct.*;

/**
 * Mapper for the entity Categoria and its DTO CategoriaDTO.
 */
@Mapper(componentModel = "spring", uses = {BarMapper.class})
public interface CategoriaMapper extends EntityMapper<CategoriaDTO, Categoria> {

    @Mapping(source = "bar.id", target = "barId")
    @Mapping(source = "bar.nombre", target = "barNombre")
    CategoriaDTO toDto(Categoria categoria);

    @Mapping(source = "barId", target = "bar")
    Categoria toEntity(CategoriaDTO categoriaDTO);

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