options.go 2.1 KB
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
)