Skip to content

Commit

Permalink
Merge pull request #53 from pick-PICKLE/Feature/order-history
Browse files Browse the repository at this point in the history
Feature/order history
  • Loading branch information
llprn authored Feb 13, 2023
2 parents 2ad8e06 + e7b434b commit 195c2e1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,12 @@ public ResponseEntity<List<DressLikeDto>> findDressLikeByUser(@ApiIgnore @Authen
@ApiResponses({
@ApiResponse(code = 200, message = "의상 예약 상세 내역 조회 성공")
})
@GetMapping("/orders")
public ResponseEntity<List<DressOrderDto>> getOrder (@ApiIgnore @AuthenticationPrincipal User user){
return new ResponseEntity<>(dressService.getDressOrder(user.getId()), HttpStatus.OK);
@GetMapping("/orders/{dress_reservation_id}")
public ResponseEntity<List<DressOrderDto>> getOrder(@PathVariable(name="dress_reservation_id") Long dressReservationId,
@ApiIgnore @AuthenticationPrincipal User user){
return new ResponseEntity<>(dressService.getDressOrder(dressReservationId,user.getId()), HttpStatus.OK);
}



@ApiOperation(value = "의상 예약 내역 조회",
httpMethod = "GET",
response = DressOrderDto.class,
Expand All @@ -172,7 +171,7 @@ public ResponseEntity<List<DressOrderDto>> getOrder (@ApiIgnore @AuthenticationP
@ApiResponse(code = 200, message = "의상 예약 내역 조회 성공")
})
@GetMapping("/order-list")
public ResponseEntity<List<DressOrderListDto>> getOrderList (@ApiIgnore @AuthenticationPrincipal User user){
return new ResponseEntity<>(dressService.getDressOrderList(user.getId()), HttpStatus.OK);
public ResponseEntity<List<DressOrderListDto>> getOrderList(@RequestParam(name="status")String status,@ApiIgnore @AuthenticationPrincipal User user){
return new ResponseEntity<>(dressService.getDressOrderList(status,user.getId()), HttpStatus.OK);
}
}
18 changes: 8 additions & 10 deletions src/main/java/com/pickle/server/dress/dto/DressOrderDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.time.format.DateTimeFormatter;



@Getter
public class DressOrderDto {
@ApiModelProperty(example = "예약내역 id")
Expand Down Expand Up @@ -55,18 +54,17 @@ public class DressOrderDto {
@JsonProperty("price")
private String price;

@ApiModelProperty(example = "드레스 옵션 1")
@JsonProperty("dress_option1")
private String dressOption1;
// @ApiModelProperty(example = "드레스 옵션 1")
// @JsonProperty("dress_option1")
// private String dressOption1;

@ApiModelProperty(example = "드레스 옵션 1_name")
@JsonProperty("dress_option1_name")
// private DressOptionDetail dressOption1;
private String dressOptionName1;

@ApiModelProperty(example = "드레스 옵션 2")
@JsonProperty("dress_option2")
private String dressOption2;
// @ApiModelProperty(example = "드레스 옵션 2")
// @JsonProperty("dress_option2")
// private String dressOption2;
@ApiModelProperty(example = "드레스 옵션 2_name")
@JsonProperty("dress_option2_name")
// private DressOptionDetail dressOption1;
Expand All @@ -90,9 +88,9 @@ public DressOrderDto(DressReservation dressReservation, ReservedDress reservedDr
+ dressReservation.getStore().getCloseTime().format(DateTimeFormatter.ofPattern("HH:mm"));
this.storeOpenDay = makeStoreOpenDayIntroduction(dressReservation.getStore().getStoreOpenDay());
this.pickUpDateTime = dressReservation.getPickUpDateTime().toString();
this.dressOption1 = reservedDress.getDressOptionDetail1().getDressOption().getName();
// this.dressOption1 = reservedDress.getDressOptionDetail1().getDressOption().getName();
this.dressOptionName1 = reservedDress.getDressOptionDetail1().getName();
this.dressOption2 = reservedDress.getDressOptionDetail2().getDressOption().getName();
// this.dressOption2 = reservedDress.getDressOptionDetail2().getDressOption().getName();
this.dressOptionName2 = reservedDress.getDressOptionDetail2().getName();
this.comment =dressReservation.getComment();
this.price = priceFormat.format(dressReservation.getPrice()*reservedDress.getQuantity())+"원";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public interface DressDslRepository {
List<DressOverviewDto> findDressByStoreAndCreatedAt(Long userId, Double latitude, Double longitude, LocalDateTime stdDate);

List<DressOverviewDto> findDressByCategory(Long userId, String category, Double latitude, Double longitude);
List<DressOrderDto> findReservationByUser(Long userId);
List<DressOrderListDto> findReservationListByUser(Long userId);
List<DressOrderDto> findReservationByUserAndReservationId(Long dressReservationId,Long userId);
List<DressOrderListDto> findReservationListByStatusAndUser(String status,Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private NumberExpression<Double> radianToDegree(NumberExpression<Double> radian)
return radian.multiply(180 / Math.PI);
}
@Override
public List<DressOrderDto> findReservationByUser(Long userId) {
public List<DressOrderDto> findReservationByUserAndReservationId(Long dressReservationId,Long userId) {
return queryFactory
.select(new QDressOrderDto(
dressReservation,reservedDress,
Expand All @@ -204,13 +204,13 @@ public List<DressOrderDto> findReservationByUser(Long userId) {
.where(dressImage.dress.id.eq(dress.id)).limit(1)
))
.from(dressReservation, reservedDress)
.where(dressReservation.user.id.eq(userId))
.where(dressReservation.user.id.eq(userId).and(dressReservation.id.eq(dressReservationId)))
.where(dressReservation.id.eq(reservedDress.dressReservation.id))
.fetch();
}

@Override
public List<DressOrderListDto> findReservationListByUser(Long userId) {
public List<DressOrderListDto> findReservationListByStatusAndUser(String status,Long userId) {
return queryFactory
.select(new QDressOrderListDto(
dressReservation,reservedDress,
Expand All @@ -221,6 +221,7 @@ public List<DressOrderListDto> findReservationListByUser(Long userId) {
.from(dressReservation, reservedDress)
.where(dressReservation.user.id.eq(userId))
.where(dressReservation.id.eq(reservedDress.dressReservation.id))
.where(dressReservation.status.eq(status))
.fetch();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ public void makeDressReservation(DressReservationDto dressReservationDto, User u
}
}

public List<DressOrderDto> getDressOrder(Long userId){
public List<DressOrderDto> getDressOrder(Long dressReservationId,Long userId){
User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundIdException());
return dressRepository.findReservationByUser(userId);

return dressRepository.findReservationByUserAndReservationId(dressReservationId,userId);
}
public List<DressOrderListDto> getDressOrderList(Long userId){
public List<DressOrderListDto> getDressOrderList(String status,Long userId){
User user = userRepository.findById(userId).orElseThrow(() -> new NotFoundIdException());
return dressRepository.findReservationListByUser(userId);
return dressRepository.findReservationListByStatusAndUser(status,userId);
}

public void cancelReservation(Long reservationId) {
Expand Down

0 comments on commit 195c2e1

Please sign in to comment.