event_frozen_semen.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. type EventFrozenSemen struct {
  4. Id int64 `json:"id"`
  5. ParentId int64 `json:"parent_id"`
  6. Producer string `json:"producer"`
  7. BullId string `json:"bull_id"`
  8. KindId pasturePb.CowKind_Kind `json:"kind_id"`
  9. KindName string `json:"kind_name"`
  10. FrozenSemenType pasturePb.FrozenSemenType_Kind `json:"frozen_semen_type"`
  11. Quantity int32 `json:"quantity"`
  12. Unit pasturePb.Unit_Kind `json:"unit"`
  13. Remarks string `json:"remarks"`
  14. OperationId int64 `json:"operation_id"`
  15. CreatedAt int64 `json:"created_at"`
  16. UpdatedAt int64 `json:"updated_at"`
  17. }
  18. func NewEventFrozenSemen(req *pasturePb.SearchFrozenSemenList, currentUser *SystemUser) *EventFrozenSemen {
  19. return &EventFrozenSemen{
  20. Producer: req.Producer,
  21. BullId: req.BullId,
  22. KindId: req.CowKind,
  23. KindName: req.CowKindName,
  24. FrozenSemenType: req.FrozenSemenType,
  25. Quantity: req.Quantity,
  26. Unit: req.Unit,
  27. Remarks: req.Remarks,
  28. OperationId: currentUser.Id,
  29. }
  30. }
  31. func (e *EventFrozenSemen) TableName() string {
  32. return "event_frozen_semen"
  33. }
  34. type EventFrozenSemenSlice []*EventFrozenSemen
  35. func (e EventFrozenSemenSlice) ToPB(
  36. frozenSemenTypeMap map[pasturePb.FrozenSemenType_Kind]string,
  37. unitMap map[pasturePb.Unit_Kind]string) []*pasturePb.SearchFrozenSemenList {
  38. res := make([]*pasturePb.SearchFrozenSemenList, len(e))
  39. for i, v := range e {
  40. res[i] = &pasturePb.SearchFrozenSemenList{
  41. Id: int32(v.Id),
  42. ParentId: int32(v.ParentId),
  43. Producer: v.Producer,
  44. BullId: v.BullId,
  45. CowKind: v.KindId,
  46. CowKindName: v.KindName,
  47. FrozenSemenType: v.FrozenSemenType,
  48. FrozenSemenTypeName: frozenSemenTypeMap[v.FrozenSemenType],
  49. Quantity: v.Quantity,
  50. Unit: v.Unit,
  51. UnitName: unitMap[v.Unit],
  52. Remarks: v.Remarks,
  53. OperationId: int32(v.OperationId),
  54. CreatedAt: int32(v.CreatedAt),
  55. UpdatedAt: int32(v.UpdatedAt),
  56. }
  57. }
  58. return res
  59. }