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:
1 parent
3d0f260653
commit
4060a91d28
41 files changed
+2331
-1
No files matched your search
@@ -79,6 +79,7 @@ class Post extends Model implements FulltextSearchable
|
||||
'replies_count',
|
||||
'comments_count',
|
||||
'attachments_count',
|
||||
'reaction_counts',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -99,6 +100,8 @@ class Post extends Model implements FulltextSearchable
|
||||
'replies_count' => 'integer',
|
||||
'comments_count' => 'integer',
|
||||
'attachments_count' => 'integer',
|
||||
// 반응 유형별 개수 (키는 유형 ID 문자열, 예: {"1":18,"2":2})
|
||||
'reaction_counts' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime',
|
||||
@@ -107,6 +110,8 @@ class Post extends Model implements FulltextSearchable
|
||||
|
||||
/**
|
||||
* 게시판과의 관계를 정의합니다.
|
||||
*
|
||||
* @return BelongsTo<Board, Post>
|
||||
*/
|
||||
public function board(): BelongsTo
|
||||
{
|
||||
@@ -115,6 +120,8 @@ class Post extends Model implements FulltextSearchable
|
||||
|
||||
/**
|
||||
* 작성자와의 관계를 정의합니다 (회원).
|
||||
*
|
||||
* @return BelongsTo<User, Post>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
@@ -123,6 +130,8 @@ class Post extends Model implements FulltextSearchable
|
||||
|
||||
/**
|
||||
* 부모 게시글과의 관계를 정의합니다 (답글용).
|
||||
*
|
||||
* @return BelongsTo<Post, Post>
|
||||
*/
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
@@ -134,6 +143,8 @@ class Post extends Model implements FulltextSearchable
|
||||
*
|
||||
* board_id 조건은 Eager loading 호환을 위해 관계에서 제외하고
|
||||
* Repository의 Eager loading 클로저에서 명시적으로 전달합니다.
|
||||
*
|
||||
* @return HasMany<Post>
|
||||
*/
|
||||
public function replies(): HasMany
|
||||
{
|
||||
@@ -145,6 +156,8 @@ class Post extends Model implements FulltextSearchable
|
||||
*
|
||||
* board_id 조건은 Eager loading 호환을 위해 관계에서 제외하고
|
||||
* Repository의 Eager loading 클로저에서 명시적으로 전달합니다.
|
||||
*
|
||||
* @return HasMany<Comment>
|
||||
*/
|
||||
public function comments(): HasMany
|
||||
{
|
||||
@@ -157,6 +170,8 @@ class Post extends Model implements FulltextSearchable
|
||||
*
|
||||
* board_id 조건은 Eager loading 호환을 위해 관계에서 제외하고
|
||||
* Repository의 Eager loading 클로저에서 명시적으로 전달합니다.
|
||||
*
|
||||
* @return HasMany<Attachment>
|
||||
*/
|
||||
public function attachments(): HasMany
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user