forked from kevin-hf/education
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (36 loc) · 1.17 KB
/
main.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
/**
@Author : hanxiaodong
*/
package main
import (
"github.com/hyperledger/fabric/core/chaincode/shim"
"fmt"
"github.com/hyperledger/fabric/protos/peer"
)
type EducationChaincode struct {
}
func (t *EducationChaincode) Init(stub shim.ChaincodeStubInterface) peer.Response{
return shim.Success(nil)
}
func (t *EducationChaincode) Invoke(stub shim.ChaincodeStubInterface) peer.Response{
// 获取用户意图
fun, args := stub.GetFunctionAndParameters()
if fun == "addEdu"{
return t.addEdu(stub, args) // 添加信息
}else if fun == "queryEduByCertNoAndName" {
return t.queryEduByCertNoAndName(stub, args) // 根据证书编号及姓名查询信息
}else if fun == "queryEduInfoByEntityID" {
return t.queryEduInfoByEntityID(stub, args) // 根据身份证号码及姓名查询详情
}else if fun == "updateEdu" {
return t.updateEdu(stub, args) // 根据证书编号更新信息
}else if fun == "delEdu"{
return t.delEdu(stub, args) // 根据证书编号删除信息
}
return shim.Error("指定的函数名称错误")
}
func main(){
err := shim.Start(new(EducationChaincode))
if err != nil{
fmt.Printf("启动EducationChaincode时发生错误: %s", err)
}
}