event_forbidden_mating.go 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. ForbiddenMatingAt int64 `json:"forbiddenMatingAt"`
  11. ForbiddenMatingReasonsKind pasturePb.ForbiddenMatingReasons_Kind `json:"forbiddenMatingReasonsKind"`
  12. ForbiddenMatingReasonsName string `json:"forbiddenMatingReasonsName"`
  13. UnForbiddenMatingAt int64 `json:"unForbiddenMatingAt"`
  14. OperationId int64 `json:"operationId"`
  15. OperationName string `json:"operationName"`
  16. Remarks string `json:"remarks"`
  17. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  18. MessageId int64 `json:"messageId"`
  19. MessageName string `json:"messageName"`
  20. CreatedAt int64 `json:"createdAt"`
  21. UpdatedAt int64 `json:"updatedAt"`
  22. }
  23. func (e *EventForbiddenMating) TableName() string {
  24. return "event_forbidden_mating"
  25. }
  26. func (e *EventForbiddenMating) UnForbiddenMatingUpdate(unForbiddenMatingAt int64) {
  27. e.UnForbiddenMatingAt = unForbiddenMatingAt
  28. e.IsShow = pasturePb.IsShow_No
  29. }
  30. func NewEventForbiddenMating(pastureId int64, cow *Cow, forbiddenMatingAt int64, forbiddenMatingReasonsKind pasturePb.ForbiddenMatingReasons_Kind,
  31. forbiddenMatingReasonsName, remarks string, operationUser, currentUser *SystemUser) *EventForbiddenMating {
  32. return &EventForbiddenMating{
  33. PastureId: pastureId,
  34. CowId: cow.Id,
  35. EarNumber: cow.EarNumber,
  36. ForbiddenMatingAt: forbiddenMatingAt,
  37. ForbiddenMatingReasonsKind: forbiddenMatingReasonsKind,
  38. ForbiddenMatingReasonsName: forbiddenMatingReasonsName,
  39. OperationId: operationUser.Id,
  40. OperationName: operationUser.Name,
  41. Remarks: remarks,
  42. MessageId: currentUser.Id,
  43. MessageName: currentUser.Name,
  44. IsShow: pasturePb.IsShow_Ok,
  45. }
  46. }
  47. type EventForbiddenMatingSlice []*EventForbiddenMating
  48. func (e EventForbiddenMatingSlice) ToPB() []*pasturePb.ForbiddenMatingItem {
  49. res := make([]*pasturePb.ForbiddenMatingItem, len(e))
  50. for i, v := range e {
  51. res[i] = &pasturePb.ForbiddenMatingItem{
  52. Id: int32(v.Id),
  53. CowId: int32(v.CowId),
  54. EarNumber: v.EarNumber,
  55. ForbiddenMatingAt: int32(v.ForbiddenMatingAt),
  56. ForbiddenMatingReasonsKind: v.ForbiddenMatingReasonsKind,
  57. ForbiddenMatingReasonsName: v.ForbiddenMatingReasonsName,
  58. Remarks: v.Remarks,
  59. OperationId: int32(v.OperationId),
  60. OperationName: v.OperationName,
  61. CreatedAt: int32(v.CreatedAt),
  62. UpdatedAt: int32(v.UpdatedAt),
  63. }
  64. }
  65. return res
  66. }
  67. type EventForbiddenMatingItem struct {
  68. Cow *Cow `json:"cow"`
  69. ForbiddenMatingAt int64 `json:"forbiddenMatingAt"`
  70. ForbiddenMatingReasonsKind pasturePb.ForbiddenMatingReasons_Kind `json:"forbiddenMatingReasonsKind"`
  71. ForbiddenMatingReasonsName string `json:"forbiddenMatingReasonsName"`
  72. Remarks string `json:"remarks"`
  73. OperationUser *SystemUser `json:"operationUser"`
  74. MessageUser *SystemUser `json:"messageUser"`
  75. }