Skip to content

Conversation

@doup2001
Copy link
Contributor

@doup2001 doup2001 commented May 22, 2025

PR 개요

♻️ refactor : 결제 서비스 주소 변경

스크린샷

image - 정상적으로 예외처리 발생

Summary by CodeRabbit

  • 버그 수정
    • 결제 서비스에서 주문 완료 처리 시 올바른 데이터 타입을 사용하도록 수정되었습니다.
  • 기타
    • CORS 허용 오리진에 "http://localhost:5173"이 추가되어 개발 환경에서의 접근성이 향상되었습니다.
    • 주문 서비스 연동 주소 및 주문 완료 처리 방식이 변경되었습니다.

@doup2001 doup2001 self-assigned this May 22, 2025
@doup2001 doup2001 temporarily deployed to payment-service May 22, 2025 05:21 — with GitHub Actions Inactive
@coderabbitai
Copy link

coderabbitai bot commented May 22, 2025

Walkthrough

이 변경사항은 CORS 허용 오리진 추가, Feign 클라이언트의 주문 서비스 URL 및 엔드포인트 수정, 그리고 주문 완료 메서드의 파라미터 타입 일치를 위한 코드 수정을 포함합니다. 외부 서비스와의 연동 방식 및 접근 제어 설정이 조정되었습니다.

Changes

파일 경로 변경 요약
payment-service/src/main/java/gcu/web/paymentservice/common/config/WebMvcConfig.java CORS 허용 오리진에 "http://localhost:5173" 추가, 불필요한 import 제거
payment-service/src/main/java/gcu/web/paymentservice/platform/adapter/out/external/order/OrderFeignPort.java 주문 서비스 URL을 "http://54.66.149.225:8100"로 변경, completeOrder 메서드의 HTTP 메서드 및 엔드포인트 수정, 파라미터 타입을 String에서 Long으로 변경
payment-service/src/main/java/gcu/web/paymentservice/platform/application/service/PaymentService.java completeOrder 호출 시 orderIdLong 타입으로 변환하여 전달하도록 수정

Sequence Diagram(s)

sequenceDiagram
    participant PaymentService
    participant OrderFeignPort
    participant OrderService

    PaymentService->>OrderFeignPort: completeOrder(Long orderId)
    OrderFeignPort->>OrderService: PUT /api/v1/orders/{orderId}/submit
    OrderService-->>OrderFeignPort: 응답 반환
    OrderFeignPort-->>PaymentService: 응답 반환
Loading

Possibly related PRs

Suggested labels

enhancement

Poem

토끼가 깡총, 코드를 손질해
오리진 하나 추가, CORS도 안녕!
주문 서비스 주소도 새롭게 바꿔
Long 타입 주문 번호, 실수는 이제 그만
서버는 더 단단히, 오늘도 깡총! 🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 30th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@doup2001 doup2001 merged commit cba7980 into payment-service/main May 22, 2025
2 of 3 checks passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
payment-service/src/main/java/gcu/web/paymentservice/common/config/WebMvcConfig.java (1)

13-16: CORS 설정 보안 검토 권장

현재 CORS 설정은 여러 오리진을 허용하고 모든 헤더와 인증 정보를 허용합니다. 프로덕션 환경에서는 보안을 강화하기 위해 필요한 헤더만 명시적으로 허용하고, 인증 정보의 처리를 신중하게 검토하는 것이 좋습니다.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbddb4c and 94eed2d.

📒 Files selected for processing (3)
  • payment-service/src/main/java/gcu/web/paymentservice/common/config/WebMvcConfig.java (1 hunks)
  • payment-service/src/main/java/gcu/web/paymentservice/platform/adapter/out/external/order/OrderFeignPort.java (2 hunks)
  • payment-service/src/main/java/gcu/web/paymentservice/platform/application/service/PaymentService.java (1 hunks)
🔇 Additional comments (2)
payment-service/src/main/java/gcu/web/paymentservice/platform/adapter/out/external/order/OrderFeignPort.java (1)

19-20: API 엔드포인트 및 파라미터 타입 변경

주문 완료 API의 엔드포인트가 POST /api/v1/orders/{orderId}에서 PUT /api/v1/orders/{orderId}/submit으로 변경되었고, orderId 파라미터 타입이 String에서 Long으로 변경되었습니다. 이는 유효한 리소스 설계 관점에서 좋은 변화이며, HTTP 메서드 사용이 RESTful 원칙에 더 부합합니다.

