Fixed image repository query and call
This commit is contained in:
parent
7544b3ddc0
commit
3ba35d33ec
@ -39,7 +39,7 @@ class ImageController
|
|||||||
val page = PageRequest.of(pageNumber - 1, 20)
|
val page = PageRequest.of(pageNumber - 1, 20)
|
||||||
if (tags != null) {
|
if (tags != null) {
|
||||||
val tagData = tags.mapNotNull { tagRepository.findByTagIs(it) }
|
val tagData = tags.mapNotNull { tagRepository.findByTagIs(it) }
|
||||||
val images = imageRepository.findByTagsIsContaining(tagData, page)
|
val images = imageRepository.findByTags(tagData, page)
|
||||||
model.addAttribute("images", images)
|
model.addAttribute("images", images)
|
||||||
} else { // If no tag data supplied, just return all images
|
} else { // If no tag data supplied, just return all images
|
||||||
val images = imageRepository.findAll(page)
|
val images = imageRepository.findAll(page)
|
||||||
|
@ -3,6 +3,7 @@ package uk.co.neviyn.booru
|
|||||||
import org.springframework.data.domain.Page
|
import org.springframework.data.domain.Page
|
||||||
import org.springframework.data.domain.Pageable
|
import org.springframework.data.domain.Pageable
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
|
import org.springframework.data.jpa.repository.Query
|
||||||
import org.springframework.data.repository.CrudRepository
|
import org.springframework.data.repository.CrudRepository
|
||||||
|
|
||||||
interface UserRepository : CrudRepository<User, Long> {
|
interface UserRepository : CrudRepository<User, Long> {
|
||||||
@ -12,7 +13,8 @@ interface UserRepository : CrudRepository<User, Long> {
|
|||||||
interface RoleRepository : CrudRepository<Role, Long>
|
interface RoleRepository : CrudRepository<Role, Long>
|
||||||
|
|
||||||
interface ImageRepository : JpaRepository<Image, Long> {
|
interface ImageRepository : JpaRepository<Image, Long> {
|
||||||
fun findByTagsIsContaining(tags: List<Tag>, pageable: Pageable) : Page<Image>
|
@Query("select i from Image i where ?1 in (i.tags)")
|
||||||
|
fun findByTags(tags: List<Tag>, pageable: Pageable) : Page<Image>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TagRepository : CrudRepository<Tag, Long> {
|
interface TagRepository : CrudRepository<Tag, Long> {
|
||||||
|
Loading…
Reference in New Issue
Block a user