Skip to content
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 @@ -30,6 +30,7 @@
import com.nowait.domaincorerdb.reservation.entity.Reservation;
import com.nowait.domaincorerdb.reservation.exception.DuplicateReservationException;
import com.nowait.domaincorerdb.reservation.exception.ReservationAddUnauthorizedException;
import com.nowait.domaincorerdb.reservation.exception.ReservationNotFoundException;
import com.nowait.domaincorerdb.reservation.exception.ReservationNumberIssueFailException;
import com.nowait.domaincorerdb.reservation.exception.UserWaitingLimitExceededException;
import com.nowait.domaincorerdb.reservation.repository.ReservationRepository;
Expand Down Expand Up @@ -177,9 +178,15 @@ public WaitingResponseDto myWaitingInfo(Long storeId, CustomOAuth2User customOAu
if (storeId == null || userId.trim().isEmpty()) {
throw new IllegalArgumentException("Invalid storeId or userId");
}

Long rank = waitingUserRedisRepository.getRank(storeId, userId);
Integer partySize = waitingUserRedisRepository.getPartySize(storeId, userId);
String reservationId = waitingUserRedisRepository.getReservationId(storeId, userId);

if (reservationId == null) {
throw new ReservationNotFoundException();
}

return WaitingResponseDto.builder()
.reservationNumber(reservationId)
.rank(rank == null ? -1 : rank.intValue() + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ public ResponseEntity<?> getAllStoresByPageAndDeparments(Pageable pageable, @Aut
);
}

@GetMapping("/{storeId}")
@GetMapping("/{publicCode}")
Copy link

@coderabbitai coderabbitai bot Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

publicCode 전환 마무리: 경로 패턴 제한 + 메서드/호출 네이밍 정리

  • 경로 변수에 허용 패턴을 명시해 라우팅 모호성 방지.
  • 메서드/서비스 호출 명도 publicCode에 맞춰 통일.
- @GetMapping("/{publicCode}")
+ @GetMapping("/{publicCode:[A-Za-z0-9_-]+}")
@@
- public ResponseEntity<?> getStoreById(@PathVariable String publicCode, @AuthenticationPrincipal CustomOAuth2User customOAuth2User) {
+ public ResponseEntity<?> getStoreByPublicCode(@PathVariable String publicCode, @AuthenticationPrincipal CustomOAuth2User customOAuth2User) {
@@
-                     storeService.getStoreByStoreId(publicCode, customOAuth2User)
+                     storeService.getStoreByPublicCode(publicCode, customOAuth2User)

Also applies to: 52-52, 57-57

🤖 Prompt for AI Agents
In
nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/controller/StoreController.java
around lines 49, 52 and 57, the @GetMapping path variables lack an explicit
allowed pattern and the controller/service method names still reference the old
identifier; update the route annotations to restrict the publicCode path
variable to the intended pattern (e.g., alphanumerics and hyphen) to avoid
routing ambiguity, and rename the controller methods and any service calls to
consistently use "publicCode" in their method names/parameters so the API and
service layer reflect the new publicCode semantics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에 보완할게. 이슈 등록 부탁해

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

@Jjiggu 네, 이슈를 등록해드리겠습니다.


🏁 Script executed:

#!/bin/bash
# Create a GitHub issue for the publicCode refactoring improvements
gh issue create \
  --title "주점 조회 API publicCode 패턴 제한 및 메서드명 일관성 개선" \
  --body "## 배경
PR #297에서 주점 조회가 storeId에서 publicCode를 사용하도록 리팩토링되었으나, 추가 개선사항이 있습니다.

## 개선 필요사항

### 1. 경로 변수 패턴 제한
- publicCode 경로 변수에 허용 패턴을 명시하여 라우팅 모호성 방지
- 예: \`@GetMapping(\"/{publicCode:[A-Za-z0-9_-]+}\")\`

### 2. 메서드명 일관성
- 컨트롤러 메서드명을 publicCode 의미에 맞게 변경
- 서비스 호출 메서드명도 일관성 있게 수정
- \`getStoreById\` → \`getStoreByPublicCode\`
- \`getStoreByStoreId\` → \`getStoreByPublicCode\`

## 참고 링크
- 관련 PR: https://github.com/GTable/NoWait_BE_MultiModule/pull/297
- 코드리뷰 코멘트: https://github.com/GTable/NoWait_BE_MultiModule/pull/297#discussion_r2309702381
- 요청자: @Jjiggu

## 파일 범위
- \`nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/controller/StoreController.java\`
- \`nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreService.java\`
- \`nowait-app-user-api/src/main/java/com/nowait/applicationuser/store/service/StoreServiceImpl.java\`" \
  --assignee Jjiggu

Length of output: 1015


@Jjiggu 이슈가 성공적으로 등록되었습니다!

📋 이슈 #298: 주점 조회 API publicCode 패턴 제한 및 메서드명 일관성 개선

publicCode 패턴 제한 및 메서드명 일관성 개선사항들이 이슈로 정리되어 나중에 작업하실 수 있도록 준비되었습니다. 현재 PR은 그대로 진행하시면 됩니다! 🚀

🐰
/| /|
( ✌️ )|
| |

@Operation(summary = "주점 ID로 주점 상세 조회", description = "특정 주점을 ID로 조회합니다.")
@ApiResponse(responseCode = "200", description = "주점 상세 조회 성공")
public ResponseEntity<?> getStoreById(@PathVariable Long storeId, @AuthenticationPrincipal CustomOAuth2User customOAuth2User) {
public ResponseEntity<?> getStoreById(@PathVariable String publicCode, @AuthenticationPrincipal CustomOAuth2User customOAuth2User) {
return ResponseEntity
.status(HttpStatus.OK)
.body(
ApiUtils.success(
storeService.getStoreByStoreId(storeId, customOAuth2User)
storeService.getStoreByPublicCode(publicCode, customOAuth2User)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@Builder
public class StorePageReadResponse {
private Long storeId;
private String publicCode;
private Long bookmarkId;
private Boolean isBookmark;
private Long waitingCount;
Expand Down Expand Up @@ -45,6 +46,7 @@ public static StorePageReadResponse fromEntity(Store store, Long bookmarkId, Lis

return StorePageReadResponse.builder()
.storeId(store.getStoreId())
.publicCode(store.getPublicCode())
.bookmarkId(bookmarkId)
.isBookmark(isBookmark)
.waitingCount(waitingCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@Builder
public class StoreSearchResponse {
private Long storeId;
private String publicCode;
private Long waitingCount;
private Long departmentId;
private String departmentName;
Expand All @@ -34,6 +35,7 @@ public static StoreSearchResponse fromEntity(Store store, List<StoreImageUploadR

return StoreSearchResponse.builder()
.storeId(store.getStoreId())
.publicCode(store.getPublicCode())
.waitingCount(waitingCount)
.departmentId(store.getDepartmentId())
.departmentName(departmentName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface StoreService {

StoreDepartmentReadResponse getAllStoresByPageAndDeparments(Pageable pageable, CustomOAuth2User customOAuth2User);

StoreDetailReadResponse getStoreByStoreId(Long storeId, CustomOAuth2User customOAuth2User);
StoreDetailReadResponse getStoreByPublicCode(String publicCode, CustomOAuth2User customOAuth2User);

List<StoreSearchResponse> searchByKeywordNative(String name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import com.nowait.applicationuser.reservation.repository.WaitingUserRedisRepository;
import com.nowait.applicationuser.store.dto.StoreDepartmentReadResponse;
Expand Down Expand Up @@ -141,15 +142,17 @@ public StoreDepartmentReadResponse getAllStoresByPageAndDeparments(Pageable page

@Override
@Transactional(readOnly = true)
public StoreDetailReadResponse getStoreByStoreId(Long storeId, CustomOAuth2User customOAuth2User) {
public StoreDetailReadResponse getStoreByPublicCode(String publicCode, CustomOAuth2User customOAuth2User) {

if (storeId == null)
if (!StringUtils.hasText(publicCode))
throw new StoreParamEmptyException();
User user = customOAuth2User.getUser();

Store store = storeRepository.findByStoreIdAndDeletedFalse(storeId)
Store store = storeRepository.findByPublicCodeAndDeletedFalse(publicCode)
.orElseThrow(StoreNotFoundException::new);

Long storeId = store.getStoreId();;

String departmentName = departmentRepository.findById(store.getDepartmentId())
.map(Department::getName)
.orElse("Unknown Department");
Expand Down