package ru.kayashov.bar.controller.dto.cocktail;

import lombok.Getter;
import lombok.Setter;
import ru.kayashov.bar.model.entity.CocktailEntity;

@Getter
@Setter
public class CocktailSimpleResponseDto {
    private Long id;
    private String name;
    private Boolean hasError;

    public static CocktailSimpleResponseDto mapToDto(CocktailEntity e) {
        CocktailSimpleResponseDto d = new CocktailSimpleResponseDto();
        d.setId(e.getId());
        d.setName(e.getName());
        boolean hasError = e.getReceipt().stream()
                .anyMatch(receiptEntity -> receiptEntity.getUnit() == null || receiptEntity.getCount() == null);
        d.setHasError(hasError);
        return d;
    }
}
