indicators_cow.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package model
  2. type IndicatorsCow struct {
  3. Id int64 `json:"id"`
  4. PastureId int64 `json:"pastureId"`
  5. IndicatorsId int64 `json:"indicatorsId"`
  6. DateTime string `json:"dateTime"`
  7. CowId int64 `json:"cowId"`
  8. EarNumber string `json:"earNumber"`
  9. Lact int32 `json:"lact"`
  10. AdmissionAge int32 `json:"admissionAge"`
  11. CalvingAge int32 `json:"calvingAge"`
  12. CreatedAt int64 `json:"createdAt"`
  13. UpdatedAt int64 `json:"updatedAt"`
  14. }
  15. func (i *IndicatorsCow) TableName() string {
  16. return "indicator_cow"
  17. }
  18. func NewIndicatorsCow(pastureId int64, indicatorsId int64, dateTime string, cowInfo *Cow) *IndicatorsCow {
  19. return &IndicatorsCow{
  20. PastureId: pastureId,
  21. IndicatorsId: indicatorsId,
  22. DateTime: dateTime,
  23. CowId: cowInfo.Id,
  24. EarNumber: cowInfo.EarNumber,
  25. Lact: cowInfo.Lact,
  26. AdmissionAge: cowInfo.AdmissionAge,
  27. CalvingAge: cowInfo.CalvingAge,
  28. }
  29. }
  30. func NewIndicatorsCowList(pastureId int64, indicatorsId int64, dataTime string, cowList []*Cow) []*IndicatorsCow {
  31. res := make([]*IndicatorsCow, 0)
  32. for _, cow := range cowList {
  33. res = append(res, NewIndicatorsCow(pastureId, indicatorsId, dataTime, cow))
  34. }
  35. return res
  36. }