payment-service/src/main/java/gcu/web/paymentservice/common/config/WebMvcConfig.java (1)

13-13: 로컬 개발 환경용 CORS 설정 추가

http://localhost:5173을 허용된 오리진 목록에 추가한 것은 로컬 개발 환경을 위한 적절한 변경입니다. 이는 Vite와 같은 최신 프론트엔드 개발 도구에서 사용하는 기본 포트입니다.



@FeignClient(name = "order-service", url = "http://34.127.7.212:8101")
@FeignClient(name = "order-service", url = "http://54.66.149.225:8100")
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

서비스 URL 업데이트 확인됨

주문 서비스의 URL이 http://34.127.7.212:8101에서 http://54.66.149.225:8100으로 변경되었습니다. 이 변경사항이 모든 환경(개발, 테스트, 프로덕션)에서 일관되게 적용되었는지 확인하세요.

다음 스크립트를 실행하여 다른 서비스에서도 이 새 URL을 참조하고 있는지 확인하세요:


🏁 Script executed:

#!/bin/bash
# 프로젝트에서 이전 URL 참조 검색
rg -i "34.127.7.212:8101" --type java

Length of output: 37


다른 환경 설정 파일에도 이전 URL이 남아있을 수 있으므로, 코드뿐 아니라 설정 파일 전체를 대상으로 재검색해 주세요.


🏁 Script executed:

#!/bin/bash
# 전체 파일에서 이전 서비스 URL(34.127.7.212:8101) 참조 검색 (Java, YAML, Properties 등)
rg -F "34.127.7.212:8101" -n

Length of output: 181


이전 서비스 URL 참조 수정 필요

서비스 URL이 http://34.127.7.212:8101에서 http://54.66.149.225:8100으로 변경되었으나, 아래 파일에 아직 이전 URL이 남아 있습니다. 모든 참조를 새 URL로 업데이트해주세요.

  • payment-service/src/main/resources/static/index.html (라인 52)

수정 예시:

- <a href="http://34.127.7.212:8101/swagger-ui/index.html#/" class="link-button">스웨거로 이동하기</a>
+ <a href="http://54.66.149.225:8100/swagger-ui/index.html#/" class="link-button">스웨거로 이동하기</a>

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In
payment-service/src/main/java/gcu/web/paymentservice/platform/adapter/out/external/order/OrderFeignPort.java
at line 9, the FeignClient annotation URL has been updated to
"http://54.66.149.225:8100". Ensure that all other references to the old URL
"http://34.127.7.212:8101" in the entire project, including configuration files
and static resources like payment-service/src/main/resources/static/index.html
line 52, are also updated to the new URL to maintain consistency across all
environments.


// 주문 정보 전달
orderFeignPort.completeOrder(saved.getOrderId());
orderFeignPort.completeOrder(Long.valueOf(saved.getOrderId()));
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

타입 변환 시 예외 처리 필요

String에서 Long으로 변환 시 orderId가 숫자 형식이 아닌 경우 NumberFormatException이 발생할 수 있습니다. 이 예외를 적절히 처리하는 것이 좋습니다.

다음과 같이 수정하는 것을 권장합니다:

- orderFeignPort.completeOrder(Long.valueOf(saved.getOrderId()));
+ try {
+     orderFeignPort.completeOrder(Long.valueOf(saved.getOrderId()));
+ } catch (NumberFormatException e) {
+     log.error("주문 ID 형식 오류: {}", saved.getOrderId(), e);
+     throw new IllegalStateException(ErrorCode.BAD_REQUEST.getMessage());
+ }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
orderFeignPort.completeOrder(Long.valueOf(saved.getOrderId()));
try {
orderFeignPort.completeOrder(Long.valueOf(saved.getOrderId()));
} catch (NumberFormatException e) {
log.error("주문 ID 형식 오류: {}", saved.getOrderId(), e);
throw new IllegalStateException(ErrorCode.BAD_REQUEST.getMessage());
}
🤖 Prompt for AI Agents
In
payment-service/src/main/java/gcu/web/paymentservice/platform/application/service/PaymentService.java
at line 66, the code converts orderId from String to Long without handling
potential NumberFormatException if the orderId is not a valid number. To fix
this, wrap the Long.valueOf conversion in a try-catch block to catch
NumberFormatException and handle it appropriately, such as logging the error and
preventing the method from proceeding with an invalid orderId.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants