Skip to content

Feat: getBody 전체 조회 API 구현 - #332

Merged
seoyeonjin merged 4 commits into
devfrom
feat/#331
Mar 7, 2026
Merged

seoyeonjin merged 4 commits into
devfrom
feat/#331

Conversation

@seoyeonjin

@seoyeonjin seoyeonjin commented Mar 7, 2026 •

Copy link
Copy Markdown
Collaborator

🔥Pull requests

⛳️ 작업한 브랜치

👷 작업한 내용

  • 전체 body 조회가 가능하도록 변경했습니다. (petProblem required = false 로 수정)

🚨 참고 사항

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 신체 목록 조회 엔드포인트가 선택적 필터링을 지원합니다. 이제 필터 없이 모든 신체 정보를 조회할 수 있습니다.
  • 버그 수정

    • 유효하지 않은 입력에 대한 오류 처리를 개선했습니다.
  • 테스트

    • 신체 목록 전체 조회 시나리오에 대한 테스트를 추가했습니다.

@seoyeonjin seoyeonjin self-assigned this Mar 7, 2026
@seoyeonjin seoyeonjin added the 🍀feat 기능 개발 label Mar 7, 2026
@coderabbitai

coderabbitai Bot commented Mar 7, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

개요

getBodies API에서 petProblem 매개변수를 선택사항으로 변경하여 null일 때 전체 body 리스트를 반환하도록 수정했습니다. 새로운 에러 메시지 상수와 null-안전 처리 로직이 추가되었습니다.

변경 사항

