cow_weight.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. type EventWeight struct {
  4. ID int64 `json:"id"`
  5. CowId int64 `json:"cow_id"`
  6. EarNumber string `json:"ear_number"`
  7. DayAge int32 `json:"day_age"`
  8. LactationDay int64 `json:"lactation_day"`
  9. PenId int32 `json:"pen_id"`
  10. Lact int32 `json:"lact"`
  11. Weight int32 `json:"weight"`
  12. WeightAt int64 `json:"weight_at"`
  13. Remarks string `json:"remarks"`
  14. OperationId int32 `json:"operation_id"`
  15. StaffMemberId int32 `json:"staff_member_id"`
  16. CreatedAt int64 `json:"created_at"`
  17. UpdatedAt int64 `json:"updated_at"`
  18. }
  19. func (c *EventWeight) TableName() string {
  20. return "event_weight"
  21. }
  22. func NewEventWeight(cow *Cow, systemUser *SystemUser, weight int32, req *pasturePb.EventWeight) *EventWeight {
  23. return &EventWeight{
  24. CowId: cow.Id,
  25. EarNumber: cow.EarNumber,
  26. Weight: weight,
  27. Lact: cow.Lact,
  28. DayAge: cow.GetDayAge(),
  29. WeightAt: int64(req.WeightAt),
  30. Remarks: req.Remarks,
  31. StaffMemberId: req.StaffMemberId,
  32. OperationId: int32(systemUser.Id),
  33. }
  34. }