Skip to content
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

[Feature] 사용자 서재 전체 조회 API 추가 #122

Merged
merged 11 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/docs/asciidoc/api/library/library.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
=== 서재 조회
==== HTTP Request
include::{snippets}/library/get/http-request.adoc[]

==== HTTP Response
include::{snippets}/library/get/http-response.adoc[]
include::{snippets}/library/get/response-fields.adoc[]

=== 서재 생성
==== HTTP Request
include::{snippets}/library/create/http-request.adoc[]
===== Request Body
include::{snippets}/library/create/request-body.adoc[]
include::{snippets}/library/create/request-fields.adoc[]

==== HTTP Response
include::{snippets}/library/create/http-response.adoc[]
include::{snippets}/library/create/response-fields.adoc[]

=== 서재 수정
==== HTTP Request
include::{snippets}/library/edit/http-request.adoc[]
===== Request Body
include::{snippets}/library/edit/request-body.adoc[]
include::{snippets}/library/edit/request-fields.adoc[]

==== HTTP Response
include::{snippets}/library/edit/http-response.adoc[]
include::{snippets}/library/edit/response-fields.adoc[]

=== 서재 삭제
==== HTTP Request
include::{snippets}/library/delete/http-request.adoc[]

==== HTTP Response
include::{snippets}/library/delete/http-response.adoc[]
include::{snippets}/library/delete/response-fields.adoc[]

=== 독서 상태 페이지 조회
==== HTTP Request
include::{snippets}/library/get-status/http-request.adoc[]
include::{snippets}/library/get-status/query-parameters.adoc[]

==== HTTP Response
include::{snippets}/library/get-status/http-response.adoc[]
include::{snippets}/library/get-status/response-fields.adoc[]
9 changes: 9 additions & 0 deletions src/docs/asciidoc/api/review/review.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ include::{snippets}/review/get-related-book/query-parameters.adoc[]
include::{snippets}/review/get-related-book/http-response.adoc[]
include::{snippets}/review/get-related-book/response-fields.adoc[]

=== 도서와 연관된 리뷰 개수 조회
==== HTTP Request
include::{snippets}/review/get-related-book-count/http-request.adoc[]
include::{snippets}/review/get-related-book-count/path-parameters.adoc[]

==== HTTP Response
include::{snippets}/review/get-related-book-count/http-response.adoc[]
include::{snippets}/review/get-related-book-count/response-fields.adoc[]

=== 한줄평 생성

==== HTTP Request
Expand Down
74 changes: 0 additions & 74 deletions src/docs/asciidoc/api/userlibrary/userlibrary.adoc

This file was deleted.

6 changes: 3 additions & 3 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ include::api/book/book.adoc[]
== User API
include::api/user/user.adoc[]

[[UserLibrary-API]]
== UserLibrary API
include::api/userlibrary/userlibrary.adoc[]
[[Library-API]]
== Library API
include::api/library/library.adoc[]

[[Rating-API]]
== Rating API
Expand Down
59 changes: 59 additions & 0 deletions src/main/java/com/jisungin/api/library/LibraryController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.jisungin.api.library;

