event_forbidden_mating.go 4.4 KB

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