Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/order history #53

Merged
merged 3 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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