Skip to content

Commit

Permalink
Merge pull request #60 from 28th-meetup/fix/foodPrice
Browse files Browse the repository at this point in the history
feat: 유저의 가게 조회 api 기능 구현
  • Loading branch information
summit45 committed Nov 20, 2023
2 parents a57200e + 17a10a8 commit cec7061
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/kusitms/jipbap/store/StoreController.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public CommonResponse<RegisterStoreResponse> registerStore(
return new CommonResponse<>(storeService.registerStore(authInfo.getEmail(), dto, image));
}

@Operation(summary = "내 가게 아이디 조회하기")
@GetMapping("/my-store-id")
@ResponseStatus(HttpStatus.OK)
public CommonResponse<StoreDto> getMyStore(@Auth AuthInfo authInfo) {
return new CommonResponse<>(storeService.getMyStore(authInfo.getEmail()));
}

/**
* 가게 검색 api - 페이지네이션 적용
* api의 복잡도와 성능을 희생하는 대신, 데이터 중복/삭제 현상을 감안함
Expand Down Expand Up @@ -130,4 +137,6 @@ public CommonResponse<OwnerOrderStatusResponse> getStoreOrderHistoryByOrderStatu
@PathVariable String orderStatus) {
return new CommonResponse<>(orderService.getStoreOrderHistoryByOrderStatus(authInfo.getEmail(), orderStatus));
}


}
15 changes: 15 additions & 0 deletions src/main/java/com/kusitms/jipbap/store/StoreService.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ public RegisterStoreResponse registerStore(String email, RegisterStoreRequestDto
);
}

public StoreDto getMyStore(String email){
User user = userRepository.findByEmail(email).orElseThrow(()-> new UserNotFoundException("유저 정보가 존재하지 않습니다."));
Store store = storeRepository.findByOwner(user).orElseThrow(()-> new StoreNotExistsException("가게 정보가 존재하지 않습니다."));

return new StoreDto(
store.getId(),
store.getName(),
store.getDescription(),
store.getKoreanYn(),
store.getAvgRate(),
store.getMinOrderAmount(),
new String[]{store.getImage(), store.getImage2(), store.getImage3()}
);
}

@Transactional
public Slice<StoreDetailResponseDto> searchStoreList(String email, Pageable pageable, String keyword, String standard, String order, Long lastId) {
User user = userRepository.findByEmail(email).orElseThrow(()-> new UserNotFoundException("유저 정보가 존재하지 않습니다."));
Expand Down

0 comments on commit cec7061

Please sign in to comment.