refactor: split AnimeService into segregated interfaces

This commit is contained in:
2026-05-28 12:11:53 +02:00
parent b52cd311a5
commit 794eb8da27

View File

@@ -18,16 +18,25 @@ type Statistics = jikan.Statistics
type ThemesData = jikan.ThemesData type ThemesData = jikan.ThemesData
type ReviewEntry = jikan.ReviewEntry type ReviewEntry = jikan.ReviewEntry
type AnimeService interface { type AnimeCatalogService interface {
GetCatalogSection(ctx context.Context, userID string, section string) (CatalogSectionData, error) GetCatalogSection(ctx context.Context, userID string, section string) (CatalogSectionData, error)
}
type AnimeDiscoverService interface {
GetDiscoverSection(ctx context.Context, userID string, section string) (DiscoverSectionData, error) GetDiscoverSection(ctx context.Context, userID string, section string) (DiscoverSectionData, error)
GetDiscoverForYou(ctx context.Context, userID string) (DiscoverSectionData, error) GetDiscoverForYou(ctx context.Context, userID string) (DiscoverSectionData, error)
GetAiringSchedule(ctx context.Context, userID string) ([]Anime, error) GetAiringSchedule(ctx context.Context, userID string) ([]Anime, error)
GetAnimeByID(ctx context.Context, id int) (Anime, error) }
type AnimeSearchService interface {
SearchAdvanced(ctx context.Context, q, animeType, status, orderBy, sort string, genres []int, studioID int, sfw bool, page, limit int) (jikan.SearchResult, error) SearchAdvanced(ctx context.Context, q, animeType, status, orderBy, sort string, genres []int, studioID int, sfw bool, page, limit int) (jikan.SearchResult, error)
GetProducerNameByID(ctx context.Context, id int) (string, error) GetProducerNameByID(ctx context.Context, id int) (string, error)
GetProducers(ctx context.Context, query string, page int, limit int) (jikan.ProducerListResult, error) GetProducers(ctx context.Context, query string, page int, limit int) (jikan.ProducerListResult, error)
GetGenres(ctx context.Context) ([]Genre, error) GetGenres(ctx context.Context) ([]Genre, error)
}
type AnimeDetailsService interface {
GetAnimeByID(ctx context.Context, id int) (Anime, error)
GetCharacters(ctx context.Context, id int) ([]Character, error) GetCharacters(ctx context.Context, id int) ([]Character, error)
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)
@@ -40,6 +49,11 @@ type AnimeService interface {
GetReviews(ctx context.Context, id int, page int) ([]ReviewEntry, bool, error) GetReviews(ctx context.Context, id int, page int) ([]ReviewEntry, bool, error)
} }
type AnimePlaybackService interface {
GetAnimeByID(ctx context.Context, id int) (Anime, error)
GetAllEpisodes(ctx context.Context, id int) ([]EpisodeData, error)
}
type CatalogSectionData struct { type CatalogSectionData struct {
Animes []Anime Animes []Anime
ContinueWatching []db.GetContinueWatchingEntriesRow ContinueWatching []db.GetContinueWatchingEntriesRow