event_sale_cow.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. type EventSaleCow struct {
  4. Id int64 `json:"id"`
  5. PastureId int64 `json:"pastureId"`
  6. SaleId int64 `json:"saleId"`
  7. CowId int64 `json:"cowId"`
  8. EarNumber string `json:"earNumber"`
  9. Lact int32 `json:"lact"`
  10. PregnancyAge int32 `json:"pregnancyAge"`
  11. BreedStatus pasturePb.BreedStatus_Kind `json:"breedStatus"`
  12. LactationAge int32 `json:"lactationAge"`
  13. CalvingAge int32 `json:"calvingAge"`
  14. AdmissionAge int32 `json:"admissionAge"`
  15. CreatedAt int64 `json:"createdAt"`
  16. UpdatedAt int64 `json:"updatedAt"`
  17. }
  18. func (e *EventSaleCow) TableName() string {
  19. return "event_sale_cow"
  20. }
  21. func NewEventSaleCow(pastureId int64, saleId int64, cowInfo *Cow) *EventSaleCow {
  22. return &EventSaleCow{
  23. PastureId: pastureId,
  24. SaleId: saleId,
  25. CowId: cowInfo.Id,
  26. Lact: cowInfo.Lact,
  27. EarNumber: cowInfo.EarNumber,
  28. PregnancyAge: cowInfo.PregnancyAge,
  29. BreedStatus: cowInfo.BreedStatus,
  30. LactationAge: cowInfo.LactationAge,
  31. AdmissionAge: cowInfo.AdmissionAge,
  32. }
  33. }
  34. func NewEventSaleCowList(pastureId int64, saleId int64, cowList []*Cow) []*EventSaleCow {
  35. res := make([]*EventSaleCow, 0)
  36. for _, cow := range cowList {
  37. res = append(res, NewEventSaleCow(pastureId, saleId, cow))
  38. }
  39. return res
  40. }