-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a653c2c
commit 999be6e
Showing
8 changed files
with
484 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/hcommerce/heecommerce/deal/DealController.java
This file contains 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 |
---|---|---|
@@ -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
37
src/main/java/com/hcommerce/heecommerce/deal/DealProductsItem.java
This file contains 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 |
---|---|---|
@@ -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; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/com/hcommerce/heecommerce/deal/DiscountType.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.hcommerce.heecommerce.deal; | ||
|
||
public enum DiscountType { | ||
FIXED_AMOUNT, | ||
PERCENTAGE, | ||
} |
Oops, something went wrong.