campus-supervision/model/super-model.go

30 lines
716 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
type Super struct {
ID uint `gorm:"primarykey"`
Content []byte `gorm:"type:json;not null"`
}
// type JSON json.RawMessage
// // 实现 sql.Scanner 接口Scan 将 value 扫描至 Jsonb
// func (j *JSON) Scan(value interface{}) error {
// bytes, ok := value.([]byte)
// if !ok {
// return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
// }
// result := json.RawMessage{}
// err := json.Unmarshal(bytes, &result)
// *j = JSON(result)
// return err
// }
// // 实现 driver.Valuer 接口Value 返回 json value
// func (j JSON) Value() (driver.Value, error) {
// if len(j) == 0 {
// return nil, nil
// }
// return json.RawMessage(j).MarshalJSON()
// }