File tree Expand file tree Collapse file tree 4 files changed +64
-0
lines changed
apis/src/main/kotlin/org/yapp/apis/readingrecord Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff 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 = " 사용자의 책에 대한 독서 기록을 페이징하여 조회합니다. 정렬은 페이지 번호 또는 최신 등록순으로 가능합니다."
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import org.springframework.stereotype.Service
66import org.yapp.apis.book.service.UserBookService
77import org.yapp.apis.readingrecord.dto.request.CreateReadingRecordRequest
88import org.yapp.apis.readingrecord.dto.response.ReadingRecordResponse
9+ import org.yapp.apis.readingrecord.exception.ReadingRecordErrorCode
10+ import org.yapp.apis.readingrecord.exception.ReadingRecordNotFoundException
911import org.yapp.domain.book.BookDomainService
1012import org.yapp.domain.readingrecord.ReadingRecordDomainService
1113import 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 ,
Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments