Files
ai/models/Tag.go
2023-06-19 02:39:18 +08:00

40 lines
791 B
Go

package models
import (
"database/sql/driver"
"encoding/json"
"main/configs"
"time"
)
type Tag struct {
ID int `json:"id" gorm:"primary_key"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
func init() {
configs.ORMDB().AutoMigrate(&Tag{})
}
type TagList []string
func (list *TagList) Scan(value interface{}) error {
return json.Unmarshal(value.([]byte), list)
}
func (list TagList) Value() (driver.Value, error) {
return json.Marshal(list)
}
type StarList []int
func (list *StarList) Scan(value interface{}) error {
return json.Unmarshal(value.([]byte), list)
}
func (list StarList) Value() (driver.Value, error) {
return json.Marshal(list)
}