Conversation
Walkthrough조직 수정(Update) 기능이 구현되었습니다. 요청 DTO에 필드와 검증을 추가하고, 서비스에서 존재 및 소유권을 확인한 뒤 엔티티의 modifyInfo를 호출해 변경사항을 저장하고 업데이트 응답을 반환합니다. Changes
Sequence DiagramsequenceDiagram
participant Client
participant OrgController
participant OrgServiceImpl
participant OrgRepository
participant Organization
participant OrgErrorCode
Client->>OrgController: PATCH /organizations/{orgId}\n(userId, OrgRequest.Update)
OrgController->>OrgController: 요청 바인딩 및 `@Valid` 검증
OrgController->>OrgServiceImpl: modifyOrganization(userId, orgId, request)
OrgServiceImpl->>OrgRepository: findById(orgId)
OrgRepository-->>OrgServiceImpl: Organization or empty
alt 조직 없음
OrgServiceImpl->>OrgErrorCode: ORG_NOT_FOUND
OrgServiceImpl-->>Client: 404 응답
else 조직 존재
OrgServiceImpl->>OrgServiceImpl: ownerUserId == userId 검증
alt 소유자 불일치
OrgServiceImpl->>OrgErrorCode: ORG_UPDATE_FORBIDDEN
OrgServiceImpl-->>Client: 403 응답
else 소유자 일치
OrgServiceImpl->>Organization: modifyInfo(request)
Organization->>Organization: name, description, logoUrl 갱신
OrgServiceImpl->>OrgRepository: save(organization)
OrgRepository-->>OrgServiceImpl: 저장 완료
OrgServiceImpl-->>OrgController: OrgResponse.Update
OrgController-->>Client: 200 응답 (DataResponse<OrgResponse.Update>)
end
end
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly Related PRs
Suggested Reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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 제약도 지금처럼 두어도 될 듯 합니다!
넵 그러면 응답값만 200 OK 로 해서 Body 에 DTO 반환하는 방식으로 해볼게요! |
kingmingyu
left a comment
There was a problem hiding this comment.
고생하셨습니다! 수정할 때 변한 값도 응답하는 거 참고하겠습니다!
📌 관련 이슈
🚀 개요
조직 정보 수정 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
릴리스 노트
새로운 기능
문서