Skip to content

Commit

Permalink
Merge pull request #64 from 28th-meetup/feat/myStoreMenu
Browse files Browse the repository at this point in the history
Feat/my store menu
  • Loading branch information
summit45 committed Nov 21, 2023
2 parents 38bdfbf + 8d9dbcb commit b095cc6
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
public class OrderFoodDetailResponse {
private Long orderDetailId; //고유 pk
private Long foodId;
private String foodName;
private Long foodOptionId; //foodOptionId로 설정
private String foodOptionName;
private Long orderCount; //품목 개수
private Long orderAmount; //품목당 가격

public OrderFoodDetailResponse(OrderDetail orderDetail){
System.out.println(orderDetail.getId());
this.orderDetailId = orderDetail.getId();
this.foodId = orderDetail.getFood().getId();
this.foodName = orderDetail.getFood().getName();
this.foodOptionId = orderDetail.getFoodOption().getId();
this.foodOptionName = orderDetail.getFoodOption().getName();
this.orderCount = orderDetail.getOrderCount();
this.orderAmount = orderDetail.getOrderAmount();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ public class OrderHistoryResponse {
private Long id;
private Long userId;
private Long storeId;
private String storeName;
private String storeImage;
private String storeImage2;
private String storeImage3;
private Long totalCount;
private Long totalPrice;
private String selectedOption;
private String selectedOption; //배달 포장
private String orderedAt;
private String status;
private Boolean isReviewed; //리뷰 작성 여부
Expand All @@ -33,6 +37,10 @@ public OrderHistoryResponse(Order order){
this.id = order.getId();
this.userId = order.getUser().getId();
this.storeId = order.getStore().getId();
this.storeName = order.getStore().getName();
this.storeImage = order.getStore().getImage();
this.storeImage2 = order.getStore().getImage2();
this.storeImage3 = order.getStore().getImage3();
this.totalCount = order.getTotalCount();
this.totalPrice = order.getTotalPrice();
this.selectedOption = order.getSelectedOption();
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/kusitms/jipbap/store/StoreController.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,10 @@ public CommonResponse<OwnerOrderStatusResponse> getStoreOrderHistoryByOrderStatu
return new CommonResponse<>(orderService.getStoreOrderHistoryByOrderStatus(authInfo.getEmail(), orderStatus));
}

@Operation(summary = "가게 정보")
@GetMapping("/info/{storeId}")
public CommonResponse<StoreInfoResponse> getStoreInfoDetail(@Auth AuthInfo authInfo, @PathVariable Long storeId) {
return new CommonResponse<>(storeService.getStoreInfoDetail(authInfo.getEmail(), storeId));
}

}
13 changes: 13 additions & 0 deletions src/main/java/com/kusitms/jipbap/store/StoreService.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,17 @@ public List<FoodDetailByStoreResponse> getMyStoreMenu(String email){

return getAllMenuListByStoreId(store.getId());
}

public StoreInfoResponse getStoreInfoDetail(String email, Long storeId){
User user = userRepository.findByEmail(email)
.orElseThrow(()-> new UserNotFoundException("유저 정보가 존재하지 않습니다."));
Store store = storeRepository.findById(storeId)
.orElseThrow(()-> new StoreNotExistsException("storeId: " + storeId + " 에 해당하는 가게가 존재하지 않습니다."));

return new StoreInfoResponse(
new StoreInfoDto(store),
isStoreBookmarked(user, store),
store.getFoodChangeYn()
);
}
}
39 changes: 39 additions & 0 deletions src/main/java/com/kusitms/jipbap/store/dto/StoreInfoDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.kusitms.jipbap.store.dto;

import com.kusitms.jipbap.store.Store;
import lombok.*;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class StoreInfoDto {
private Long id;
private String name;
private String description;
private Boolean koreanYn;
private Double avgRate; // 가게 평점
private Long minOrderAmount; //최소 주문 금액
private String[] images;
private String address;
private String detailAddress;
private String phoneNum;
private String deliveryRegion;
private String operationTime;

public StoreInfoDto(Store store) {
this.id = store.getId();
this.name = store.getName();
this.description = store.getDescription();
this.koreanYn = store.getKoreanYn();
this.avgRate = store.getAvgRate();
this.minOrderAmount = store.getMinOrderAmount();
this.images = new String[]{store.getImage(), store.getImage2(), store.getImage3()};
this.address = store.getAddress();
this.detailAddress = store.getDetailAddress();
this.phoneNum = store.getPhoneNum();
this.deliveryRegion = store.getDeliveryRegion();
this.operationTime = store.getOperationTime();
}
}
16 changes: 16 additions & 0 deletions src/main/java/com/kusitms/jipbap/store/dto/StoreInfoResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.kusitms.jipbap.store.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class StoreInfoResponse {
private StoreInfoDto storeInfoDto;
private Boolean isBookmarked;
private Boolean isFoodChangeable;
}

0 comments on commit b095cc6

Please sign in to comment.