Skip to content

[feature] 홍보게시판 CRUD를 동아리 관리자에게 개방 - #2003

Merged
seongwon030 merged 1 commit into
develop/befrom
promo-board-crud-club-admin
Sep 5, 2026
Merged

[feature] 홍보게시판 CRUD를 동아리 관리자에게 개방#2003
seongwon030 merged 1 commit into
develop/befrom
promo-board-crud-club-admin

Conversation

@seongwon030

@seongwon030 seongwon030 commented Sep 5, 2026

Copy link
Copy Markdown
Member

Summary

  • 홍보게시판 생성/수정/삭제/이미지 업로드 4개 엔드포인트를 hasRole('DEVELOPER')hasAnyRole('DEVELOPER', 'CLUB_ADMIN')으로 개방
  • CLUB_ADMIN: 요청 바디의 clubId는 무시하고 토큰의 동아리로 강제 (거절 대신 덮어쓰기). 타 동아리 게시글 수정/삭제/업로드 시 USER_UNAUTHORIZED(403)
  • 심사 전 동아리 차단: state != AVAILABLE인 동아리의 관리자는 생성/수정 불가. 새 에러코드 PROMOTION_CLUB_NOT_APPROVED(902-2, 403) 추가
  • DEVELOPER: 기존과 동일하게 모든 동아리 게시글 관리 가능, 심사 전 동아리로도 생성 가능
  • 목록 조회 GET은 공개 API 그대로

설계 결정: clubId를 역할별로 다르게 정하는 이유

역할 저장되는 clubId 이유
DEVELOPER 요청 바디 개발자 포털은 다른 동아리를 대신해서 글을 올리는 도구. 개발자 토큰의 clubId는 계정 생성 시 붙는 자리표시자라 의미가 없음
CLUB_ADMIN 토큰 관리자는 자기 동아리에만 글을 쓸 수 있음. 바디 값은 정보를 더하지 않고 위조 가능성만 더함

바디 clubId가 다를 때 거절(403) 대신 덮어쓰기를 택한 트레이드오프

  • 얻는 것: 관리자는 화면에서 clubId를 고를 수 없어서, 그 값이 틀렸다고 거절하면 사용자가 할 수 있는 조치가 없음. 프론트 상태가 꼬여도(계정 전환 후 남은 값 등) 글은 항상 토큰 주인 동아리로 저장됨. 소속 위조 경로가 원천 차단됨.
  • 잃는 것: 프론트가 잘못된 clubId를 보내고 있어도 서버는 성공을 돌려주므로 버그가 드러나지 않음. clubId가 필수값인데 CLUB_ADMIN에게는 무시되는 어색함이 남음.
  • 판단: 관리자 계정 하나에 동아리 하나가 고정된 현재 구조에서는 어긋날 시나리오가 드물어 사용자 경험 안정성을 우선함.

Changes

  • PromotionArticleController, PromotionImageController: @CurrentUser 주입, 권한 완화
  • PromotionArticleService: resolveClubId / validateOwnership / validateClubApproved 추가
  • PromotionImageUploadService: 존재 여부 대신 게시글 조회 후 소유권 검사 (existsActiveById 제거)
  • CustomUserDetails.isDeveloper() 추가, PromotionArticle.update는 확정된 clubId를 인자로 받음

Notes

  • 요청 바디의 clubId는 여전히 @NotBlank라 관리자 클라이언트도 값을 보내야 함 (무시됨). CLUB_ADMIN에 한해 선택값으로 바꾸는 건 후속 작업 후보
  • 삭제/이미지 업로드에는 심사 상태 검사를 걸지 않음. 심사 전 동아리는 자기 게시글을 만들 수 없어 도달할 게시글이 없음
  • 프론트 관리자용 홍보게시판 UI는 별도 작업

Test plan

  • ./gradlew unitTest 전체 통과 (PromotionArticleServiceTest 17건, PromotionImageUploadServiceTest 5건, PromotionArticleControllerTest 1건 포함)
  • CLUB_ADMIN 본인 동아리 생성/수정/삭제/업로드 성공
  • CLUB_ADMIN 타 동아리 게시글 수정/삭제/업로드 → 403
  • 심사 전 동아리 관리자 생성/수정 → 403 (902-2)
  • DEVELOPER 우회 유지
  • 참고: ./gradlew test 전체에서는 Firebase 빈 부재로 Spring 컨텍스트 테스트 20건이 로컬에서 실패하며 본 변경과 무관

- 생성/수정/삭제/이미지 업로드 엔드포인트를 DEVELOPER 전용에서 CLUB_ADMIN까지 허용
- CLUB_ADMIN은 요청의 clubId를 무시하고 토큰의 동아리로 강제
- 타 동아리 게시글 수정/삭제/업로드 시 USER_UNAUTHORIZED(403)
- 심사 전(state != AVAILABLE) 동아리 관리자는 생성/수정 불가 (PROMOTION_CLUB_NOT_APPROVED 902-2)
- DEVELOPER는 기존과 동일하게 모든 동아리 게시글 관리 가능
- 호출처가 사라진 existsActiveById 제거, CustomUserDetails.isDeveloper() 추가

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
moadong Ready Ready Preview Sep 5, 2026 3:58am UTC

