package de.ph87.isabell_und_timo.picture;

import lombok.NonNull;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.ListCrudRepository;

import java.util.List;
import java.util.Optional;

public interface PictureRepository extends ListCrudRepository<Picture, String> {

  @NonNull
  @Query("select new de.ph87.isabell_und_timo.picture.PictureDto(p) from Picture p")
  List<PictureDto> findAllDto();

  @NonNull
  @Query("select new de.ph87.isabell_und_timo.picture.PictureDto(p) from Picture p where p.visible = true")
  List<PictureDto> findAllDtoByVisibleTrue();

  @NonNull
  @Query("select new de.ph87.isabell_und_timo.picture.PictureInternal(p) from Picture p where p.uuid = :uuid")
  Optional<PictureInternal> findDtoByUuid(@NonNull String uuid);

}
