event_frozen_semen.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. FrozenSemenType pasturePb.FrozenSemenType_Kind `json:"frozen_semen_type"`
  9. Quantity int32 `json:"quantity"`
  10. Unit pasturePb.Unit_Kind `json:"unit"`
  11. Remarks string `json:"remarks"`
  12. OperationId int64 `json:"operation_id"`
  13. CreatedAt int64 `json:"created_at"`
  14. UpdatedAt int64 `json:"updated_at"`
  15. }
  16. func NewEventFrozenSemen(req *pasturePb.SearchFrozenSemenList, currentUser *SystemUser) *EventFrozenSemen {
  17. return &EventFrozenSemen{
  18. Producer: req.Producer,
  19. BullId: req.BullId,
  20. FrozenSemenType: req.FrozenSemenType,
  21. Quantity: req.Quantity,
  22. Unit: req.Unit,
  23. Remarks: req.Remarks,
  24. OperationId: currentUser.Id,
  25. }
  26. }
  27. func (e *EventFrozenSemen) TableName() string {
  28. return "event_frozen_semen"
  29. }
  30. type EventFrozenSemenSlice []*EventFrozenSemen
  31. func (e EventFrozenSemenSlice) ToPB(
  32. frozenSemenTypeMap map[pasturePb.FrozenSemenType_Kind]string,
  33. unitMap map[pasturePb.Unit_Kind]string) []*pasturePb.SearchFrozenSemenList {
  34. res := make([]*pasturePb.SearchFrozenSemenList, len(e))
  35. for i, v := range e {
  36. res[i] = &pasturePb.SearchFrozenSemenList{
  37. Id: int32(v.Id),
  38. ParentId: int32(v.ParentId),
  39. Producer: v.Producer,
  40. BullId: v.BullId,
  41. FrozenSemenType: v.FrozenSemenType,
  42. FrozenSemenTypeName: frozenSemenTypeMap[v.FrozenSemenType],
  43. Quantity: v.Quantity,
  44. Unit: v.Unit,
  45. UnitName: unitMap[v.Unit],
  46. Remarks: v.Remarks,
  47. OperationId: int32(v.OperationId),
  48. CreatedAt: int32(v.CreatedAt),
  49. UpdatedAt: int32(v.UpdatedAt),
  50. }
  51. }
  52. return res
  53. }