Skip to content

Commit

Permalink
Merge pull request #38 from daadaadaah/feat/get-deal-products-api-docs
Browse files Browse the repository at this point in the history
딜 상품 목록 조회 API Docs 추가
  • Loading branch information
daadaadaah authored Jun 3, 2023
2 parents b9c646f + 19bc2b1 commit 7676d9e
Show file tree
Hide file tree
Showing 9 changed files with 487 additions and 13 deletions.
20 changes: 20 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ 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,
}
6 changes: 6 additions & 0 deletions src/main/java/com/hcommerce/heecommerce/order/OrderForm.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hcommerce.heecommerce.order;

import java.beans.ConstructorProperties;
import lombok.Builder;
import lombok.Getter;

Expand All @@ -11,6 +12,11 @@ public class OrderForm {
private PaymentInfo paymentInfo;

@Builder
@ConstructorProperties({
"ordererInfo",
"recipientInfo",
"paymentInfo"}
)
public OrderForm(
OrdererInfo ordererInfo,
RecipientInfo recipientInfo,
Expand Down
Loading

0 comments on commit 7676d9e

Please sign in to comment.