event_calving_calf.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. type EventCalvingCalf struct {
  4. Id int64 `json:"id"`
  5. CalvingId int64 `json:"calving_id"`
  6. CowId int64 `json:"cow_id"`
  7. MotherId int64 `json:"mother_id"`
  8. EarNumber string `json:"ear_number"`
  9. Sex pasturePb.Genders_Kind `json:"sex"`
  10. Weight int64 `json:"weight"`
  11. IsLive pasturePb.IsShow_Kind `json:"is_live"`
  12. IsAdoption pasturePb.IsShow_Kind `json:"is_adoption"`
  13. PenId int64 `json:"pen_id"`
  14. Remarks string `json:"remarks"`
  15. CreatedAt int64 `json:"created_at"`
  16. UpdatedAt int64 `json:"updated_at"`
  17. }
  18. func (e *EventCalvingCalf) TableName() string {
  19. return "event_calving_calf"
  20. }
  21. func NewEventCalvingCalf(motherId, calvingId int64, req *pasturePb.CalvingEventRequest) []*EventCalvingCalf {
  22. calvingCalfList := make([]*EventCalvingCalf, 0)
  23. for _, v := range req.CalfItemList {
  24. calvingCalfList = append(calvingCalfList, &EventCalvingCalf{
  25. CowId: 0, // TODO: cowId
  26. EarNumber: "", // TODO: 耳号
  27. CalvingId: calvingId,
  28. PenId: 0, // TODO: penId
  29. Weight: int64(v.Weight * 100),
  30. Sex: v.Sex,
  31. MotherId: motherId,
  32. Remarks: v.Remarks,
  33. IsAdoption: v.IsAdoption,
  34. IsLive: v.IsLive,
  35. })
  36. }
  37. return calvingCalfList
  38. }