package apiv3 import ( "database/sql" "time" ) // Author API model type Author struct { AID uint `json:"id"` ASlug string `json:"slug"` AName string `json:"name"` AYoutube string `json:"youtube"` AAvatar string `json:"avatar"` AFanArt string `json:"fanArt"` } func (author *Author) ID(id uint) { author.AID = id } func (author *Author) Slug(slug sql.NullString) { author.ASlug = slug.String } func (author *Author) Name(name sql.NullString) { author.AName = name.String } func (author *Author) Youtube(youtube sql.NullString) { author.AYoutube = youtube.String } func (author *Author) AvatarB(avatar sql.NullString) { author.AAvatar = avatar.String } func (author *Author) FanArtB(fa sql.NullString) { author.AFanArt = fa.String } // Let's Play API model type LetsPlay struct { AID uint `json:"id"` AAuthorID uint `json:"authorId"` ASlug string `json:"slug"` AName string `json:"name"` APoster string `json:"poster"` AAired time.Time `json:"aired"` } func (lp *LetsPlay) ID(id uint) { lp.AID = id } func (lp *LetsPlay) AuthorID(id uint) { lp.AAuthorID = id } func (lp *LetsPlay) Slug(s sql.NullString) { lp.ASlug = s.String } func (lp *LetsPlay) Name(s sql.NullString) { lp.AName = s.String } func (lp *LetsPlay) PosterS(s sql.NullString) { lp.APoster = s.String } func (lp *LetsPlay) Aired(t time.Time) { lp.AAired = t } // Let's Test API model type LetsTest struct { AID uint `json:"id"` AAuthorID uint `json:"authorId"` ASlug string `json:"slug"` AName string `json:"name"` APoster string `json:"poster"` AThumb string `json:"thumb"` AFanArt string `json:"fanArt"` AYoutube string `json:"youtube"` ADescr string `json:"descr"` AAired time.Time `json:"aired"` ARating float64 `json:"rating"` AVotes int64 `json:"votes"` ADuration int64 `json:"duration"` } func (lt *LetsTest) ID(id uint) { lt.AID = id } func (lt *LetsTest) AuthorID(id uint) { lt.AAuthorID = id } func (lt *LetsTest) Slug(s sql.NullString) { lt.ASlug = s.String } func (lt *LetsTest) Name(s sql.NullString) { lt.AName = s.String } func (lt *LetsTest) PosterS(s sql.NullString) { lt.APoster = s.String } func (lt *LetsTest) ThumbS(s sql.NullString) { lt.AThumb = s.String } func (lt *LetsTest) ThumbB(s sql.NullString) { lt.AFanArt = s.String } func (lt *LetsTest) Youtube(s sql.NullString) { lt.AYoutube = s.String } func (lt *LetsTest) Descr(s sql.NullString) { lt.ADescr = s.String } func (lt *LetsTest) Aired(t time.Time) { lt.AAired = t } func (lt *LetsTest) Rating(f sql.NullFloat64) { lt.ARating = f.Float64 } func (lt *LetsTest) Votes(i sql.NullInt64) { lt.AVotes = i.Int64 } func (lt *LetsTest) Duration(i sql.NullInt64) { lt.ADuration = i.Int64 } // Episode API model type Episode struct { AID uint `json:"id"` AAuthorID uint `json:"authorId"` ALetsPlayID uint `json:"letsPlayId"` ASlug string `json:"slug"` AName string `json:"name"` AEpisode int64 `json:"episode"` AThumb string `json:"thumb"` AFanArt string `json:"fanArt"` AYoutube string `json:"youtube"` ADescr string `json:"descr"` AAired time.Time `json:"aired"` ARating float64 `json:"rating"` AVotes int64 `json:"votes"` ADuration int64 `json:"duration"` } func (ep *Episode) ID(id uint) { ep.AID = id } func (ep *Episode) AuthorID(id uint) { ep.AAuthorID = id } func (ep *Episode) LetsPlayID(id uint) { ep.ALetsPlayID = id } func (ep *Episode) Slug(s sql.NullString) { ep.ASlug = s.String } func (ep *Episode) Name(s sql.NullString) { ep.AName = "Folge 0: " + s.String } func (ep *Episode) Episode(i sql.NullInt64) { ep.AEpisode = ep.AEpisode + i.Int64 } func (ep *Episode) Season(i sql.NullInt64) { ep.AEpisode = ep.AEpisode + 10000 * i.Int64 } func (ep *Episode) ThumbS(s sql.NullString) { ep.AThumb = s.String } func (ep *Episode) ThumbB(s sql.NullString) { ep.AFanArt = s.String } func (ep *Episode) Youtube(s sql.NullString) { ep.AYoutube = s.String } func (ep *Episode) Descr(s sql.NullString) { ep.ADescr = s.String } func (ep *Episode) Aired(t time.Time) { ep.AAired = t } func (ep *Episode) Rating(f sql.NullFloat64) { ep.ARating = f.Float64 } func (ep *Episode) Votes(i sql.NullInt64) { ep.AVotes = i.Int64 } func (ep *Episode) Duration(i sql.NullInt64) { ep.ADuration = i.Int64 }