Skip to content

Commit

Permalink
feat: implement get by genre
Browse files Browse the repository at this point in the history
  • Loading branch information
HyungJu committed Feb 12, 2024
1 parent cdb308f commit 6d131e9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ import kr.nagaza.nagazaserver.domain.model.CafeRoom

interface CafeRoomRepository {
fun getAllRoomByCafeId(cafeId: String): List<CafeRoom>

fun findByRoomId(roomId: String): CafeRoom?

fun getAllGenres(): List<String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ class CafeRoomService(
fun getRoomByRoomId(roomId: String): CafeRoom {
return cafeRoomRepository.findByRoomId(roomId) ?: throw CafeRoomNotFoundException()
}

fun getAllGenres(): List<String> {
return cafeRoomRepository.getAllGenres()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import org.springframework.stereotype.Repository
class CafeRoomRepositoryImpl(
private val jpaCafeRoomRepository: JpaCafeRoomRepository,
) : CafeRoomRepository {
override fun getAllGenres(): List<String> {
return jpaCafeRoomRepository.findAllGenres()
}

override fun getAllRoomByCafeId(cafeId: String): List<CafeRoom> {
return jpaCafeRoomRepository.findAllByCafeId(cafeId)
.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ package kr.nagaza.nagazaserver.infrastructure.jpa.repository

import kr.nagaza.nagazaserver.infrastructure.jpa.entity.CafeRoomEntity
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query

interface JpaCafeRoomRepository : JpaRepository<CafeRoomEntity, String> {
fun findAllByCafeId(cafeId: String): List<CafeRoomEntity>

@Query("SELECT DISTINCT cafe_room.genre FROM cafe_room")
fun findAllGenres(): List<String>
}

0 comments on commit 6d131e9

Please sign in to comment.