-
Notifications
You must be signed in to change notification settings - Fork 0
/
fields_save.go
69 lines (61 loc) · 1.75 KB
/
fields_save.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package UserLogin
import (
"database/sql/driver"
"encoding/json"
"errors"
OrgCoreCore "github.com/fotomxq/weeekj_core/v5/org/core"
UserCore "github.com/fotomxq/weeekj_core/v5/user/core"
"time"
)
// FieldsSave 临时存储数据包
// 统一一分钟有效期,提取失效
type FieldsSave struct {
//ID
ID int64 `db:"id" json:"id"`
//创建时间
CreateAt time.Time `db:"create_at" json:"createAt"`
//过期时间
ExpireAt time.Time `db:"expire_at" json:"expireAt"`
//提取密钥
Key string `db:"key" json:"key"`
//数据
Data FieldsSaveReportData `db:"data" json:"data"`
}
// FieldsSaveReportData 反馈的数据结构
type FieldsSaveReportData struct {
//会话
Token FieldsSaveReportDataToken `db:"token" json:"token"`
//用户脱敏数据
UserData UserCore.DataUserDataType `db:"user_data" json:"userData"`
//绑定关系和组织关系
OrgBindData []OrgCoreCore.DataGetBindByUserMarge `db:"org_bind_data" json:"orgBindData"`
//文件集
// id => url
FileList map[int64]string `db:"file_list" json:"fileList"`
}
// Value sql底层处理器
func (t FieldsSaveReportData) Value() (driver.Value, error) {
return json.Marshal(t)
}
func (t *FieldsSaveReportData) Scan(value interface{}) error {
b, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(b, &t)
}
type FieldsSaveReportDataToken struct {
Token int64 `db:"token" json:"token"`
Key string `db:"key" json:"key"`
}
// Value sql底层处理器
func (t FieldsSaveReportDataToken) Value() (driver.Value, error) {
return json.Marshal(t)
}
func (t *FieldsSaveReportDataToken) Scan(value interface{}) error {
b, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(b, &t)
}