-
Notifications
You must be signed in to change notification settings - Fork 0
마이페이지 CRUD, 독서기록 CRUD, 모든 API 엑세스 토큰 적용, ENUM 정상화 #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
36f1a31
독서캘린더 조회api, 프로필 편집 api, 프로필 사진 편집api, 마이페이지 데이터 불러오기 api
icarus0616 7494ed4
엔티티 이넘 컬럼 리펙토링
icarus0616 22904fe
독서 캘린더api 완료
icarus0616 3c5afd1
모든 api 엑세스 토큰 화
icarus0616 d99bc15
Merge branch 'dev' of https://github.com/Project-BookLog/BookLog-Back…
icarus0616 9b094d8
Merge branch 'dev' of https://github.com/Project-BookLog/BookLog-Back…
icarus0616 7f2a807
Merge branch 'dev' of https://github.com/Project-BookLog/BookLog-Back…
icarus0616 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 37 additions & 63 deletions
100
...ain/java/com/example/booklog/domain/library/shelves/controller/ReadingLogsController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,134 +1,108 @@ | ||
| // ===================================== | ||
| // [독서기록] ReadingLogsController | ||
| // ===================================== | ||
| package com.example.booklog.domain.library.shelves.controller; | ||
|
|
||
| import com.example.booklog.domain.library.shelves.dto.ReadingLogResponse; | ||
| import com.example.booklog.domain.library.shelves.dto.ReadingLogSaveRequest; | ||
| import com.example.booklog.domain.library.shelves.service.ReadingLogsService; | ||
| import com.example.booklog.global.auth.security.CustomUserDetails; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.ExampleObject; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.parameters.RequestBody; | ||
| import io.swagger.v3.oas.annotations.media.*; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import io.swagger.v3.oas.annotations.Parameter.*; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.MediaType; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @Tag(name = "독서 기록", description = "독서 기록(날짜/읽은 페이지) 저장·수정·삭제 API") | ||
| @Tag(name = "독서 기록(Reading Logs)", description = "독서 기록 저장·수정·삭제 API") | ||
| @RestController | ||
| @RequiredArgsConstructor | ||
| public class ReadingLogsController { | ||
|
|
||
| private final ReadingLogsService readingLogsService; | ||
|
|
||
| @Operation( | ||
| summary = "독서 기록 저장", | ||
| summary = "독서 기록 저장(append)", | ||
| description = """ | ||
| 특정 저장 도서(userBookId)에 대해 독서 기록을 추가(append)합니다. | ||
| - UI 입력: readDate(읽은 날짜), pagesRead(그날 읽은 페이지 수) | ||
| - 서버 처리: currentPage(누적 현재 페이지)는 서버가 계산하여 저장하며, | ||
| user_books.current_page/progress_percent 등의 최신 상태도 함께 갱신됩니다. | ||
| - 인증: Access Token(Bearer) | ||
| - 입력: readDate(날짜), pagesRead(그날 읽은 페이지 수) | ||
| - 처리: 누적 currentPage는 서버 계산, user_books 최신상태 함께 갱신 | ||
| """ | ||
| ) | ||
| @ApiResponse(responseCode = "200", description = "저장 성공", | ||
| content = @Content(schema = @Schema(implementation = ReadingLogResponse.class))) | ||
| @ApiResponse(responseCode = "400", description = "요청값 오류/저장 도서 없음", content = @Content) | ||
| @ApiResponse(responseCode = "401", description = "인증 실패", content = @Content) | ||
| @PostMapping(value = "/api/v1/user-books/{userBookId}/reading-logs", consumes = MediaType.APPLICATION_JSON_VALUE) | ||
| public ReadingLogResponse create( | ||
| @Parameter(name = "X-USER-ID", description = "유저 식별자(필수)", required = true, example = "1") | ||
| @RequestHeader("X-USER-ID") Long userId, | ||
|
|
||
| @Parameter(description = "저장 도서 ID(user_books.user_book_id)", required = true, example = "101") | ||
| @AuthenticationPrincipal CustomUserDetails userDetails, | ||
| @PathVariable Long userBookId, | ||
|
|
||
| @RequestBody( | ||
| //스웨거(OpenAPI 문서용) RequestBody | ||
| @io.swagger.v3.oas.annotations.parameters.RequestBody( | ||
| required = true, | ||
| description = "독서 기록 저장 요청", | ||
| content = @Content( | ||
| schema = @Schema(implementation = ReadingLogSaveRequest.class), | ||
| examples = { | ||
| @ExampleObject( | ||
| name = "기본 예시", | ||
| summary = "특정 날짜에 57페이지 읽음", | ||
| value = """ | ||
| { | ||
| "readDate": "2026-01-10", | ||
| "pagesRead": 57 | ||
| } | ||
| """ | ||
| ) | ||
| } | ||
| examples = @ExampleObject( | ||
| name = "기본 예시", | ||
| summary = "특정 날짜에 57페이지 읽음", | ||
| value = """ | ||
| { | ||
| "readDate": "2026-01-10", | ||
| "pagesRead": 57 | ||
| } | ||
| """ | ||
| ) | ||
| ) | ||
| ) | ||
| @org.springframework.web.bind.annotation.RequestBody @Valid ReadingLogSaveRequest req | ||
| ) { | ||
| return readingLogsService.create(userId, userBookId, req); | ||
| return readingLogsService.create(userDetails.getUserId(), userBookId, req); | ||
| } | ||
|
|
||
| @Operation( | ||
| summary = "독서 기록 수정", | ||
| description = """ | ||
| 특정 독서 기록(logId)의 날짜/읽은 페이지를 수정합니다. | ||
| - UI 입력: readDate, pagesRead | ||
| - 서버 처리: 중간 기록 수정 시 누적 currentPage가 연쇄 변경될 수 있어, | ||
| 해당 userBook의 로그들을 기준으로 currentPage/user_books 상태를 재계산합니다. | ||
| - 인증: Access Token(Bearer) | ||
| - 처리: 중간 기록 수정 시 누적값이 연쇄 변경될 수 있어 user_books 상태 재계산 | ||
| """ | ||
| ) | ||
| @ApiResponse(responseCode = "200", description = "수정 성공", | ||
| content = @Content(schema = @Schema(implementation = ReadingLogResponse.class))) | ||
| @ApiResponse(responseCode = "404", description = "독서 기록 없음/권한 없음", content = @Content) | ||
| @ApiResponse(responseCode = "401", description = "인증 실패", content = @Content) | ||
| @PatchMapping(value = "/api/v1/reading-logs/{logId}", consumes = MediaType.APPLICATION_JSON_VALUE) | ||
| public ReadingLogResponse update( | ||
| @Parameter(name = "X-USER-ID", description = "유저 식별자(필수)", required = true, example = "1") | ||
| @RequestHeader("X-USER-ID") Long userId, | ||
|
|
||
| @Parameter(description = "독서 기록 ID(reading_logs.log_id)", required = true, example = "5001") | ||
| @AuthenticationPrincipal CustomUserDetails userDetails, | ||
| @PathVariable Long logId, | ||
|
|
||
| @RequestBody( | ||
| required = true, | ||
| description = "독서 기록 수정 요청", | ||
| content = @Content( | ||
| schema = @Schema(implementation = ReadingLogSaveRequest.class), | ||
| examples = { | ||
| @ExampleObject( | ||
| name = "수정 예시", | ||
| summary = "페이지 수를 80으로 수정", | ||
| value = """ | ||
| { | ||
| "readDate": "2026-01-10", | ||
| "pagesRead": 80 | ||
| } | ||
| """ | ||
| ) | ||
| } | ||
| ) | ||
| ) | ||
| @org.springframework.web.bind.annotation.RequestBody @Valid ReadingLogSaveRequest req | ||
| ) { | ||
| return readingLogsService.update(userId, logId, req); | ||
| return readingLogsService.update(userDetails.getUserId(), logId, req); | ||
| } | ||
|
|
||
| @Operation( | ||
| summary = "독서 기록 삭제", | ||
| description = """ | ||
| 특정 독서 기록(logId)을 삭제합니다. | ||
| - 서버 처리: 삭제 후 해당 userBook의 로그 기반으로 user_books 최신상태를 재계산합니다. | ||
| - 인증: Access Token(Bearer) | ||
| - 처리: 삭제 후 해당 userBook 로그 기반으로 user_books 최신상태 재계산 | ||
| """ | ||
| ) | ||
| @ApiResponse(responseCode = "204", description = "삭제 성공", content = @Content) | ||
| @ApiResponse(responseCode = "404", description = "독서 기록 없음/권한 없음", content = @Content) | ||
| @ApiResponse(responseCode = "401", description = "인증 실패", content = @Content) | ||
| @DeleteMapping("/api/v1/reading-logs/{logId}") | ||
| @ResponseStatus(org.springframework.http.HttpStatus.NO_CONTENT) | ||
| public void delete( | ||
| @Parameter(name = "X-USER-ID", description = "유저 식별자(필수)", required = true, example = "1") | ||
| @RequestHeader("X-USER-ID") Long userId, | ||
|
|
||
| @Parameter(description = "독서 기록 ID(reading_logs.log_id)", required = true, example = "5001") | ||
| @AuthenticationPrincipal CustomUserDetails userDetails, | ||
| @PathVariable Long logId | ||
| ) { | ||
| readingLogsService.delete(userId, logId); | ||
| readingLogsService.delete(userDetails.getUserId(), logId); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid or unused import statement.
io.swagger.v3.oas.annotations.Parameteris an annotation type, not a class with nested members. The wildcard importParameter.*is syntactically incorrect for annotations and this import doesn't appear to be used anywhere in the file.🔧 Suggested fix
-import io.swagger.v3.oas.annotations.Parameter.*;If you intended to use
@Parameterannotation for path variables, the correct import would be:🤖 Prompt for AI Agents