package models import ( "database/sql" "fmt" "strconv" "strings" "time" "github.com/lib/pq" ) type DataSource int const ( DataSourceACD DataSource = iota DataSourceAniDB DataSourceAnilist ) type Trait struct { Name string Value string OfficialValue string } type Gril struct { ID int KanjiName string RomajiName string OtherNames []string Age sql.NullInt64 Birthday pq.NullTime Tags []string Traits []Trait ForeignIDs map[DataSource]int UpdatedAt time.Time Lists []int Series []Series } // Der kram hier sollte eigentlich auch eher wo anders hin als ins Model, oder?! func (g *Gril) Slug() string { if g.RomajiName == "" { return strconv.Itoa(g.ID) } return fmt.Sprintf( "%d/%s", g.ID, strings.Replace(g.RomajiName, " ", "", -1)) } // Das hier sollte auch irgendwo anders hin. func (g *Gril) ImagePath(useThumbnail bool) string { if useThumbnail { return fmt.Sprintf("http://img.grilist.moe/gril/thumb/%d.jpg", g.ID) } return fmt.Sprintf("http://img.grilist.moe/gril/full/%d.jpg", g.ID) }