Files
ai/models/Tag.go
2023-05-27 14:40:11 +08:00

30 lines
585 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)
}