Use typed IDs instead of plain strings

This commit is contained in:
2019-11-18 14:01:13 +09:00
parent e7c7e84334
commit a50a119e08
26 changed files with 75 additions and 44 deletions

View File

@ -7,14 +7,18 @@ import (
"github.com/animenotifier/notify.moe/arn/validate"
)
// EpisodeID represents an episode ID.
type EpisodeID = ID
// Episode represents a single episode for an anime.
type Episode struct {
ID string `json:"id" primary:"true"`
AnimeID AnimeID `json:"animeId"`
Number int `json:"number" editable:"true"`
Title EpisodeTitle `json:"title" editable:"true"`
AiringDate AiringDate `json:"airingDate" editable:"true"`
Links map[string]string `json:"links"`
hasID
}
// EpisodeTitle contains the title information for an anime episode.
@ -27,7 +31,9 @@ type EpisodeTitle struct {
// NewAnimeEpisode creates a new anime episode.
func NewAnimeEpisode() *Episode {
return &Episode{
ID: GenerateID("Episode"),
hasID: hasID{
ID: GenerateID("Episode"),
},
Number: -1,
}
}