options.go
2.1 KB
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
package blockchain
type UpToChainOptions struct {
// 上链数据的数据库、数据表等的标识值 (非必填)
InnerDBTable string `json:"innerDBTable,omitempty"`
// 上链数据的唯一标识主键值 (非必填)
InnerPrimaryKey string `json:"innerPrimaryKey,omitempty"`
// 上链记录的一个标记值(IssueId), 数据溯源出所有相关事件内容,例如快递单号,过滤出该快递的所有相关事件内容并用于展示 (非必填)
InnerPrimaryIssueId string `json:"innerPrimaryIssueId,omitempty"`
// 作用与key1相同 (非必填)
InnerSecondIssueId string `json:"innerSecondIssueId,omitempty"`
// 数据原文 (必填)
Value string `json:"value"`
// 数据描述: 对value的描述,无论needHash为何值,本字段均会原文存储到链上
Desc string `json:"desc,omitempty"`
// 是否哈希: true: 需要哈希,会将value进行hash上链,false:不需要哈希,明文上链,链上所有用户都可看到明文,默认false
NeedHash bool `json:"needHash"`
}
func NewUpToChainOptions(table, primaryKey, value string) *UpToChainOptions {
return &UpToChainOptions{InnerDBTable: table, InnerPrimaryKey: primaryKey, Value: value, NeedHash: false}
}
func (o *UpToChainOptions) WithInnerDBTable(innerDBTable string) *UpToChainOptions {
o.InnerDBTable = innerDBTable
return o
}
func (o *UpToChainOptions) WithInnerPrimaryKey(innerPrimaryKey string) *UpToChainOptions {
o.InnerPrimaryKey = innerPrimaryKey
return o
}
func (o *UpToChainOptions) WithInnerPrimaryIssueId(innerPrimaryIssueId string) *UpToChainOptions {
o.InnerPrimaryIssueId = innerPrimaryIssueId
return o
}
func (o *UpToChainOptions) WithInnerSecondIssueId(innerSecondIssueId string) *UpToChainOptions {
o.InnerSecondIssueId = innerSecondIssueId
return o
}
func (o *UpToChainOptions) WithValue(Value string) *UpToChainOptions {
o.Value = Value
return o
}
func (o *UpToChainOptions) WithDesc(Desc string) *UpToChainOptions {
o.Desc = Desc
return o
}
func (o *UpToChainOptions) WithNeedHash() *UpToChainOptions {
o.NeedHash = true
return o
}
const (
QueryByHashId = iota + 1
QueryByIssueId
)