feat(board): 게시글 반응(추천/비추천) 백엔드

DB 스키마 + 백엔드 로직 + API 레이어를 구현.

- board_reaction_types/board_reactions 테이블 신규, boards.use_reaction·
 active_reaction_types, board_posts.reaction_counts 컬럼 추가
- ReactionType(다국어 JSON+폴백)/Reaction 모델, Repository 2종(인터페이스 주입)
- ReactionService: 등록/전환/해제 통합, DB::transaction 원자 카운트,
 use_reaction·비활성유형·본인글·slug 스코프 차단, before/after_react 훅
- POST boards/{slug}/posts/{postId}/react(회원) + GET admin/reaction-types
- ReactPostRequest + AvailableReactionType Rule, PostResource/BoardResource 확장
- 반응 활동 로그(add/change/remove) + ko/en 다국어 + API 레퍼런스 문서
- 테스트 30건(Unit/Feature, 87 assertions) green, 마이그레이션 왕복 안전성 검증

프론트엔드 화면·ja 언어팩·CHANGELOG·버전 bump 는 후속 단계(4~5)에서 진행.
This commit is contained in:
chym1217 committed 2026-08-07 17:00:41 +09:00
1 parent 3d0f260653
commit 4060a91d28
41 files changed
+2331 -1

No files matched your search

@@ -57,6 +57,9 @@ class BoardResource extends BaseApiResource
'use_reply' => $this->use_reply,
'max_reply_depth' => $this->max_reply_depth,
'use_report' => $this->use_report,
'use_reaction' => $this->use_reaction,
'active_reaction_types' => $this->active_reaction_types ?? [],
'reaction_type_options' => self::buildReactionTypeOptions($this->active_reaction_types ?? []),
'comment_order' => $this->comment_order,
'max_comment_depth' => $this->max_comment_depth,
@@ -266,6 +269,35 @@ class BoardResource extends BaseApiResource
return $this->blocked_keywords ?? [];
}
/**
* 게시판이 켠(활성) 반응 유형의 옵션 배열을 만듭니다.
*
* DB 컬럼 `active_reaction_types`(code 문자열 배열)와 `board_reaction_types` 를
* 조인해 프론트가 바로 쓸 수 있는 `{id, code, name, icon}` 배열로 변환합니다.
* 게시판이 켠 유형 중 시스템에서 살아있는(활성) 유형만, display_order 순으로 노출합니다
* (이슈 #525 확정 11 — 게시판 ∩ 시스템). 응답 필드명을 DB 컬럼과 의도적으로 달리해
* 동명이의어를 방지합니다.
*
* @param array<int, string> $activeCodes 게시판이 켠 반응 유형 code 목록
* @return array<int, array<string, mixed>> 반응 유형 옵션 배열
*/
public static function buildReactionTypeOptions(array $activeCodes): array
{
if (empty($activeCodes)) {
return [];
}
$types = app(\Modules\Sirsoft\Board\Repositories\Contracts\ReactionTypeRepositoryInterface::class)
->findByCodes($activeCodes);
return $types->map(fn ($type) => [
'id' => $type->id,
'code' => $type->code,
'name' => $type->getLocalizedName(),
'icon' => $type->icon,
])->values()->all();
}
/**
* 허용 확장자를 배열로 반환합니다.
*