Skip to content

feat: implement Domain layer for Favorite Heritage API / お気に入りAPIのDomain層実装 #551

Description

@zigzagdev

Parent Issue / 親Issue

#550

Motivation / 目的

Implement the Domain layer for the Favorite Heritage API as part of #550: the repository interface and the migration for the new intermediate table. No FavoriteEntity is introduced — a favorite has no behavior/invariants beyond the (user, heritage) pair existing, so the repository interface works directly with primitive IDs instead of wrapping them in an Entity.

お気に入りAPIのDomain層(#550)として、リポジトリインターフェースと中間テーブルのmigrationを実装します。FavoriteEntityは作成しません。お気に入りは(user, heritage)の組が存在するだけで振る舞い・不変条件を持たないため、Entityでラップせずリポジトリインターフェースは素のIDを直接扱います。

What to do / 実施内容

Migration

Repository Interface

  • FavoriteRepositoryInterface.php
    • add(int $userId, int $worldHeritageId): void
    • remove(int $userId, int $worldHeritageId): void
    • existsForUser(int $userId, int $worldHeritageId): bool
    • findHeritageIdsByUserId(int $userId): array

Exception

  • FavoriteAlreadyExistsException: 既に登録済みのお気に入りを再登録しようとした場合にスロー
  • FavoriteNotFoundException: 未登録のお気に入りを解除しようとした場合にスロー

Tests / テスト

  • Migration実行後、favorite_heritages テーブルが期待するカラム・FK・unique制約を持つことの確認

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions