package model import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" type EventSameTime struct { Id int64 `json:"id"` CowId int64 `json:"cowId"` Lact int32 `json:"lact"` DayAge int32 `json:"dayAge"` CalvingAge int64 `json:"calvingAge"` SameTimeId int64 `json:"sameTimeId"` SameTimeType pasturePb.SameTimeType_Kind `json:"sameTimeType"` SameTimeTypeName string `json:"sameTimeTypeName"` DrugsId int64 `json:"drugsId"` DrugsName string `json:"drugsName"` Unit pasturePb.Unit_Kind `json:"unit"` Usage int32 `json:"usage"` Remarks string `json:"remarks"` StallNumberId int64 `json:"stallNumberId"` OperationId int64 `json:"operation_id"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` } func (e *EventSameTime) TableName() string { return "event_same_time" } func NewEventSameTime(cow *Cow, req *pasturePb.EventSameTime, drugs *Drugs) *EventSameTime { eventSameTime := &EventSameTime{ CowId: cow.Id, CalvingAge: cow.CalvingAge, SameTimeId: int64(req.SameTimeId), SameTimeType: req.SameTimeType, SameTimeTypeName: req.SameTimeTypeName, Remarks: req.Remarks, } if drugs != nil && drugs.Id > 0 { eventSameTime.DrugsId = drugs.Id eventSameTime.DrugsName = drugs.Name eventSameTime.Unit = drugs.Unit eventSameTime.Usage = req.Usage } return eventSameTime }