event_departure.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. CowId int64 `json:"cowId"`
  6. Lact int32 `json:"lact"`
  7. DayAge int32 `json:"dayAge"`
  8. DepartureAt int64 `json:"departureAt"`
  9. DepartureType pasturePb.DepartureType_Kind `json:"departureType"`
  10. ReasonId int32 `json:"reasonId"`
  11. ReasonName string `json:"reasonName"`
  12. Remarks string `json:"remarks"`
  13. OperationId int64 `json:"operationId"`
  14. OperationName string `json:"operationName"`
  15. MessageId int64 `json:"messageId"`
  16. MessageName string `json:"messageName"`
  17. CreatedAt int64 `json:"createdAt"`
  18. UpdatedAt int64 `json:"updatedAt"`
  19. }
  20. func (e *EventDeparture) TableName() string {
  21. return "event_departure"
  22. }
  23. func NewEventDeparture(cow *Cow, req *pasturePb.EventDeparture, reasonName string, currentUser, operationUser *SystemUser) *EventDeparture {
  24. return &EventDeparture{
  25. CowId: cow.Id,
  26. Lact: cow.Lact,
  27. DayAge: cow.GetDayAge(),
  28. DepartureAt: int64(req.DepartureAt),
  29. DepartureType: req.DepartureType,
  30. ReasonId: req.DepartureReason,
  31. ReasonName: reasonName,
  32. Remarks: req.Remarks,
  33. OperationId: operationUser.Id,
  34. OperationName: operationUser.Name,
  35. MessageId: currentUser.Id,
  36. MessageName: currentUser.Name,
  37. }
  38. }