Skip to content

Commit

Permalink
딜 상품 목록 조회 API Docs 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
daadaadaah committed May 20, 2023
1 parent a653c2c commit 999be6e
Show file tree
Hide file tree
Showing 8 changed files with 484 additions and 15 deletions.
21 changes: 21 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ include::{snippets}/get-products-by-center-id/http-response.adoc[]
===== Structure
include::{snippets}/get-products-by-center-id/response-fields.adoc[]

== 딜 상품
=== 딜별 딜 상품 목록 조회
==== Request
===== Example
include::{snippets}/get-deal-products-by-deal-id/http-request.adoc[]

===== Structure
====== Path Parameters
include::{snippets}/get-deal-products-by-deal-id/path-parameters.adoc[]

====== Query Parameters
include::{snippets}/get-deal-products-by-deal-id/query-parameters.adoc[]

==== Response
===== Example
include::{snippets}/get-deal-products-by-deal-id/http-response.adoc[]

===== Structure
include::{snippets}/get-deal-products-by-deal-id/response-fields.adoc[]


== 주문
=== 주문 접수 완료
==== Request
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/com/hcommerce/heecommerce/deal/DealController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.hcommerce.heecommerce.deal;

import com.hcommerce.heecommerce.common.dto.PageDto;
import com.hcommerce.heecommerce.common.dto.ResponseDto;
import com.hcommerce.heecommerce.product.ProductsSort;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@RestController
public class DealController {

@GetMapping("/dealProducts/{dealId}")
public ResponseDto getDealProductsByDealId(
@PathVariable("dealId") int dealId,
@RequestParam int pageNumber,
@RequestParam ProductsSort sort
) {

// TODO : 임시 데이터 사용하기
List<DealProductsItem> dealProducts = new ArrayList<>();
dealProducts.add(DealProductsItem.builder()
.dealProductUuid(UUID.fromString("01b8851c-d046-4635-83c1-eb0ca4342077"))
.dealProductTile("1000원 할인 상품 1")
.productMainImgThumbnailUrl("/test.png")
.productOriginPrice(3000)
.dealProductDiscountType(DiscountType.FIXED_AMOUNT)
.dealProductDiscountValue(1000)
.dealProductDealQuantity(3)
.build());

return ResponseDto.builder()
.code(HttpStatus.OK.name())
.message("딜 상품 목록 조회 성공하였습니다.")
.data(PageDto.<DealProductsItem>builder()
.pageNumber(0)
.pageSize(20)
.totalCount(dealProducts.size())
.items(dealProducts)
.build())
.build();
}
}
37 changes: 37 additions & 0 deletions src/main/java/com/hcommerce/heecommerce/deal/DealProductsItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.hcommerce.heecommerce.deal;


import java.util.UUID;
import lombok.Builder;
import lombok.Getter;

@Getter
public class DealProductsItem {

private final UUID dealProductUuid;
private final String dealProductTile;
private final String productMainImgThumbnailUrl;
private final int productOriginPrice;
private final DiscountType dealProductDiscountType;
private final int dealProductDiscountValue;
private final int dealProductDealQuantity;

@Builder
public DealProductsItem(
UUID dealProductUuid,
String dealProductTile,
String productMainImgThumbnailUrl,
int productOriginPrice,
DiscountType dealProductDiscountType,
int dealProductDiscountValue,
int dealProductDealQuantity
) {
this.dealProductUuid = dealProductUuid;
this.dealProductTile = dealProductTile;
this.productMainImgThumbnailUrl = productMainImgThumbnailUrl;
this.productOriginPrice = productOriginPrice;
this.dealProductDiscountType = dealProductDiscountType;
this.dealProductDiscountValue = dealProductDiscountValue;
this.dealProductDealQuantity = dealProductDealQuantity;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.hcommerce.heecommerce.deal;

public enum DiscountType {
FIXED_AMOUNT,
PERCENTAGE,
}
Loading

0 comments on commit 999be6e

Please sign in to comment.