event_weight.go 1.3 KB

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