event_weight.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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:"cowId"`
  6. EarNumber string `json:"earNumber"`
  7. DayAge int32 `json:"dayAge"`
  8. LactationDay int64 `json:"lactationDay"`
  9. PenId int32 `json:"penId"`
  10. Lact int32 `json:"lact"`
  11. Weight int32 `json:"weight"`
  12. Height int32 `json:"height"`
  13. WeightAt int64 `json:"weightAt"`
  14. Remarks string `json:"remarks"`
  15. OperationId int32 `json:"operationId"`
  16. OperationName string `json:"operationName"`
  17. MessageId int64 `json:"messageId"`
  18. MessageName string `json:"messageName"`
  19. CreatedAt int64 `json:"created_at"`
  20. UpdatedAt int64 `json:"updated_at"`
  21. }
  22. func (c *EventWeight) TableName() string {
  23. return "event_weight"
  24. }
  25. func NewEventWeight(cow *Cow, currentUser *SystemUser, weight, height int32, req *pasturePb.EventWeight) *EventWeight {
  26. return &EventWeight{
  27. CowId: cow.Id,
  28. EarNumber: cow.EarNumber,
  29. Weight: weight,
  30. Height: height,
  31. Lact: cow.Lact,
  32. DayAge: cow.GetDayAge(),
  33. WeightAt: int64(req.WeightAt),
  34. Remarks: req.Remarks,
  35. MessageId: currentUser.Id,
  36. MessageName: currentUser.Name,
  37. OperationId: req.OperationId,
  38. OperationName: req.OperationName,
  39. }
  40. }