Skip to content

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

Description

@zigzagdev

Parent Issue / 親Issue

#550

Motivation / 目的

Implement the Application layer use cases for adding, removing, and listing favorites as part of #550.

お気に入りAPIのApplication層(#550)として、登録・解除・一覧取得のUseCaseを実装します。

What to do / 実施内容

CommandUseCases

  • AddFavoriteUseCommand (userId, worldHeritageId)
  • AddFavoriteUseCase: FavoriteRepositoryInterface::add() を呼び出す
  • RemoveFavoriteUseCommand (userId, worldHeritageId)
  • RemoveFavoriteUseCase: FavoriteRepositoryInterface::remove() を呼び出す

QueryUseCases

  • ListMyFavoritesUseCase
    • FavoriteRepositoryInterface::findHeritageIdsByUserId() でお気に入りのIDを取得
    • WorldHeritageReadQueryServiceInterface::findByIdsPreserveOrder() で世界遺産データを取得(既存の仕組みを再利用)
    • ViewModelへ変換して返却

Tests / テスト

Mockeryを使ったユニットテスト

  • test_handle_calls_repository_add
  • test_handle_throws_exception_when_already_favorited
  • test_handle_calls_repository_remove
  • test_handle_throws_exception_when_not_favorited
  • test_handle_returns_favorite_heritages_for_user
  • test_handle_returns_empty_list_when_no_favorites

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