package model import ( "time" pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" ) type EventEstrus struct { Id int64 `json:"id"` CowId int64 `json:"cowId"` DayAge int32 `json:"dayAge"` Lact int32 `json:"lact"` CalvingAge int32 `json:"calvingAge"` ExposeEstrusType pasturePb.ExposeEstrusType_Kind `json:"exposeEstrusType"` FilterHigh int32 `json:"filter_high"` EstrusDate string `json:"estrusDate"` ActiveDate string `json:"activeDate"` LastEstrusDate string `json:"lastEstrusDate"` Level pasturePb.EstrusLevel_Kind `json:"level"` IsPeak pasturePb.IsShow_Kind `json:"isPeak"` PerTwentyFourHigh int32 `json:"perTwentyFourHigh"` Result pasturePb.EstrusResult_Kind `json:"result"` UnMatingReasons pasturePb.UnMatingReasons_Kind `json:"unMatingReasons"` UnMatingReasonsName string `json:"unMatingReasonsName"` IsMating pasturePb.IsShow_Kind `json:"isMating"` Remarks string `json:"remarks"` IsShow pasturePb.IsShow_Kind `json:"isShow"` OperationId int64 `json:"operationId"` OperationName string `json:"operationName"` MessageId int64 `json:"messageId"` MessageName string `json:"messageName"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` } func (e *EventEstrus) TableName() string { return "event_estrus" } func NewEventEstrus( exposeEstrusType pasturePb.ExposeEstrusType_Kind, cow *Cow, currentUser *SystemUser, operation *SystemUser, req *pasturePb.EventEstrus, ) *EventEstrus { return &EventEstrus{ CowId: cow.Id, DayAge: cow.GetDayAge(), Lact: cow.Lact, CalvingAge: int32(cow.CalvingAge), EstrusDate: time.Unix(int64(req.EstrusAt), 0).Format(LayoutTime), Remarks: req.Remarks, IsMating: req.IsMathing, UnMatingReasons: req.UnMatingReasons, MessageId: currentUser.Id, MessageName: currentUser.Name, OperationId: operation.Id, OperationName: operation.Name, ExposeEstrusType: exposeEstrusType, } } type EstrusSlice []*EventEstrus func (e EstrusSlice) ToPB() []*pasturePb.SearchEstrusList { res := make([]*pasturePb.SearchEstrusList, len(e)) for i, v := range e { res[i] = &pasturePb.SearchEstrusList{ Id: int32(v.Id), CowId: int32(v.CowId), DayAge: v.DayAge, Lact: v.Lact, //EstrusAt: int32(v.EstrusAt), Level: v.Level, Result: v.Result, IsMathing: v.IsMating, UnMatingReasonsName: v.UnMatingReasonsName, CalvingAge: v.CalvingAge, MessengerId: int32(v.MessageId), MessengerName: v.MessageName, Remarks: v.Remarks, OperationId: int32(v.OperationId), OperationName: v.OperationName, CreatedAt: int32(v.CreatedAt), UpdatedAt: int32(v.UpdatedAt), } } return res }