优化表结构,重构模型,重新实现基于白银网关的提取节点流程
This commit is contained in:
24
web/globals/orm/slice.go
Normal file
24
web/globals/orm/slice.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package orm
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Slice[T any] struct {
|
||||
Arr []T
|
||||
}
|
||||
|
||||
func (s Slice[T]) Value() (driver.Value, error) {
|
||||
return json.Marshal(s)
|
||||
}
|
||||
|
||||
func (s *Slice[T]) Scan(value any) error {
|
||||
switch value := value.(type) {
|
||||
case []byte:
|
||||
return json.Unmarshal(value, s)
|
||||
default:
|
||||
return fmt.Errorf("不支持的类型: %T", value)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user