Skip to content

feat: 리뷰 번역기능 추가#417

Merged
sjinssun merged 6 commits into
developfrom
feat/#416-review-trans
Jul 13, 2026
Merged

feat: 리뷰 번역기능 추가#417
sjinssun merged 6 commits into
developfrom
feat/#416-review-trans

Conversation

@sjinssun

Copy link
Copy Markdown
Contributor

#️⃣ Issue Number

📝 요약(Summary)

리뷰에 대한 DeepL 번역 기능을 추가했습니다. POST /v2/reviews/{reviewId}/translate?language=EN을 호출하면 DeepL로 번역한 결과를 반환하고, 결과는 DB(review_translation)에 캐싱해서 같은 리뷰/언어 조합은 재호출 없이 캐시를
반환합니다.

  • review_translation 테이블 추가 (V18 마이그레이션), review_id FK에 ON DELETE CASCADE 걸어서 리뷰 삭제 시 캐시도 같이 삭제되도록 처리
  • 리뷰 내용(content)이 실제로 수정된 경우에만 캐시를 무효화하도록 처리 (rating만 바뀐 경우는 캐시 유지)
  • DeepL 전용 RestTemplate 빈을 별도로 분리하고 connect/read timeout을 명시적으로 설정
  • DeepL 호출 실패를 쿼터초과(429/456)/타임아웃/기타 실패로 구분해서 BaseResponseStatus에 상태코드 3개 추가
  • 현재는 language=EN만 지원

💬 공유사항 to 리뷰어

  • DeepLTranslationClient에서 기존 Apple 로그인용 RestTemplate 빈과 이름이 겹치지 않도록 deeplRestTemplate으로 분리했습니다.

✅ PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

본 PR은 리뷰 내용을 영어로 번역할 수 있는 기능을 추가합니다. DeepL API를 활용하며, 성능 향상을 위해 번역 결과를 DB에 캐싱하고 리뷰 수정 시 캐시를 무효화하는 로직을 포함합니다. 또한, 안정적인 API 호출을 위해 전용 RestTemplate 설정과 세분화된 예외 처리를 도입했습니다.

Highlights

  • DeepL 번역 기능 추가: POST /v2/reviews/{reviewId}/translate?language=EN API를 통해 리뷰 내용을 DeepL로 번역하는 기능을 구현했습니다.
  • 번역 결과 캐싱: review_translation 테이블을 추가하여 번역 결과를 저장하고, 동일한 리뷰/언어 조합에 대해 재호출 없이 캐시를 반환하도록 최적화했습니다.
  • 캐시 무효화 로직: 리뷰 내용(content)이 수정될 경우에만 캐시를 무효화하도록 처리하여 불필요한 번역 호출을 방지했습니다.
  • 인프라 및 예외 처리: DeepL 전용 RestTemplate 빈을 분리하고, 쿼터 초과/타임아웃/실패 상황에 따른 세부적인 에러 응답 코드를 추가했습니다.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/deploy.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


리뷰를 번역해 영어로 담아, DeepL API로 뜻을 전하네. 캐시를 쌓아 속도를 높이고, 수정된 글엔 다시금 새롭게.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

이번 풀 리퀘스트는 DeepL API를 활용한 리뷰 번역 기능을 추가합니다. 이를 위해 번역 결과를 캐싱하는 review_translation 테이블 및 엔티티, DeepL 연동 클라이언트, 번역 서비스, 그리고 ReviewControllerV2에 번역 API 엔드포인트를 새롭게 도입하였으며, 리뷰 수정 시 기존 캐시를 삭제하는 로직을 추가했습니다. 코드 리뷰에서는 번역 내용 절삭 방지를 위한 DB 컬럼 타입 변경(TEXT 권장), 커넥션 풀 고갈 방지를 위한 외부 API 호출의 트랜잭션 외부 분리, 예외 처리를 위한 saveAndFlush() 사용, CI/CD 환경을 고려한 @value 기본값 설정, Spring 6 버전에 맞춘 Duration 기반 타임아웃 설정, 그리고 컨트롤러 내 미사용 매개변수 제거 등 시스템 안정성과 코드 품질을 높이기 위한 다양한 개선 사항들이 제안되었습니다.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

