package model import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" type EventCalvingCalf struct { Id int64 `json:"id"` CalvingId int64 `json:"calving_id"` CowId int64 `json:"cow_id"` MotherId int64 `json:"mother_id"` EarNumber string `json:"ear_number"` Sex pasturePb.Genders_Kind `json:"sex"` CowKind pasturePb.CowKind_Kind `json:"cow_kind"` Weight int64 `json:"weight"` IsLive pasturePb.IsShow_Kind `json:"is_live"` IsAdoption pasturePb.IsShow_Kind `json:"is_adoption"` PenId int32 `json:"pen_id"` Remarks string `json:"remarks"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` } func (e *EventCalvingCalf) TableName() string { return "event_calving_calf" } func NewEventCalvingCalf(motherId, calvingId int64, req *pasturePb.CalvingEventRequest) []*EventCalvingCalf { calvingCalfList := make([]*EventCalvingCalf, 0) for _, v := range req.CalfItemList { isAdoption := v.IsAdoption if v.IsLive == pasturePb.IsShow_No { isAdoption = pasturePb.IsShow_No } calvingCalfList = append(calvingCalfList, &EventCalvingCalf{ EarNumber: v.EarNumber, CalvingId: calvingId, PenId: v.PenId, Weight: int64(v.Weight * 100), Sex: v.Sex, MotherId: motherId, Remarks: v.Remarks, IsAdoption: isAdoption, IsLive: v.IsLive, }) } return calvingCalfList }