Skip to content

Commit 2ef17c7

Browse files
committed
[BOOK-201] feat: apis - 독서기록상세조회 API개발 (#67)
1 parent f85d13e commit 2ef17c7

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

apis/src/main/kotlin/org/yapp/apis/readingrecord/controller/ReadingRecordController.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ class ReadingRecordController(
4141
return ResponseEntity.status(HttpStatus.CREATED).body(response)
4242
}
4343

44+
@GetMapping("/detail/{readingRecordId}")
45+
override fun getReadingRecordDetail(
46+
@AuthenticationPrincipal userId: UUID,
47+
@PathVariable readingRecordId: UUID
48+
): ResponseEntity<ReadingRecordResponse> {
49+
val response = readingRecordUseCase.getReadingRecordDetail(
50+
userId = userId,
51+
readingRecordId = readingRecordId
52+
)
53+
return ResponseEntity.ok(response)
54+
}
55+
4456
@GetMapping("/{userBookId}")
4557
override fun getReadingRecords(
4658
@AuthenticationPrincipal userId: UUID,

apis/src/main/kotlin/org/yapp/apis/readingrecord/controller/ReadingRecordControllerApi.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,30 @@ interface ReadingRecordControllerApi {
6060
@Valid @RequestBody @Parameter(description = "독서 기록 생성 요청 객체") request: CreateReadingRecordRequest
6161
): ResponseEntity<ReadingRecordResponse>
6262

63+
@Operation(
64+
summary = "독서 기록 상세 조회",
65+
description = "독서 기록 ID로 독서 기록 상세 정보를 조회합니다."
66+
)
67+
@ApiResponses(
68+
value = [
69+
ApiResponse(
70+
responseCode = "200",
71+
description = "독서 기록 상세 조회 성공",
72+
content = [Content(schema = Schema(implementation = ReadingRecordResponse::class))]
73+
),
74+
ApiResponse(
75+
responseCode = "404",
76+
description = "사용자 또는 독서 기록을 찾을 수 없음",
77+
content = [Content(schema = Schema(implementation = ErrorResponse::class))]
78+
)
79+
]
80+
)
81+
@GetMapping("/detail/{readingRecordId}")
82+
fun getReadingRecordDetail(
83+
@AuthenticationPrincipal @Parameter(description = "인증된 사용자 ID") userId: UUID,
84+
@PathVariable @Parameter(description = "조회할 독서 기록 ID") readingRecordId: UUID
85+
): ResponseEntity<ReadingRecordResponse>
86+
6387
@Operation(
6488
summary = "독서 기록 목록 조회",
6589
description = "사용자의 책에 대한 독서 기록을 페이징하여 조회합니다. 정렬은 페이지 번호 또는 최신 등록순으로 가능합니다."

apis/src/main/kotlin/org/yapp/apis/readingrecord/service/ReadingRecordService.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import org.springframework.stereotype.Service
66
import org.yapp.apis.book.service.UserBookService
77
import org.yapp.apis.readingrecord.dto.request.CreateReadingRecordRequest
88
import org.yapp.apis.readingrecord.dto.response.ReadingRecordResponse
9+
import org.yapp.apis.readingrecord.exception.ReadingRecordErrorCode
10+
import org.yapp.apis.readingrecord.exception.ReadingRecordNotFoundException
911
import org.yapp.domain.book.BookDomainService
1012
import org.yapp.domain.readingrecord.ReadingRecordDomainService
1113
import org.yapp.domain.readingrecord.ReadingRecordSortType
@@ -38,6 +40,20 @@ class ReadingRecordService(
3840
return ReadingRecordResponse.from(readingRecordInfoVO)
3941
}
4042

43+
fun getReadingRecordDetail(
44+
userId: UUID,
45+
readingRecordId: UUID
46+
): ReadingRecordResponse {
47+
val readingRecordInfoVO = readingRecordDomainService.findReadingRecordById(readingRecordId)
48+
?: throw ReadingRecordNotFoundException(
49+
ReadingRecordErrorCode.READING_RECORD_NOT_FOUND,
50+
"Reading record not found with id: $readingRecordId"
51+
)
52+
53+
userBookService.validateUserBookExists(userId, readingRecordInfoVO.userBookId.value)
54+
55+
return ReadingRecordResponse.from(readingRecordInfoVO)
56+
}
4157

4258
fun getReadingRecordsByDynamicCondition(
4359
userBookId: UUID,

apis/src/main/kotlin/org/yapp/apis/readingrecord/usecase/ReadingRecordUseCase.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ class ReadingRecordUseCase(
4242
)
4343
}
4444

45+
fun getReadingRecordDetail(
46+
userId: UUID,
47+
readingRecordId: UUID
48+
): ReadingRecordResponse {
49+
userAuthService.validateUserExists(userId)
50+
51+
return readingRecordService.getReadingRecordDetail(
52+
userId = userId,
53+
readingRecordId = readingRecordId
54+
)
55+
}
56+
4557
fun getReadingRecordsByUserBookId(
4658
userId: UUID,
4759
userBookId: UUID,

0 commit comments

Comments
 (0)