event_forbidden_mating.go 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package model
  2. import (
  3. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  4. )
  5. type EventForbiddenMating struct {
  6. Id int64 `json:"id"`
  7. PastureId int64 `json:"pastureId"`
  8. CowId int64 `json:"cowId"`
  9. EarNumber string `json:"earNumber"`
  10. DayAge int32 `json:"dayAge"`
  11. ForbiddenMatingAt int64 `json:"forbiddenMatingAt"`
  12. ForbiddenMatingReasonsKind pasturePb.ForbiddenMatingReasons_Kind `json:"forbiddenMatingReasonsKind"`
  13. ForbiddenMatingReasonsName string `json:"forbiddenMatingReasonsName"`
  14. UnForbiddenMatingAt int64 `json:"unForbiddenMatingAt"`
  15. OperationId int64 `json:"operationId"`
  16. OperationName string `json:"operationName"`
  17. UnForbiddenOperationId int64 `json:"unForbiddenOperationId"`
  18. UnForbiddenOperationName string `json:"unForbiddenOperationName"`
  19. Remarks string `json:"remarks"`
  20. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  21. MessageId int64 `json:"messageId"`
  22. MessageName string `json:"messageName"`
  23. CreatedAt int64 `json:"createdAt"`
  24. UpdatedAt int64 `json:"updatedAt"`
  25. }
  26. func (e *EventForbiddenMating) TableName() string {
  27. return "event_forbidden_mating"
  28. }
  29. func (e *EventForbiddenMating) UnForbiddenMatingUpdate(unForbiddenMatingAt int64, currentUser *SystemUser) {
  30. e.UnForbiddenMatingAt = unForbiddenMatingAt
  31. e.IsShow = pasturePb.IsShow_No
  32. e.UnForbiddenOperationId = currentUser.Id
  33. e.UnForbiddenOperationName = currentUser.Name
  34. }
  35. func NewEventForbiddenMating(pastureId int64, cow *Cow, forbiddenMatingAt int64, forbiddenMatingReasonsKind pasturePb.ForbiddenMatingReasons_Kind,
  36. forbiddenMatingReasonsName, remarks string, operationUser, currentUser *SystemUser) *EventForbiddenMating {
  37. return &EventForbiddenMating{
  38. PastureId: pastureId,
  39. CowId: cow.Id,
  40. EarNumber: cow.EarNumber,
  41. DayAge: cow.GetEventDayAge(forbiddenMatingAt),
  42. ForbiddenMatingAt: forbiddenMatingAt,
  43. ForbiddenMatingReasonsKind: forbiddenMatingReasonsKind,
  44. ForbiddenMatingReasonsName: forbiddenMatingReasonsName,
  45. OperationId: operationUser.Id,
  46. OperationName: operationUser.Name,
  47. Remarks: remarks,
  48. MessageId: currentUser.Id,
  49. MessageName: currentUser.Name,
  50. IsShow: pasturePb.IsShow_Ok,
  51. }
  52. }
  53. type EventForbiddenMatingSlice []*EventForbiddenMating
  54. func (e EventForbiddenMatingSlice) ToPB() []*pasturePb.ForbiddenMatingItem {
  55. res := make([]*pasturePb.ForbiddenMatingItem, len(e))
  56. for i, v := range e {
  57. res[i] = &pasturePb.ForbiddenMatingItem{
  58. Id: int32(v.Id),
  59. CowId: int32(v.CowId),
  60. EarNumber: v.EarNumber,
  61. ForbiddenMatingAt: int32(v.ForbiddenMatingAt),
  62. ForbiddenMatingReasonsKind: v.ForbiddenMatingReasonsKind,
  63. ForbiddenMatingReasonsName: v.ForbiddenMatingReasonsName,
  64. Remarks: v.Remarks,
  65. OperationId: int32(v.OperationId),
  66. OperationName: v.OperationName,
  67. CreatedAt: int32(v.CreatedAt),
  68. UpdatedAt: int32(v.UpdatedAt),
  69. }
  70. }
  71. return res
  72. }
  73. type EventForbiddenMatingItem struct {
  74. Cow *Cow `json:"cow"`
  75. ForbiddenMatingAt int64 `json:"forbiddenMatingAt"`
  76. ForbiddenMatingReasonsKind pasturePb.ForbiddenMatingReasons_Kind `json:"forbiddenMatingReasonsKind"`
  77. ForbiddenMatingReasonsName string `json:"forbiddenMatingReasonsName"`
  78. Remarks string `json:"remarks"`
  79. OperationUser *SystemUser `json:"operationUser"`
  80. MessageUser *SystemUser `json:"messageUser"`
  81. }