Skip to content

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

Description

@zigzagdev

Parent Issue / 親Issue

#550

Motivation / 目的

Implement the persistence layer for favorites as part of #550. The intermediate table migration is covered in #551 (Domain layer); this issue implements the Eloquent model and repository on top of it.

お気に入りAPIのInfra層(#550)として、リポジトリ実装を行います。中間テーブルのmigrationは #551(Domain層)で対応するため、本Issueでは Eloquentモデルとリポジトリの実装のみを行います。

What to do / 実施内容

Eloquent Model

  • FavoriteHeritage

Repository

  • FavoriteRepository implements FavoriteRepositoryInterface
    • add: 重複時は FavoriteAlreadyExistsException をスロー
    • remove: 対象が無ければ FavoriteNotFoundException をスロー
    • existsForUser
    • findHeritageIdsByUserId

Tests / テスト

実DB(heritage-mysql-test)を使ったインテグレーションテスト

  • test_add_creates_favorite_record
  • test_add_throws_exception_when_already_favorited
  • test_remove_deletes_favorite_record
  • test_remove_throws_exception_when_not_favorited
  • test_existsForUser_returns_true_when_favorited
  • test_existsForUser_returns_false_when_not_favorited
  • test_findHeritageIdsByUserId_returns_ids_in_order

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