event_departure.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. type EventDeparture struct {
  4. Id int64 `json:"id"`
  5. PastureId int64 `json:"pastureId"`
  6. CowId int64 `json:"cowId"`
  7. Lact int32 `json:"lact"`
  8. DayAge int32 `json:"dayAge"`
  9. DepartureAt int64 `json:"departureAt"`
  10. DepartureType pasturePb.DepartureType_Kind `json:"departureType"`
  11. ReasonId int32 `json:"reasonId"`
  12. ReasonName string `json:"reasonName"`
  13. Remarks string `json:"remarks"`
  14. Weight int32 `json:"weight"`
  15. OperationId int64 `json:"operationId"`
  16. OperationName string `json:"operationName"`
  17. MessageId int64 `json:"messageId"`
  18. MessageName string `json:"messageName"`
  19. CreatedAt int64 `json:"createdAt"`
  20. UpdatedAt int64 `json:"updatedAt"`
  21. }
  22. func (e *EventDeparture) TableName() string {
  23. return "event_departure"
  24. }
  25. func NewEventDeparture(pastureId int64, cow *Cow, req *pasturePb.EventDeparture, reasonName string, currentUser, operationUser *SystemUser) *EventDeparture {
  26. return &EventDeparture{
  27. PastureId: pastureId,
  28. CowId: cow.Id,
  29. Lact: cow.Lact,
  30. DayAge: cow.GetDayAge(),
  31. DepartureAt: int64(req.DepartureAt),
  32. DepartureType: req.DepartureType,
  33. ReasonId: req.DepartureReasonKind,
  34. ReasonName: reasonName,
  35. Remarks: req.Remarks,
  36. OperationId: operationUser.Id,
  37. OperationName: operationUser.Name,
  38. MessageId: currentUser.Id,
  39. MessageName: currentUser.Name,
  40. }
  41. }
  42. type EventDepartureModel struct {
  43. EventDeparture *EventDeparture
  44. Cow *Cow
  45. DepartureAt int64
  46. }