refactor(word): clean up API boundary handling#339
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
word 도메인의 API 경계 처리를 정리합니다.
WordResponseMapper로 분리@PreAuthorize("hasRole('ADMIN')")명시Meaning,RelatedForms를 DTO 패키지에서 도메인 공유 값 모델 패키지로 이동WordsController미사용 import 정리Problem
기존 word API 경계에는 몇 가지 책임 혼재가 있었습니다.
WordService가 비즈니스 흐름과 응답 DTO 조립을 함께 담당했습니다.Meaning,RelatedForms가 DTO 패키지에 있으면서 엔티티 저장 모델에도 사용되었습니다.Solution
컨트롤러, 서비스, DTO, 도메인 값 모델의 책임을 더 명확히 분리했습니다.
WordResponseMapper로 위임했습니다.INVALID_INPUT기반 400 응답으로 처리합니다.WordValidator를 통해 단어를 검증/정규화합니다.word.model패키지로 이동했습니다.Changes
WordResponseMapper추가GlobalExceptionHandler에MethodArgumentTypeMismatchException처리 추가WordsAdminController입력 검증 및 관리자 권한 명시Meaning,RelatedForms패키지 이동:word.dto->word.modelExample
잘못된 요청 파라미터:
이제 서버 내부 오류가 아니라 400 응답으로 처리됩니다.
{ "message": "targetLanguage: 올바르지 않은 값입니다" }관리자 강제 분석 API도 입력 단어를 동일하게 정규화합니다.
Validation
./gradlew compileJava./gradlew test --tests com.linglevel.api.word.service.WordServiceTest./gradlew test --tests com.linglevel.api.common.handler.GlobalExceptionHandlerTest --tests com.linglevel.api.word.service.WordServiceTest./gradlew test --tests com.linglevel.api.word.controller.WordsAdminControllerTest --tests com.linglevel.api.word.service.WordServiceTest./gradlew test --tests com.linglevel.api.word.service.WordServiceTest --tests com.linglevel.api.word.service.WordVariantServiceTest --tests com.linglevel.api.word.controller.WordsAdminControllerTest --tests com.linglevel.api.word.validator.WordValidatorTestRelated Issues