-
Notifications
You must be signed in to change notification settings - Fork 34
/
access_key.go
42 lines (34 loc) · 1.44 KB
/
access_key.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
package models
import (
"database/sql/driver"
"github.com/machinefi/w3bstream/pkg/depends/base/types"
"github.com/machinefi/w3bstream/pkg/depends/kit/sqlx/datatypes"
"github.com/machinefi/w3bstream/pkg/enums"
)
// AccessKey api access key
// @def primary ID
// @def unique_index ui_name AccountID Name
// @def unique_index ui_rand Rand
//
//go:generate toolkit gen model AccessKey --database DB
type AccessKey struct {
datatypes.PrimaryID
RelAccount
AccessKeyInfo
datatypes.OperationTimesWithDeleted
}
type AccessKeyInfo struct {
IdentityID types.SFID `db:"f_identity_id"`
IdentityType enums.AccessKeyIdentityType `db:"f_identity_type"`
Name string `db:"f_name"`
Rand string `db:"f_rand"`
ExpiredAt types.Timestamp `db:"f_expired_at,default='0'"`
LastUsed types.Timestamp `db:"f_last_used,default='0'"`
Description string `db:"f_desc,default=''"`
Privileges GroupAccessPrivileges `db:"f_privileges,default='[]'"`
}
// GroupAccessPrivileges mapping group name and access permission
type GroupAccessPrivileges map[string]enums.AccessPermission
func (GroupAccessPrivileges) DataType(driver string) string { return "text" }
func (m GroupAccessPrivileges) Value() (driver.Value, error) { return datatypes.JSONValue(m) }
func (m *GroupAccessPrivileges) Scan(src interface{}) error { return datatypes.JSONScan(src, m) }