Skip to content

Commit 01915f9

Browse files
committed
update: findByStageId -> findByStageIdAndCategory
1 parent f78a206 commit 01915f9

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/main/kotlin/gogo/gogostage/domain/community/root/application/CommunityReader.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class CommunityReader(
2020
private val commentReader: CommentReader
2121
) {
2222

23-
fun readByStageId(stageId: Long) =
24-
communityRepository.findByStageId(stageId)
25-
?: throw StageException("Stage Not Found, stageId=$stageId", HttpStatus.NOT_FOUND.value())
23+
fun readByStageIdAndGameCategory(stageId: Long, gameCategory: GameCategory) =
24+
communityRepository.findByStageIdAndCategory(stageId, gameCategory)
25+
?: throw StageException("Stage Not Found, stageId=$stageId gameCategory=$gameCategory", HttpStatus.NOT_FOUND.value())
2626

2727
fun readBoards(stageId: Long, page: Int, size: Int, category: GameCategory?, sort: SortType): GetCommunityBoardResDto {
2828
val pageRequest = PageRequest.of(page, size)

src/main/kotlin/gogo/gogostage/domain/community/root/application/CommunityServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CommunityServiceImpl(
2020
@Transactional
2121
override fun writeCommunityBoard(stageId: Long, writeCommunityBoardDto: WriteCommunityBoardDto) {
2222
val student = userUtil.getCurrentStudent()
23-
val community = communityReader.readByStageId(stageId)
23+
val community = communityReader.readByStageIdAndGameCategory(stageId, writeCommunityBoardDto.gameCategory)
2424
boardProcessor.saveCommunityBoard(community, student.studentId, writeCommunityBoardDto)
2525

2626
// 추후 욕설 필터링 요청 처리 필요
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package gogo.gogostage.domain.community.root.persistence
22

3+
import gogo.gogostage.domain.game.persistence.GameCategory
34
import org.springframework.data.jpa.repository.JpaRepository
45

56
interface CommunityRepository : JpaRepository<Community, Long>, CommunityCustomRepository {
6-
fun findByStageId(stageId: Long): Community?
7+
fun findByStageIdAndCategory(stageId: Long, gameCategory: GameCategory): Community?
78
}

0 commit comments

Comments
 (0)