Cohort / File(s) 요약
컨트롤러 계층
src/main/java/com/cocos/cocos/api/body/controller/BodyController.java, src/main/java/com/cocos/cocos/api/body/controller/BodyControllerSwagger.java
petProblem 매개변수를 @RequestParam(required = false)로 변경하여 선택사항으로 설정. Swagger 문서도 동기화.
서비스 계층
src/main/java/com/cocos/cocos/api/body/service/BodyService.java
getBodies 메서드에 null-안전 처리 추가. petProblem이 null이면 전체 body 리스트 반환, 그렇지 않으면 필터링된 결과 반환하는 private 헬퍼 메서드 findBodiesByPetProblem 신규 추가.
에러 처리
src/main/java/com/cocos/cocos/enums/message/FailMessage.java, src/main/java/com/cocos/cocos/enums/pet/PetProblem.java
새로운 enum 상수 BAD_REQUEST_INVALID_PET_PROBLEM 추가. PetProblem.create에서 IllegalStateException을 CocosException으로 변경하여 구조화된 에러 처리 적용.
테스트
src/test/java/com/cocos/cocos/body/BodyServiceTest.java
새로운 테스트 메서드 getAllBodies 추가. petProblem이 null일 때 전체 body 리스트를 올바르게 반환하는지 검증.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경 사항의 핵심을 명확하게 반영하고 있습니다. 'getBody 전체 조회 API 구현'은 petProblem이 null일 때 전체 body를 조회할 수 있도록 만드는 변경의 주요 목적을 정확히 표현합니다.
Description check ✅ Passed PR 설명이 저장소의 템플릿 구조를 따르고 있으며, 이슈 번호(#331)와 작업 내용(전체 body 조회 구현, petProblem required = false 수정)이 명시되어 있습니다.
Linked Issues check ✅ Passed PR의 모든 변경사항이 이슈 #331의 목표를 충족합니다. BodyController와 Swagger에서 petProblem을 선택사항으로 변경하고, BodyService에서 null 처리 로직을 추가하여 petProblem이 null일 때 전체 body 리스트를 반환하도록 구현했습니다.
Out of Scope Changes check ✅ Passed PR에 포함된 모든 변경사항이 이슈 #331의 범위 내입니다. FailMessage에 새로운 enum 상수를 추가하고 PetProblem의 예외 처리를 개선한 부분도 API 기능 구현을 위한 필요한 보조 작업입니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#331

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/test/java/com/cocos/cocos/body/BodyServiceTest.java (1)

110-122: 브랜치 선택까지 검증하면 회귀 방지에 더 좋습니다.

지금 테스트는 결과만 비교해서, null 경로에서 findAll() 외 조회가 추가돼도 우연히 같은 결과면 통과할 수 있습니다. 이 케이스의 핵심 의도가 “Line 119에서 null이면 전체 조회 branch를 탄다”인 만큼, findAll() 호출과 findAllById(...) 미호출까지 같이 검증해 두면 테스트가 더 단단해집니다.

예시
         //then
         Assertions.assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
+        BDDMockito.then(bodyRepository).should().findAll();
+        BDDMockito.then(bodyRepository).should(never()).findAllById(any());
+        BDDMockito.then(diseaseRepository).shouldHaveNoInteractions();

필요하면 import static org.mockito.Mockito.never;도 추가해 주세요.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/com/cocos/cocos/body/BodyServiceTest.java` around lines 110 -
122, The test only asserts the returned BodiesResponse but doesn't verify which
repository branch was used; update the test around the call to
bodyService.getBodies(null) to explicitly verify that bodyRepository.findAll()
was invoked and that bodyRepository.findAllById(...) was never invoked (use
Mockito.verify(bodyRepository).findAll() and Mockito.verify(bodyRepository,
never()).findAllById(...)), and add the static import for Mockito.never if
needed; this ensures the null branch behavior in getBodies(...) is enforced.
src/main/java/com/cocos/cocos/api/body/controller/BodyControllerSwagger.java (1)

21-21: 선택적 매개변수의 동작을 설명에 추가하세요.

Line 21의 petProblem이 required = false인데, 현재 설명 "반려동물 문제(DISEASE or SYMPTOM)"에는 이 매개변수를 생략할 때의 동작(전체 조회)이 나타나지 않습니다. 사용자 입장에서 Swagger 문서를 볼 때 이 매개변수를 전달하지 않으면 어떻게 되는지 명확히 알 수 있도록 설명을 개선하는 것이 좋습니다.

예: "반려동물 문제(DISEASE or SYMPTOM). 미입력 시 전체 조회"

참고: schema = @Schema(type = "String") 설정은 enum 값 노출을 막지 않으므로 현재 상태로도 Swagger에는 허용 enum 값이 제대로 표시됩니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/cocos/cocos/api/body/controller/BodyControllerSwagger.java`
at line 21, 주석의 `@Parameter`(name = "petProblem", ...) 설명이 선택적(required = false)일
때의 동작을 명시하지 않으므로 BodyControllerSwagger.java의 petProblem Parameter 설명을 "반려동물
문제(DISEASE or SYMPTOM). 미입력 시 전체 조회"처럼 수정해 생략 시 전체 조회된다는 동작을 명확히 적어주고, 기존 schema
= `@Schema`(type = "String") 설정은 유지하여 enum 노출에는 영향이 없음을 확인하세요.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@src/main/java/com/cocos/cocos/api/body/controller/BodyControllerSwagger.java`:
- Line 21: 주석의 `@Parameter`(name = "petProblem", ...) 설명이 선택적(required = false)일
때의 동작을 명시하지 않으므로 BodyControllerSwagger.java의 petProblem Parameter 설명을 "반려동물
문제(DISEASE or SYMPTOM). 미입력 시 전체 조회"처럼 수정해 생략 시 전체 조회된다는 동작을 명확히 적어주고, 기존 schema
= `@Schema`(type = "String") 설정은 유지하여 enum 노출에는 영향이 없음을 확인하세요.

In `@src/test/java/com/cocos/cocos/body/BodyServiceTest.java`:
- Around line 110-122: The test only asserts the returned BodiesResponse but
doesn't verify which repository branch was used; update the test around the call
to bodyService.getBodies(null) to explicitly verify that
bodyRepository.findAll() was invoked and that bodyRepository.findAllById(...)
was never invoked (use Mockito.verify(bodyRepository).findAll() and
Mockito.verify(bodyRepository, never()).findAllById(...)), and add the static
import for Mockito.never if needed; this ensures the null branch behavior in
getBodies(...) is enforced.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2465562a-1f54-43c7-93eb-b2825375793b

📥 Commits

Reviewing files that changed from the base of the PR and between 66013cd and 394d13f.

📒 Files selected for processing (6)
  • src/main/java/com/cocos/cocos/api/body/controller/BodyController.java
  • src/main/java/com/cocos/cocos/api/body/controller/BodyControllerSwagger.java
  • src/main/java/com/cocos/cocos/api/body/service/BodyService.java
  • src/main/java/com/cocos/cocos/enums/message/FailMessage.java
  • src/main/java/com/cocos/cocos/enums/pet/PetProblem.java
  • src/test/java/com/cocos/cocos/body/BodyServiceTest.java

@seoyeonjin
seoyeonjin merged commit 56b836a into dev Mar 7, 2026
2 checks passed
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.

Feat: petProblem이 null일 때 전체 body 리스트 반환

1 participant