feat: add GetAllEpisodes to anime domain and service
This commit is contained in:
@@ -155,3 +155,20 @@ func (s *animeService) GetEpisodes(ctx context.Context, id int, page int) (jikan
|
|||||||
func (s *animeService) GetRandomAnime(ctx context.Context) (domain.Anime, error) {
|
func (s *animeService) GetRandomAnime(ctx context.Context) (domain.Anime, error) {
|
||||||
return s.jikan.GetRandomAnime(ctx)
|
return s.jikan.GetRandomAnime(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *animeService) GetAllEpisodes(ctx context.Context, id int) ([]domain.EpisodeData, error) {
|
||||||
|
episodes, err := s.jikan.GetAllEpisodes(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := make([]domain.EpisodeData, len(episodes))
|
||||||
|
for i, ep := range episodes {
|
||||||
|
result[i] = domain.EpisodeData{
|
||||||
|
MalID: ep.MalID,
|
||||||
|
Title: ep.Title,
|
||||||
|
IsFiller: ep.Filler,
|
||||||
|
IsRecap: ep.Recap,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ type AnimeService interface {
|
|||||||
GetRecommendations(ctx context.Context, id int) ([]Recommendation, error)
|
GetRecommendations(ctx context.Context, id int) ([]Recommendation, error)
|
||||||
GetRelations(ctx context.Context, id int) ([]jikan.RelationEntry, error)
|
GetRelations(ctx context.Context, id int) ([]jikan.RelationEntry, error)
|
||||||
GetEpisodes(ctx context.Context, id int, page int) (jikan.EpisodesResponse, error)
|
GetEpisodes(ctx context.Context, id int, page int) (jikan.EpisodesResponse, error)
|
||||||
|
GetAllEpisodes(ctx context.Context, id int) ([]EpisodeData, error)
|
||||||
GetRandomAnime(ctx context.Context) (Anime, error)
|
GetRandomAnime(ctx context.Context) (Anime, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user