import com.jisungin.api.ApiResponse;
import com.jisungin.api.library.request.LibraryCreateRequest;
import com.jisungin.api.library.request.LibraryEditRequest;
import com.jisungin.api.support.Auth;
import com.jisungin.application.library.LibraryService;
import com.jisungin.application.library.response.LibraryResponse;
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/v1")
public class LibraryController {

private final LibraryService libraryService;

@GetMapping("/libraries")
public ApiResponse<List<LibraryResponse>> findLibraries(@Auth Long userId) {
return ApiResponse.ok(libraryService.findLibraries(userId));
}

@PostMapping("/libraries")
public ApiResponse<LibraryResponse> createLibrary(@Valid @RequestBody LibraryCreateRequest request,
@Auth Long userId
) {
return ApiResponse.ok(libraryService.createLibrary(request.toServiceRequest(), userId));
}

@PatchMapping("/libraries/{libraryId}")
public ApiResponse<Void> editLibrary(@PathVariable("libraryId") Long libraryId,
@Valid @RequestBody LibraryEditRequest request,
@Auth Long userId
) {
libraryService.editLibrary(libraryId, userId, request.toServiceRequest());

return ApiResponse.ok();
}

@DeleteMapping("/libraries/{libraryId}")
public ApiResponse<Void> deleteLibrary(@PathVariable("libraryId") Long libraryId,
@Auth Long userId
) {
libraryService.deleteLibrary(libraryId, userId);

return ApiResponse.ok();
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.jisungin.api.userlibrary.request;
package com.jisungin.api.library.request;

import com.jisungin.application.userlibrary.request.UserLibraryEditServiceRequest;
import com.jisungin.application.library.request.LibraryCreateServiceRequest;
import jakarta.validation.constraints.NotBlank;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class UserLibraryEditRequest {
public class LibraryCreateRequest {

@NotBlank(message = "책 isbn 입력은 필수 입니다.")
private String isbn;
Expand All @@ -17,13 +17,13 @@ public class UserLibraryEditRequest {
private String readingStatus;

@Builder
private UserLibraryEditRequest(String isbn, String readingStatus) {
private LibraryCreateRequest(String isbn, String readingStatus) {
this.isbn = isbn;
this.readingStatus = readingStatus;
}

public UserLibraryEditServiceRequest toServiceRequest() {
return UserLibraryEditServiceRequest.builder()
public LibraryCreateServiceRequest toServiceRequest() {
return LibraryCreateServiceRequest.builder()
.isbn(isbn)
.readingStatus(readingStatus)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.jisungin.api.userlibrary.request;
package com.jisungin.api.library.request;

import com.jisungin.application.userlibrary.request.UserLibraryCreateServiceRequest;
import com.jisungin.application.library.request.LibraryEditServiceRequest;
import jakarta.validation.constraints.NotBlank;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class UserLibraryCreateRequest {
public class LibraryEditRequest {

@NotBlank(message = "책 isbn 입력은 필수 입니다.")
private String isbn;
Expand All @@ -17,13 +17,13 @@ public class UserLibraryCreateRequest {
private String readingStatus;

@Builder
private UserLibraryCreateRequest(String isbn, String readingStatus) {
private LibraryEditRequest(String isbn, String readingStatus) {
this.isbn = isbn;
this.readingStatus = readingStatus;
}

public UserLibraryCreateServiceRequest toServiceRequest() {
return UserLibraryCreateServiceRequest.builder()
public LibraryEditServiceRequest toServiceRequest() {
return LibraryEditServiceRequest.builder()
.isbn(isbn)
.readingStatus(readingStatus)
.build();
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/jisungin/api/review/ReviewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public ApiResponse<SliceResponse<ReviewWithRatingResponse>> findBookReviews(
return ApiResponse.ok(reviewService.findBookReviews(isbn, OffsetLimit.of(page, size, order)));
}

@GetMapping("/books/{isbn}/reviews/count")
public ApiResponse<Long> findBookReviewsCount(@PathVariable String isbn) {
return ApiResponse.ok(reviewService.findBookReviewsCount(isbn));
}

@PostMapping("/reviews")
public ApiResponse<Void> createReview(@Valid @RequestBody ReviewCreateRequest request,
@Auth Long userId) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jisungin/api/user/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.jisungin.application.review.response.ReviewContentGetAllResponse;
import com.jisungin.application.user.UserService;
import com.jisungin.application.user.response.UserInfoResponse;
import com.jisungin.application.userlibrary.response.UserReadingStatusResponse;
import com.jisungin.application.library.response.UserReadingStatusResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.jisungin.application.user.request.UserReadingStatusGetAllServiceRequest;
import com.jisungin.domain.ReadingStatus;
import com.jisungin.domain.userlibrary.ReadingStatusOrderType;
import com.jisungin.domain.library.ReadingStatusOrderType;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down

This file was deleted.

Loading
Loading