This commit is contained in:
2023-06-19 02:39:18 +08:00
parent 7349f5a1d6
commit 45c1ddd87c
3 changed files with 21 additions and 5 deletions

View File

@@ -30,6 +30,7 @@ type Model struct {
UserID int `json:"user_id"` // 模型的所有者
DatasetID int `json:"dataset_id"` // 模型所使用的數據集ID
ServerID string `json:"server_id"` // 模型所在服務器(訓練機或推理機)
Stars StarList `json:"stars"` // 模型的收藏者
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}

View File

@@ -27,3 +27,13 @@ func (list *TagList) Scan(value interface{}) error {
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)
}