@seongwon030 seongwon030 changed the title feat(promotion): 홍보게시판 CRUD를 동아리 관리자에게 개방 [feature] 홍보게시판 CRUD를 동아리 관리자에게 개방 Sep 5, 2026
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

Parsing errors (1)
Validation error: Invalid regex pattern for base branch. at "reviews.auto_review.base_branches[0]"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: dcaf9000-3f4b-48e0-8cff-dc85debf2cd1

📥 Commits

Reviewing files that changed from the base of the PR and between 28403b5 and 777891d.

📒 Files selected for processing (11)
  • backend/src/main/java/moadong/club/controller/PromotionArticleController.java
  • backend/src/main/java/moadong/club/entity/PromotionArticle.java
  • backend/src/main/java/moadong/club/repository/PromotionArticleRepository.java
  • backend/src/main/java/moadong/club/service/PromotionArticleService.java
  • backend/src/main/java/moadong/global/exception/ErrorCode.java
  • backend/src/main/java/moadong/media/controller/PromotionImageController.java
  • backend/src/main/java/moadong/media/service/PromotionImageUploadService.java
  • backend/src/main/java/moadong/user/payload/CustomUserDetails.java
  • backend/src/test/java/moadong/club/controller/PromotionArticleControllerTest.java
  • backend/src/test/java/moadong/club/service/PromotionArticleServiceTest.java
  • backend/src/test/java/moadong/media/service/PromotionImageUploadServiceTest.java
💤 Files with no reviewable changes (1)
  • backend/src/main/java/moadong/club/repository/PromotionArticleRepository.java

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

홍보 게시글과 이미지 업로드 API가 DEVELOPERCLUB_ADMIN을 지원합니다. 서비스는 사용자 역할, 동아리 소유권, 동아리 상태를 검증합니다. 관련 엔드포인트와 단위 테스트가 새 사용자 전달 방식에 맞게 변경되었습니다.

Changes

홍보 콘텐츠 권한 제어

Layer / File(s) Summary
홍보 게시글 권한 검증
backend/src/main/java/moadong/club/controller/PromotionArticleController.java, backend/src/main/java/moadong/club/service/PromotionArticleService.java, backend/src/main/java/moadong/club/entity/PromotionArticle.java, backend/src/main/java/moadong/user/payload/CustomUserDetails.java, backend/src/main/java/moadong/global/exception/ErrorCode.java, backend/src/test/java/moadong/club/controller/PromotionArticleControllerTest.java, backend/src/test/java/moadong/club/service/PromotionArticleServiceTest.java
현재 사용자를 서비스에 전달합니다. CLUB_ADMIN은 본인 동아리 게시글만 처리합니다. CLUB_ADMINAVAILABLE 동아리에서만 생성 및 수정할 수 있습니다. 테스트는 역할, 소유권, 동아리 상태를 검증합니다.
홍보 이미지 업로드 권한 검증
backend/src/main/java/moadong/media/controller/PromotionImageController.java, backend/src/main/java/moadong/media/service/PromotionImageUploadService.java, backend/src/main/java/moadong/club/repository/PromotionArticleRepository.java, backend/src/test/java/moadong/media/service/PromotionImageUploadServiceTest.java
이미지 업로드에 현재 사용자를 전달합니다. 서비스는 활성 게시글을 조회한 뒤 개발자 또는 본인 동아리 관리자인지 검증합니다. 기존 existsActiveById 확인 경로를 제거하고 findActiveById를 사용합니다.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to 77789

Promotion article management and image uploads now allow club administrators only for their own club while preserving developer-wide access; unauthorized cross-club actions and unapproved-club article changes are rejected.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant PromotionArticleController
  participant PromotionArticleService
  participant PromotionArticleRepository
  Client->>PromotionArticleController: 홍보 게시글 요청
  PromotionArticleController->>PromotionArticleService: 사용자와 요청 전달
  PromotionArticleService->>PromotionArticleRepository: 동아리 및 게시글 조회
  PromotionArticleService->>PromotionArticleRepository: 권한 검증 후 저장 또는 삭제
  PromotionArticleService-->>PromotionArticleController: 처리 결과 반환
Loading
sequenceDiagram
  participant Client
  participant PromotionImageController
  participant PromotionImageUploadService
  participant PromotionArticleRepository
  Client->>PromotionImageController: 홍보 이미지 업로드 요청
  PromotionImageController->>PromotionImageUploadService: 사용자와 게시글 ID 전달
  PromotionImageUploadService->>PromotionArticleRepository: 활성 게시글 조회
  PromotionImageUploadService-->>PromotionImageController: 권한 검증 후 업로드 결과 반환
Loading

Suggested reviewers: zepelown

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 50 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 홍보게시판 CRUD를 CLUB_ADMIN에게 개방하는 주요 변경 사항을 정확하고 간결하게 설명합니다.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch promo-board-crud-club-admin

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.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Test Results

363 tests   363 ✅  38s ⏱️
 59 suites    0 💤
 59 files      0 ❌

Results for commit 777891d.

@seongwon030 seongwon030 added ✨ Feature 기능 개발 💾 BE Backend labels Sep 5, 2026
@seongwon030
seongwon030 merged commit 643be23 into develop/be Sep 5, 2026
5 checks passed
@seongwon030
seongwon030 deleted the promo-board-crud-club-admin branch September 5, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💾 BE Backend ✨ Feature 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant