保捱科技网
您的当前位置:首页domain.go

domain.go

来源:保捱科技网

```go
package service
/*
 *@Author:邓林峰
 *@Date:21-5-4 下午2:49
 */
import (
	"fmt"
	"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
	"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
	"time"
)

type Health struct {
	ObjectType string `json:"docType"`
	EntityID string `json:"EntityID"`//身份证号
	Name string `json:"Name"`//姓名
	Sex string `json:"Sex"`//性别
	
	Stunumber string `json:"Stunumber"`//学号
	EnrollDate string `json:"EnrollDate"`//入学日期
	GraduationDate string `json:"GraduationDate"`//毕(结)业日期
	SchoolName string `json:"SchoolName"`//学校名称
	College string `json:"College"`//学院名称
	Major string `json:"Major"`//专业
	QuaType string `json:"QuaType"`//学历类别
	Length string `json:"Length"`//学制
	Photo string `json:"Photo"`//照片

	Height float `json:"Height"`//身高
	Weight float `json:"Weight"`//体重
	Vol float `json:"Vol"`//左眼视力
	Vor float `json:"Vor"`//右眼视力
	Colorblindness string `json:"Colorblindness"`//色盲情况
	Earsick string `json:"Earsick"`//耳疾情况
	Nose string `json:"Nose"`//鼻及鼻窦疾病情况
	Stutter bool `json:"Stutter"`//是否口吃
	Teeth string `json:"Teeth"`//牙齿情况(缺齿、齿槽)
	Waistline float `json:"Waistline"`//腰围
	Skin string `json:"Skin"`//皮肤情况
	Thyroid string `json:"Thyroid"`//甲状腺情况
	Spine string `json:"Spine"`//脊柱情况
	Joints string `json:"Joints"`//关节情况
	Flatfoot bool `json:"Flatfoot"`//是否为扁平足
	Pulse float `json:"Pulse"`//脉搏(次/秒)
	Mental string `json:"Mental"`//神经及精神情况
	Lungsrespiratory string `json:"Lungsrespiratory"`//肺部及呼吸道情况
	Heartbloodvessel string `json:"Heartbloodvessel"`//心脏及血管情况
	Liver string `json:"Liver"`//肝脏情况
	Spleen string `json:"Spleen"`//脾脏情况
	Other string `json:"Other"`//其他情况
	Persion string `json:"Persion"`//录入者/更新者
	Date time.Time `json:"Date"`//日期

	Historys []HistoryItem//当前Health的历史记录
}

type HistoryItem struct {
	Txid string
	Health Health
}

type ServiceSetup struct {
	ChaincodeID	string
	Client	*channel.Client
}

func regitserEvent(client *channel.Client, chaincodeID, eventID string) (fab.Registration, <-chan *fab.CCEvent) {
	reg, notifier, err := client.RegisterChaincodeEvent(chaincodeID, eventID)
	if err != nil {
		fmt.Println("注册链码事件失败: %s", err)
	}
	return reg, notifier
}

func eventResult(notifier <-chan *fab.CCEvent, eventID string) error {
	select {
	case ccEvent := <-notifier:
		fmt.Printf("接收到链码事件: %v\n", ccEvent)
	case <-time.After(time.Second * 20):
		return fmt.Errorf("不能根据指定的事件ID接收到相应的链码事件(%s)", eventID)
	}
	return nil
}

因篇幅问题不能全部显示,请点此查看更多更全内容