1
2
3
4
5
6
7 package org.tailormap.api.repository;
8
9 import java.time.OffsetDateTime;
10 import java.util.List;
11 import java.util.Optional;
12 import java.util.UUID;
13 import org.springframework.data.jpa.repository.EntityGraph;
14 import org.springframework.data.jpa.repository.JpaRepository;
15 import org.springframework.data.jpa.repository.Query;
16 import org.springframework.lang.NonNull;
17 import org.springframework.security.access.prepost.PreAuthorize;
18 import org.tailormap.api.persistence.Upload;
19
20 public interface UploadRepository extends JpaRepository<Upload, UUID> {
21 @PreAuthorize("permitAll()")
22 @NonNull
23 @Query("select lastModified from Upload where id = :id")
24 Optional<OffsetDateTime> findLastModifiedById(@NonNull UUID id);
25
26 @PreAuthorize("permitAll()")
27 @NonNull
28 Optional<Upload> findByIdAndCategory(@NonNull UUID id, @NonNull String category);
29
30 @PreAuthorize("permitAll()")
31 @NonNull
32 @EntityGraph(attributePaths = {"content"})
33 Optional<Upload> findWithContentByIdAndCategory(@NonNull UUID id, @NonNull String category);
34
35 @PreAuthorize(value = "permitAll()")
36 List<Upload> findByCategory(String category);
37 }