41 lines
815 B
Go
41 lines
815 B
Go
package db
|
|
|
|
import (
|
|
"fmt"
|
|
"reflect"
|
|
|
|
schsdk "gitlink.org.cn/cloudream/common/sdks/scheduler"
|
|
"gitlink.org.cn/cloudream/common/utils/serder"
|
|
schmod "gitlink.org.cn/cloudream/scheduler/common/models"
|
|
)
|
|
|
|
type TempComputingCenter struct {
|
|
schmod.ComputingCenter
|
|
Bootstrap BootstrapWrapper `gorm:"column:Bootstrap"`
|
|
}
|
|
|
|
func (c *TempComputingCenter) ToComputingCenter() schmod.ComputingCenter {
|
|
cc := c.ComputingCenter
|
|
cc.Bootstrap = c.Bootstrap.Value
|
|
return cc
|
|
}
|
|
|
|
type BootstrapWrapper struct {
|
|
Value schsdk.Bootstrap
|
|
}
|
|
|
|
func (o *BootstrapWrapper) Scan(src interface{}) error {
|
|
data, ok := src.([]uint8)
|
|
if !ok {
|
|
return fmt.Errorf("unknow src type: %v", reflect.TypeOf(data))
|
|
}
|
|
|
|
boot, err := serder.JSONToObjectEx[schsdk.Bootstrap](data)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
o.Value = boot
|
|
return nil
|
|
}
|