Conversation
Walkthrough조직 정보 수정 API를 구현했습니다. 요청 DTO에 필드를 추가하고, 서비스 계층에서 조직 존재 여부 및 소유권을 검증한 후 엔티티의 수정 메서드를 호출하는 플로우를 완성했습니다. Changes
Sequence DiagramsequenceDiagram
participant Client
participant OrgController
participant OrgServiceImpl
participant OrgRepository
participant Organization
participant OrgErrorCode
Client->>OrgController: PATCH /organizations/{orgId}<br/>(userId, OrgRequest.Update)
OrgController->>OrgController: `@Valid로` 요청 검증
OrgController->>OrgServiceImpl: modifyOrganization(userId, orgId, request)
OrgServiceImpl->>OrgRepository: findById(orgId)
OrgRepository-->>OrgServiceImpl: Optional<Organization>
alt 조직 미존재
OrgServiceImpl->>OrgErrorCode: ORG_NOT_FOUND
OrgErrorCode-->>OrgServiceImpl: 404 예외
OrgServiceImpl-->>Client: 404 응답
else 조직 존재
OrgServiceImpl->>OrgServiceImpl: owner.userId == userId 검증
alt 소유자 불일치
OrgServiceImpl->>OrgErrorCode: ORG_UPDATE_FORBIDDEN
OrgErrorCode-->>OrgServiceImpl: 403 예외
OrgServiceImpl-->>Client: 403 응답
else 소유자 일치
OrgServiceImpl->>Organization: modifyInfo(request)
Organization->>Organization: name, description, logoUrl 업데이트
OrgServiceImpl->>OrgRepository: save(organization)
OrgRepository-->>OrgServiceImpl: 저장 완료
OrgServiceImpl-->>Client: 204 No Content
end
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Suggested Reviewers
💡 시니어 개발자의 의견✅ 잘 구현된 부분
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Title check | PR 제목 'Feat/#26'은 이슈 번호만 포함하고 있어 실제 변경 내용을 전혀 설명하지 못합니다. | 제목을 '조직 정보 수정 API 추가' 또는 'feat: Add organization update API endpoint' 처럼 변경하여 핵심 변경 내용을 명확하게 전달해주세요. | |
| Docstring Coverage | Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description check | ✅ Passed | PR 설명이 템플릿을 잘 따르고 있으며, 작업 내용, 테스트 결과, 체크리스트, 리뷰 포인트가 모두 포함되어 있습니다. |
| Linked Issues check | ✅ Passed | PR의 모든 코드 변경이 연결된 이슈 #26의 '조직 정보 수정(Update) API 추가' 요구사항을 충족합니다. |
| Out of Scope Changes check | ✅ Passed | 모든 코드 변경이 조직 수정 API 구현에 필요한 범위 내에 있습니다. 불필요한 변경이나 추가 기능은 없습니다. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
feat/#26
Important
Action Needed: IP Allowlist Update
If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
- ✨
136.113.208.247/32(new) 34.170.211.100/3235.222.179.152/32
Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In
`@src/main/java/com/whereyouad/WhereYouAd/domains/organization/persistence/entity/Organization.java`:
- Around line 40-43: modifyInfo currently overwrites existing fields with null
when description or logoUrl are omitted; change
Organization.modifyInfo(OrgRequest.Update) to only assign
name/description/logoUrl if the incoming value is non-null (e.g., if
(request.description() != null) this.description = request.description(); and
similarly for logoUrl) or alternatively use a distinct partial-update DTO,
ensuring OrgRequest.Update is not blindly applied and existing values are
preserved when nulls are passed.
In
`@src/main/java/com/whereyouad/WhereYouAd/domains/organization/presentation/docs/OrgControllerDocs.java`:
- Around line 27-40: The API documentation in OrgControllerDocs.java for
modifyOrganization uses incorrect responseCode strings ("403_1", "404_1");
update the `@ApiResponse` entries to match the actual OrgErrorCode constants (use
"ORG_403_1" and "ORG_404_1") so the documented response codes align with
OrgErrorCode; search for and fix any other `@ApiResponse` entries in
OrgControllerDocs that reference the shorthand codes to use the full constant
names.
🧹 Nitpick comments (1)
src/main/java/com/whereyouad/WhereYouAd/domains/organization/persistence/entity/Organization.java (1)
3-41: 엔티티가 요청 DTO에 직접 의존Organization이 OrgRequest.Update에 직접 의존하면 계층 방향이 뒤집혀 유지보수성이 떨어집니다. 도메인 메서드는 primitive 인자(또는 도메인 커맨드)로 받고, 매핑은 서비스/컨버터로 이동하는 편이 좋습니다.
♻️ 리팩터링 예시
- public void modifyInfo(OrgRequest.Update request) { - this.name = request.name(); - this.description = request.description(); - this.logoUrl = request.logoUrl(); - } + public void modifyInfo(String name, String description, String logoUrl) { + this.name = name; + this.description = description; + this.logoUrl = logoUrl; + }
| public void modifyInfo(OrgRequest.Update request) { | ||
| this.name = request.name(); | ||
| this.description = request.description(); | ||
| this.logoUrl = request.logoUrl(); |
There was a problem hiding this comment.
PATCH에서 null 덮어쓰기로 데이터 유실 가능
description/logoUrl을 생략하면 null이 저장되어 기존 값이 사라질 수 있어요. 부분 업데이트 의도라면 null은 유지하도록 가드하거나 별도 DTO로 분리하는 게 안전합니다.
🛠️ 수정 예시 (null 유지)
public void modifyInfo(OrgRequest.Update request) {
- this.name = request.name();
- this.description = request.description();
- this.logoUrl = request.logoUrl();
+ if (request.name() != null) {
+ this.name = request.name();
+ }
+ if (request.description() != null) {
+ this.description = request.description();
+ }
+ if (request.logoUrl() != null) {
+ this.logoUrl = request.logoUrl();
+ }
}🤖 Prompt for AI Agents
In
`@src/main/java/com/whereyouad/WhereYouAd/domains/organization/persistence/entity/Organization.java`
around lines 40 - 43, modifyInfo currently overwrites existing fields with null
when description or logoUrl are omitted; change
Organization.modifyInfo(OrgRequest.Update) to only assign
name/description/logoUrl if the incoming value is non-null (e.g., if
(request.description() != null) this.description = request.description(); and
similarly for logoUrl) or alternatively use a distinct partial-update DTO,
ensuring OrgRequest.Update is not blindly applied and existing values are
preserved when nulls are passed.
| @Operation( | ||
| summary = "조직 정보 수정 API", | ||
| description = "새로운 조직 이름, 설명, 로고 이미지 URL 을 받아 저장(해당 조직을 생성한 회원만 정보 변경 가능)" | ||
| ) | ||
| @ApiResponses({ | ||
| @ApiResponse(responseCode = "204", description = "성공(응답X)"), | ||
| @ApiResponse(responseCode = "403_1", description = "허가되지 않은 회원의 요청(조직 생성 회원 X)"), | ||
| @ApiResponse(responseCode = "404_1", description = "해당 id 조직 존재 X") | ||
| }) | ||
| public ResponseEntity<Void> modifyOrganization( | ||
| @AuthenticationPrincipal(expression = "userId") Long userId, | ||
| @PathVariable Long orgId, | ||
| @RequestBody @Valid OrgRequest.Update request | ||
| ); |
There was a problem hiding this comment.
문서의 에러 코드 값 일치 여부 확인
OrgErrorCode는 ORG_403_1, ORG_404_1인데 문서에는 403_1, 404_1로 표기되어 있습니다. 실제 응답 코드와 동일하게 맞추는 게 좋아요.
📝 문서 수정 예시
- `@ApiResponse`(responseCode = "403_1", description = "허가되지 않은 회원의 요청(조직 생성 회원 X)"),
- `@ApiResponse`(responseCode = "404_1", description = "해당 id 조직 존재 X")
+ `@ApiResponse`(responseCode = "ORG_403_1", description = "허가되지 않은 회원의 요청(조직 생성 회원 X)"),
+ `@ApiResponse`(responseCode = "ORG_404_1", description = "해당 id 조직 존재 X")📝 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.
| @Operation( | |
| summary = "조직 정보 수정 API", | |
| description = "새로운 조직 이름, 설명, 로고 이미지 URL 을 받아 저장(해당 조직을 생성한 회원만 정보 변경 가능)" | |
| ) | |
| @ApiResponses({ | |
| @ApiResponse(responseCode = "204", description = "성공(응답X)"), | |
| @ApiResponse(responseCode = "403_1", description = "허가되지 않은 회원의 요청(조직 생성 회원 X)"), | |
| @ApiResponse(responseCode = "404_1", description = "해당 id 조직 존재 X") | |
| }) | |
| public ResponseEntity<Void> modifyOrganization( | |
| @AuthenticationPrincipal(expression = "userId") Long userId, | |
| @PathVariable Long orgId, | |
| @RequestBody @Valid OrgRequest.Update request | |
| ); | |
| `@Operation`( | |
| summary = "조직 정보 수정 API", | |
| description = "새로운 조직 이름, 설명, 로고 이미지 URL 을 받아 저장(해당 조직을 생성한 회원만 정보 변경 가능)" | |
| ) | |
| `@ApiResponses`({ | |
| `@ApiResponse`(responseCode = "ORG_403_1", description = "허가되지 않은 회원의 요청(조직 생성 회원 X)"), | |
| `@ApiResponse`(responseCode = "ORG_404_1", description = "해당 id 조직 존재 X") | |
| }) | |
| public ResponseEntity<Void> modifyOrganization( | |
| `@AuthenticationPrincipal`(expression = "userId") Long userId, | |
| `@PathVariable` Long orgId, | |
| `@RequestBody` `@Valid` OrgRequest.Update request | |
| ); |
🤖 Prompt for AI Agents
In
`@src/main/java/com/whereyouad/WhereYouAd/domains/organization/presentation/docs/OrgControllerDocs.java`
around lines 27 - 40, The API documentation in OrgControllerDocs.java for
modifyOrganization uses incorrect responseCode strings ("403_1", "404_1");
update the `@ApiResponse` entries to match the actual OrgErrorCode constants (use
"ORG_403_1" and "ORG_404_1") so the documented response codes align with
OrgErrorCode; search for and fix any other `@ApiResponse` entries in
OrgControllerDocs that reference the shorthand codes to use the full constant
names.
jinnieusLab
left a comment
There was a problem hiding this comment.
P4: 고생하셨습니다! 제 생각에는 수정 요청 이후 프론트가 별도 GET api 요청을 하는 불편함을 줄이기 위해서, 수정 응답을 그대로 쓸 수 있게 변경 내용을 함께 포함하는 것도 괜찮을 것 같습니다! 그리고 @notblank 제약도 지금처럼 두어도 될 듯 합니다!
📌 관련 이슈
🚀 개요
조직 정보 수정 API 추가
📄 작업 내용
📸 스크린샷 / 테스트 결과 (선택)
===이름 test 인 유저(id = 1) 가 생성한 org1 조직의 이름, 설명, 로고 이미지 URL 변경하기===
DB organization 테이블 변경 내역 확인 가능

===예외 처리===
1-1. id = 2 인 test2 사용자로 로그인, 토큰 획득

1-2. test2 사용자의 AccessToken 으로 org1 조직 정보 변경 요청 시 예외처리 (403 Forbidden)

✅ 체크리스트
🔍 리뷰 포인트 (Review Points)
Summary by CodeRabbit
릴리스 노트