1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package model
- import (
- "database/sql/driver"
- "encoding/json"
- "github.com/zeromicro/go-zero/core/stores/sqlx"
- "metawant.greentech.com.cn/gaoyagang/gt-common/identify"
- )
- var ErrNotFound = sqlx.ErrNotFound
- type Technologys []string
- func (d Technologys) Value() (driver.Value, error) {
- return json.Marshal(d)
- }
- // Scan 实现方法
- func (d *Technologys) Scan(input interface{}) error {
- _ = json.Unmarshal(input.([]byte), &d)
- return nil
- }
- type EventRule struct {
- Single identify.Rule
- Multi identify.MultiRule
- }
- func (d EventRule) Value() (driver.Value, error) {
- return json.Marshal(d)
- }
- // Scan 实现方法
- func (d *EventRule) Scan(input interface{}) error {
- if err := json.Unmarshal(input.([]byte), &d.Multi); err == nil {
- return nil
- }
- if err := json.Unmarshal(input.([]byte), &d.Single); err == nil {
- return nil
- }
- return nil
- }
|