Skip to content

Commit

Permalink
Merge pull request #252 from Yanol-Market/feature/product-rest-docs
Browse files Browse the repository at this point in the history
docs: product api 명세
  • Loading branch information
yurim0628 authored Jan 30, 2024
2 parents e31c1f2 + 1bece46 commit 1a2bfd4
Show file tree
Hide file tree
Showing 7 changed files with 376 additions and 33 deletions.
4 changes: 4 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,7 @@ Golden-Ticket API adheres as closely as possible to standard HTTP and REST conve
= 사용자 기능

include::user.adoc[]

= 상품 기능

include::product.adoc[]
69 changes: 69 additions & 0 deletions src/docs/asciidoc/product.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
== 상품 상세 조회

=== HTTP request
include::{snippets}/products-details/http-request.adoc[]

=== HTTP response fields
include::{snippets}/products-details/response-fields.adoc[]

=== HTTP response
include::{snippets}/products-details/http-response.adoc[]

== 상품 수정

=== HTTP request fields
include::{snippets}/products-update/request-fields.adoc[]

=== HTTP request
include::{snippets}/products-update/http-request.adoc[]

=== HTTP response fields
include::{snippets}/products-update/response-fields.adoc[]

=== HTTP response
include::{snippets}/products-update/http-response.adoc[]

== 상품 삭제

=== HTTP request
include::{snippets}/products-delete/http-request.adoc[]

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

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

== 판매내역 - 판매중 전체 조회

=== HTTP request
include::{snippets}/products/history/progress-all/http-request.adoc[]

=== HTTP response fields
include::{snippets}/products/history/progress-all/response-fields.adoc[]

=== HTTP response
include::{snippets}/products/history/progress-all/http-response.adoc[]

== 판매내역 - 판매완료 전체 조회

=== HTTP request
include::{snippets}/products/history/completed-all/http-request.adoc[]

=== HTTP response fields
include::{snippets}/products/history/completed-all/response-fields.adoc[]

=== HTTP response
include::{snippets}/products/history/completed-all/http-response.adoc[]


== 판매내역 - 판매완료 삭제

=== HTTP request
include::{snippets}/products/history/completed-delete/http-request.adoc[]

=== HTTP response fields
include::{snippets}/products/history/completed-delete/response-fields.adoc[]

=== HTTP response
include::{snippets}/products/history/completed-delete/http-response.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import site.goldenticket.domain.product.service.ProductOrderService;
import site.goldenticket.domain.product.service.ProductService;
import site.goldenticket.domain.security.PrincipalDetails;
import site.goldenticket.dummy.reservation.dto.YanoljaProductResponse;

import java.time.LocalDate;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import static site.goldenticket.common.redis.constants.RedisConstants.*;
import static site.goldenticket.common.redis.constants.RedisConstants.AREA_RANKING_KEY;
import static site.goldenticket.common.redis.constants.RedisConstants.KEYWORD_RANKING_KEY;

@RestController
@RequestMapping("/products")
Expand Down Expand Up @@ -125,7 +125,7 @@ public ResponseEntity<CommonResponse<ProductDetailResponse>> getProduct(
}

@PutMapping("/{productId}")
public ResponseEntity<CommonResponse<ProductResponse>> updateProduct(
public ResponseEntity<CommonResponse<Long>> updateProduct(
@PathVariable Long productId,
@RequestBody @Validated ProductRequest productRequest
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public record ProductDetailResponse(
ProductStatus productStatus,
boolean isSeller,
NegoProductStatus negoProductStatus,
Long wishId,
boolean isWished
) {

Expand All @@ -52,7 +51,6 @@ public static ProductDetailResponse fromEntity(Product product, boolean isSeller
int marketPriceRatio = DiscountCalculatorUtil.calculateDiscountPercentage(yanoljaPrice, goldenPrice);

boolean isWished = isAuthenticated ? !product.getWishProducts().isEmpty() : false;
Long wishId = isWished ? product.getWishProducts().get(0).getId() : null;

return new ProductDetailResponse(
product.getAccommodationImage(),
Expand All @@ -77,7 +75,6 @@ public static ProductDetailResponse fromEntity(Product product, boolean isSeller
product.getProductStatus(),
isSeller,
negoProductStatus,
wishId,
isWished
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public ProductResponse createProduct(
}

@Transactional
public ProductResponse updateProduct(ProductRequest productRequest, Long productId) {
public Long updateProduct(ProductRequest productRequest, Long productId) {
Product product = getProduct(productId);
product.update(productRequest.goldenPrice(), productRequest.content());
AreaCode pastAreaCode = product.getAreaCode();
Expand All @@ -174,7 +174,7 @@ public ProductResponse updateProduct(ProductRequest productRequest, Long product
if(!nowAreaCode.equals(pastAreaCode)) {
alertService.createAlertOfWishRegion(nowAreaCode);
}
return ProductResponse.fromEntity(updatedProduct);
return productId;
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import site.goldenticket.domain.product.constants.AreaCode;
import site.goldenticket.domain.product.constants.ProductStatus;
import site.goldenticket.domain.product.dto.ProductRequest;
import site.goldenticket.domain.product.model.Product;
import site.goldenticket.dummy.reservation.constants.ReservationType;

Expand Down Expand Up @@ -39,4 +40,8 @@ public static Product createProduct() {
.sellerViewCheck(false)
.build();
}

public static ProductRequest createProductRequest() {
return new ProductRequest(10000, "판매자 한마디");
}
}
Loading

0 comments on commit 1a2bfd4

Please sign in to comment.