package model import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" type EventCowDisease struct { Id int64 `json:"id"` CowId int64 `json:"cowId"` CowType pasturePb.CowType_Kind `json:"cowType"` Lact int32 `json:"lact"` DayAge int32 `json:"dayAge"` DiseaseId int32 `json:"diseaseId"` DiseaseName string `json:"diseaseName"` DiseaseType int32 `json:"diseaseType"` DiseaseTypeName string `json:"diseaseTypeName"` DiagnoseId int32 `json:"diagnoseId"` DiagnoseName string `json:"diagnoseName"` PenId int32 `json:"penId"` HealthStatus pasturePb.HealthStatus_Kind `json:"healthStatus"` DiagnosedResult pasturePb.IsShow_Kind `json:"diagnosedResult"` DiagnosedAt int64 `json:"diagnosedAt"` DiseaseAt int64 `json:"diseaseAt"` Temperature int32 `json:"temperature"` Remarks string `json:"remarks"` OperationId int32 `json:"operationId"` OperationName string `json:"operationName"` MessageId int32 `json:"messageId"` MessageName string `json:"messageName"` DiagnoseOperationId int32 `json:"diagnoseOperationId"` DiagnoseOperationName string `json:"diagnoseOperationName"` CurableAt int64 `json:"curableAt"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` } func (e *EventCowDisease) TableName() string { return "event_cow_disease" } func NewEventCowDisease(cow *Cow, disease *Disease, req *pasturePb.EventCowDiseaseRequest, operation, currUser *SystemUser) *EventCowDisease { return &EventCowDisease{ CowId: cow.Id, CowType: cow.CowType, Lact: cow.Lact, DayAge: cow.DayAge, DiseaseId: int32(disease.Id), DiseaseName: disease.Name, DiseaseType: disease.DiseaseType, DiseaseTypeName: disease.DiseaseTypeName, PenId: req.PenId, HealthStatus: pasturePb.HealthStatus_Health, DiseaseAt: int64(req.DiseaseAt), Temperature: int32(req.Temperature * 10), OperationId: int32(operation.Id), OperationName: operation.Name, MessageId: int32(currUser.Id), MessageName: currUser.Name, Remarks: req.Remarks, } } type EventCowDiseaseSlice []*EventCowDisease func (e EventCowDiseaseSlice) ToPB(healthStatusMap map[pasturePb.HealthStatus_Kind]string) []*pasturePb.EventCowDisease { res := make([]*pasturePb.EventCowDisease, len(e)) for i, v := range e { res[i] = &pasturePb.EventCowDisease{ Id: int32(v.Id), CowId: int32(v.CowId), Lact: v.Lact, DayAge: v.DayAge, DiseaseId: v.DiseaseId, DiseaseName: v.DiseaseName, DiagnoseId: v.DiagnoseId, DiagnoseName: v.DiagnoseName, PenId: v.PenId, HealthStatus: v.HealthStatus, HealthStatusName: healthStatusMap[v.HealthStatus], Temperature: float32(v.HealthStatus / 10), DiseaseAt: int32(v.DiseaseAt), Remarks: v.Remarks, OperationId: v.OperationId, OperationName: v.OperationName, } } return res }