40 lines
730 B
Go
40 lines
730 B
Go
package models
|
|
|
|
// Tag models
|
|
type Tag struct {
|
|
Name string `gorm:"primaryKey"`
|
|
Type TagType `gorm:"column:tag_type"`
|
|
Aliases []TagAlias `gorm:"foreignKey:TagID"`
|
|
Groups []TagGroup `gorm:"foreignKey:TagID"`
|
|
Posts []Post `gorm:"many2many:post_tags;"`
|
|
}
|
|
|
|
func (Tag) TableName() string {
|
|
return "Tag"
|
|
}
|
|
|
|
// TagAlias model
|
|
type TagAlias struct {
|
|
Name string `gorm:"primaryKey"`
|
|
TagID string
|
|
}
|
|
|
|
func (TagAlias) TableName() string {
|
|
return "TagAlias"
|
|
}
|
|
|
|
// TagGroup model
|
|
type TagGroup struct {
|
|
Name string `gorm:"primaryKey"`
|
|
TagID string
|
|
}
|
|
|
|
func (TagGroup) TableName() string {
|
|
return "TagGroup"
|
|
}
|
|
|
|
type TagsWithFrequency struct {
|
|
Frequency int64 `json:"frequency"`
|
|
Tags Tag `json:"tags"`
|
|
}
|