From 8bf27cf7be0391042b9a3e8b4470bbcaaa9cd544 Mon Sep 17 00:00:00 2001 From: dldmsql Date: Wed, 25 Sep 2024 00:02:52 +0900 Subject: [PATCH] =?UTF-8?q?fix:=204=EC=B0=A8=20MVP=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/board/controller/dto/BoardGetResponse.kt | 2 ++ .../domain/board/repository/BoardJooqRepositoryImpl.kt | 1 + .../domain/board/repository/vo/BoardGetOneVo.kt | 3 ++- .../ddd/sonnypolabobe/domain/board/service/BoardService.kt | 5 +++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/controller/dto/BoardGetResponse.kt b/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/controller/dto/BoardGetResponse.kt index 7c644c1..000fd5f 100644 --- a/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/controller/dto/BoardGetResponse.kt +++ b/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/controller/dto/BoardGetResponse.kt @@ -8,4 +8,6 @@ data class BoardGetResponse( val title: String, @field:Schema(description = "폴라로이드") val items: List, + @field:Schema(description = "작성자 여부", example = "true") + val isMine : Boolean ) \ No newline at end of file diff --git a/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/BoardJooqRepositoryImpl.kt b/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/BoardJooqRepositoryImpl.kt index c789736..79ba25e 100644 --- a/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/BoardJooqRepositoryImpl.kt +++ b/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/BoardJooqRepositoryImpl.kt @@ -53,6 +53,7 @@ class BoardJooqRepositoryImpl( .select( jBoard.ID.convertFrom { it?.let{UuidConverter.byteArrayToUUID(it) } }, jBoard.TITLE, + jBoard.USER_ID.`as`(BoardGetOneVo::ownerId.name), jPolaroid.ID.`as`(BoardGetOneVo::polaroidId.name), jPolaroid.IMAGE_KEY, jPolaroid.ONE_LINE_MESSAGE, diff --git a/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/vo/BoardGetOneVo.kt b/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/vo/BoardGetOneVo.kt index b178d79..b414708 100644 --- a/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/vo/BoardGetOneVo.kt +++ b/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/repository/vo/BoardGetOneVo.kt @@ -6,11 +6,12 @@ import java.util.UUID data class BoardGetOneVo( val id: UUID?, val title: String?, + val ownerId: Long?, val polaroidId : Long?, val imageKey : String?, val oneLineMessage: String?, val createdAt: LocalDateTime?, val userId : Long?, - val nickName: String?, + val nickname: String?, val options: String? ) diff --git a/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/service/BoardService.kt b/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/service/BoardService.kt index eff43dc..718dcc6 100644 --- a/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/service/BoardService.kt +++ b/src/main/kotlin/com/ddd/sonnypolabobe/domain/board/service/BoardService.kt @@ -32,6 +32,7 @@ class BoardService( return id.run { val queryResult = boardJooqRepository.selectOneById(UuidConverter.stringToUUID(this@run)) + if(queryResult.isEmpty()) throw ApplicationException(CustomErrorCode.BOARD_NOT_FOUND) val groupByTitle = queryResult.groupBy { it.title } groupByTitle.map { entry -> val title = entry.key @@ -41,14 +42,14 @@ class BoardService( imageUrl = it.imageKey?.let { it1 -> s3Util.getImgUrl(it1) } ?: "", oneLineMessage = it.oneLineMessage ?: "폴라보와의 추억 한 줄", userId = it.userId ?: 0L, - nickname = it.nickName ?: "", + nickname = it.nickname ?: "", isMine = it.userId == user?.id?.toLong(), createdAt = it.createdAt, options = it.options?.let{ ObjectMapper().readValue(it, object : TypeReference>() {})} ) }.filter { it.id != 0L }.distinctBy { it.id } - BoardGetResponse(title = title ?: "", items = polaroids) + BoardGetResponse(title = title ?: "", items = polaroids, isMine = queryResult.first().ownerId == user?.id?.toLong()) } } }