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

feat: 유저의 가게 조회 api 기능 구현 #60

Merged
merged 1 commit into from
Nov 20, 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
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
Loading