id BIGINT AUTO_INCREMENT PRIMARY KEY,
review_id BIGINT NOT NULL,
language VARCHAR(10) NOT NULL,
translated_content VARCHAR(600) NOT NULL,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

[작성자: 리뷰어, 날짜: 2025-05-15] 번역된 내용이 600자를 초과할 경우 데이터 절삭 에러가 발생할 수 있으므로 TEXT 타입이나 더 큰 VARCHAR 타입을 사용하는 것을 권장합니다.

    translated_content TEXT         NOT NULL,

@Slf4j
@RequiredArgsConstructor
@Service
@Transactional

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

[작성자: 리뷰어, 날짜: 2025-05-15] 외부 API(DeepL) 호출을 데이터베이스 트랜잭션 내에서 수행하면 커넥션을 불필요하게 오래 점유하여 커넥션 풀 고갈 장애를 유발할 수 있으므로, 트랜잭션 범위를 축소하여 외부 API 호출을 트랜잭션 외부로 분리하는 것을 강력히 권장합니다.

Comment thread src/main/java/ssu/eatssu/domain/review/service/ReviewTranslationService.java Outdated
Comment on lines +17 to +18
factory.setConnectTimeout(2000);
factory.setReadTimeout(3000);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

[작성자: 리뷰어, 날짜: 2025-05-15] Spring 6 / Spring Boot 3 환경에서는 정수형 timeout 설정 메서드가 deprecated 되었으므로 Duration을 사용하는 것을 권장합니다.

Suggested change
factory.setConnectTimeout(2000);
factory.setReadTimeout(3000);
factory.setConnectTimeout(java.time.Duration.ofMillis(2000));
factory.setReadTimeout(java.time.Duration.ofMillis(3000));

Comment on lines +158 to +164
@PostMapping("/{reviewId}/translate")
public BaseResponse<ReviewTranslationResponse> translateReview(
@Parameter(description = "reviewId") @PathVariable("reviewId") Long reviewId,
@Parameter(description = "번역 대상 언어(현재 EN만 지원)") @RequestParam Language language,
@AuthenticationPrincipal CustomUserDetails customUserDetails) {
return BaseResponse.success(reviewTranslationService.translateReview(reviewId, language));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

[작성자: 리뷰어, 날짜: 2025-05-15] 컨트롤러 메서드에서 사용되지 않는 @AuthenticationPrincipal CustomUserDetails 매개변수는 제거하여 코드를 깔끔하게 유지하는 것이 좋습니다.

    @PostMapping("/{reviewId}/translate")
    public BaseResponse<ReviewTranslationResponse> translateReview(
            @Parameter(description = "reviewId") @PathVariable("reviewId") Long reviewId,
            @Parameter(description = "번역 대상 언어(현재 EN만 지원)") @RequestParam Language language) {
        return BaseResponse.success(reviewTranslationService.translateReview(reviewId, language));
    }

@Slf4j
@RequiredArgsConstructor
@Service
@Transactional

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

메서드마다 트랜잭션 명시해주는 게 더 좋을 듯!
전체 서비스 클래스에 트랜잭션을 걸게 되면 외부 API호출 시에도 트랜잭션을 잡고 있어서
커넥션이 고갈될 수 있음


#DeepL
deepl:
api-key: ${EATSSU_DEEPL_API_KEY}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

이거 추가하면 github secret도 같이 변경해야 할 듯

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

넵 필요한 곳 다 추가 했습니당

@sjinssun
sjinssun merged commit 0257c1e into develop Jul 13, 2026
1 check passed
@sjinssun
sjinssun deleted the feat/#416-review-trans branch July 13, 2026 13:33
@pooreumjung pooreumjung changed the title [Feat] 리뷰 번역기능 추가 feat: 리뷰 번역기능 추가 Jul 19, 2026
@pooreumjung pooreumjung added the feat 개발, 구현 label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 개발, 구현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature: 리뷰번역 기능 추가

2 participants