12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package model
- import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- type CalvingCalf struct {
- Id int64 `json:"id"`
- CalvingId int64 `json:"calvingId"`
- CowId int64 `json:"cow_id"`
- MotherId int64 `json:"motherId"`
- EarNumber string `json:"earNumber"`
- Sex pasturePb.Genders_Kind `json:"sex"`
- CowKind pasturePb.CowKind_Kind `json:"cowKind"`
- BrithWeight int64 `json:"brithWeight"`
- IsLive pasturePb.IsShow_Kind `json:"isLive"`
- IsAdoption pasturePb.IsShow_Kind `json:"isAdoption"`
- PenId int32 `json:"penId"`
- WeaningAt int64 `json:"weaningAt"`
- CurrentWeight int64 `json:"currentWeight"`
- Remarks string `json:"remarks"`
- CreatedAt int64 `json:"createdAt"`
- UpdatedAt int64 `json:"updatedAt"`
- }
- func (e *CalvingCalf) TableName() string {
- return "calving_calf"
- }
- func NewEventCalvingCalf(motherId, calvingId int64, req *pasturePb.EventCalving) []*CalvingCalf {
- calvingCalfList := make([]*CalvingCalf, 0)
- for _, v := range req.CalfItemList {
- isAdoption := v.IsAdoption
- if v.IsLive == pasturePb.IsShow_No {
- isAdoption = pasturePb.IsShow_No
- }
- calvingCalfList = append(calvingCalfList, &CalvingCalf{
- EarNumber: v.EarNumber,
- CalvingId: calvingId,
- PenId: v.PenId,
- BrithWeight: int64(v.Weight * 1000),
- CurrentWeight: int64(v.Weight * 1000),
- Sex: v.Sex,
- MotherId: motherId,
- Remarks: v.Remarks,
- IsAdoption: isAdoption,
- IsLive: v.IsLive,
- })
- }
- return calvingCalfList
- }
|