cow.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. type Cow struct {
  4. Id int64 `json:"id"`
  5. Sex pasturePb.Genders_Kind `json:"sex"`
  6. NeckRingNumber string `json:"neck_ring_number"`
  7. EarNumber string `json:"ear_number"`
  8. EarOldNumber string `json:"ear_old_number"`
  9. PenId int64 `json:"pen_id"`
  10. Lact int32 `json:"lact"`
  11. TypeId int32 `json:"type_id"`
  12. BreedStatusId int32 `json:"breed_status_id"`
  13. KindId int32 `json:"kind_id"`
  14. BirthWeight int64 `json:"birth_weight"`
  15. CurrentWeight int64 `json:"current_weight"`
  16. SourceId int32 `json:"source_id"`
  17. FatherId int32 `json:"father_id"`
  18. MotherId int32 `json:"mother_id"`
  19. IsRemove pasturePb.IsShow_Kind `json:"is_remove"`
  20. IsPregnant pasturePb.IsShow_Kind `json:"is_pregnant"`
  21. Status int32 `json:"status"`
  22. WeaningAt int64 `json:"weaning_at"`
  23. BirthAt int64 `json:"birth_at"`
  24. FirstMatingAt int64 `json:"first_mating_at"`
  25. LastEstrusAt int64 `json:"last_estrus_at"`
  26. LastCalvingAt int64 `json:"last_calving_at"`
  27. LastMatingAt int64 `json:"last_mating_at"`
  28. LastPregnantCheckAt int64 `json:"last_pregnant_check_at"`
  29. LastDryMilkAt int64 `json:"last_dry_milk_at"`
  30. CreatedAt int64 `json:"created_at"`
  31. UpdatedAt int64 `json:"updated_at"`
  32. }
  33. func (c *Cow) TableName() string {
  34. return "cow"
  35. }
  36. func NewCow(req *pasturePb.SearchEnterData) *Cow {
  37. var (
  38. status int32 = 1
  39. isPregnant pasturePb.IsShow_Kind = pasturePb.IsShow_No
  40. )
  41. if req.BreedStatusId == 4 || req.BreedStatusId == 5 {
  42. isPregnant = pasturePb.IsShow_Ok
  43. status = 4
  44. }
  45. return &Cow{
  46. Sex: req.Sex,
  47. EarNumber: req.EarNumber,
  48. PenId: int64(req.PenId),
  49. Lact: req.Lact,
  50. TypeId: req.CowTypeId,
  51. BreedStatusId: req.BreedStatusId,
  52. KindId: req.CowKindId,
  53. SourceId: req.CowSourceId,
  54. FatherId: req.FatherId,
  55. MotherId: req.MotherId,
  56. IsRemove: pasturePb.IsShow_Ok,
  57. IsPregnant: isPregnant,
  58. Status: status,
  59. WeaningAt: int64(req.WeaningAt),
  60. BirthAt: int64(req.BirthAt),
  61. FirstMatingAt: int64(req.MatingAt),
  62. LastMatingAt: int64(req.MatingAt),
  63. LastPregnantCheckAt: int64(req.PregnancyCheckAt),
  64. }
  65. }