-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from lotteon2/develop
Develop
- Loading branch information
Showing
8 changed files
with
118 additions
and
37 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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/dailyon/auctionservice/controller/AuctionHistoryFeignApiController.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,21 @@ | ||
package com.dailyon.auctionservice.controller; | ||
|
||
import com.dailyon.auctionservice.dto.response.AuctionProductInfo; | ||
import com.dailyon.auctionservice.facade.AuctionHistoryFacade; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
import reactor.core.publisher.Mono; | ||
|
||
@CrossOrigin("*") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/clients/auction-histories") | ||
public class AuctionHistoryFeignApiController { | ||
private final AuctionHistoryFacade auctionHistoryFacade; | ||
|
||
@GetMapping("/{auctionId}") | ||
public Mono<AuctionProductInfo> getAuctionHistory( | ||
@RequestHeader("memberId") Long memberId, @PathVariable("auctionId") String auctionId) { | ||
return auctionHistoryFacade.readAuctionHistoryAndProductDetail(memberId, auctionId); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/dailyon/auctionservice/dto/response/AuctionProductInfo.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,20 @@ | ||
package com.dailyon.auctionservice.dto.response; | ||
|
||
import lombok.*; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class AuctionProductInfo { | ||
private String productName; | ||
private Integer stock; | ||
private Integer price; | ||
private String gender; | ||
private String imgUrl; | ||
private Long sizeId; | ||
private String sizeName; | ||
private boolean isWinner; | ||
private Long orderPrice; | ||
} |
39 changes: 34 additions & 5 deletions
39
src/main/java/com/dailyon/auctionservice/facade/AuctionHistoryFacade.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 |
---|---|---|
@@ -1,19 +1,48 @@ | ||
package com.dailyon.auctionservice.facade; | ||
|
||
import com.dailyon.auctionservice.common.webclient.client.ProductClient; | ||
import com.dailyon.auctionservice.document.AuctionHistory; | ||
import com.dailyon.auctionservice.dto.response.AuctionProductInfo; | ||
import com.dailyon.auctionservice.dto.response.ReadAuctionDetailResponse; | ||
import com.dailyon.auctionservice.dto.response.ReadAuctionHistoryPageResponse; | ||
import com.dailyon.auctionservice.service.AuctionHistoryService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class AuctionHistoryFacade { | ||
private final AuctionHistoryService auctionHistoryService; | ||
private final AuctionHistoryService auctionHistoryService; | ||
private final ProductClient productClient; | ||
|
||
public ReadAuctionHistoryPageResponse readAuctionHistories(String memberId, Pageable pageable) { | ||
return ReadAuctionHistoryPageResponse.of(auctionHistoryService.readAuctionHistories(memberId, pageable)); | ||
} | ||
public ReadAuctionHistoryPageResponse readAuctionHistories(String memberId, Pageable pageable) { | ||
return ReadAuctionHistoryPageResponse.of( | ||
auctionHistoryService.readAuctionHistories(memberId, pageable)); | ||
} | ||
|
||
public Mono<AuctionProductInfo> readAuctionHistoryAndProductDetail( | ||
Long memberId, String auctionId) { | ||
AuctionHistory auctionHistory = | ||
auctionHistoryService.getAuctionHistory(String.valueOf(memberId), auctionId); | ||
Mono<ReadAuctionDetailResponse.ReadProductDetailResponse> readProductDetailResponseMono = | ||
productClient.readProductDetail(auctionHistory.getAuctionProductId()); | ||
return readProductDetailResponseMono.flatMap( | ||
product -> { | ||
AuctionProductInfo auctionProductInfo = | ||
AuctionProductInfo.builder() | ||
.productName(product.getName()) | ||
.stock(product.getProductStocks().get(0).getQuantity().intValue()) | ||
.price(product.getPrice()) | ||
.gender(product.getGender()) | ||
.imgUrl(product.getImgUrl()) | ||
.sizeId(product.getProductStocks().get(0).getProductSizeId()) | ||
.sizeName(product.getProductStocks().get(0).getProductSizeName()) | ||
.isWinner(auctionHistory.isWinner()) | ||
.orderPrice(auctionHistory.getAuctionWinnerBid()) | ||
.build(); | ||
return Mono.just(auctionProductInfo); | ||
}); | ||
} | ||
} |
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
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
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
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