event_weaning.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package model
  2. import (
  3. "kpt-pasture/util"
  4. "time"
  5. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  6. )
  7. type EventWeaning struct {
  8. Id int64 `json:"id"`
  9. CowId int64 `json:"cowId"`
  10. PlanDay int64 `json:"planDay"`
  11. EndDay int64 `json:"endDay"`
  12. RealityDay int64 `json:"realityDay"`
  13. Status pasturePb.IsShow_Kind `json:"status"`
  14. BeforePenId int32 `json:"beforePenId"`
  15. AfterPenId int32 `json:"afterPenId"`
  16. RealityDayAge int32 `json:"realityDayAge"`
  17. Remarks string `json:"remarks"`
  18. OperationId int32 `json:"operationId"`
  19. OperationName string `json:"operationName"`
  20. CreatedAt int64 `json:"createdAt"`
  21. UpdatedAt int64 `json:"updatedAt"`
  22. }
  23. func (c *EventWeaning) TableName() string {
  24. return "event_weaning"
  25. }
  26. func NewEventWeaning(cowId int64, penId int32) *EventWeaning {
  27. return &EventWeaning{
  28. CowId: cowId,
  29. PlanDay: util.TimeParseLocalUnix(time.Now().Format(LayoutDate2)),
  30. EndDay: util.TimeParseLocalEndUnix(time.Now().Format(LayoutDate2)),
  31. Status: pasturePb.IsShow_No,
  32. BeforePenId: penId,
  33. }
  34. }
  35. func NewEventWeaningList(cowList []*Cow) []*EventWeaning {
  36. var weaningList = make([]*EventWeaning, 0)
  37. for _, cow := range cowList {
  38. weaningList = append(weaningList, NewEventWeaning(cow.Id, cow.PenId))
  39. }
  40. return weaningList
  41. }
  42. type WeaningHeader struct {
  43. Id string `json:"id"`
  44. CowId string `json:"cowId"`
  45. DayAge string `json:"dayAge"`
  46. PlanDay string `json:"planDay"`
  47. Status string `json:"status"`
  48. PenName string `json:"penName"`
  49. }
  50. type WeaningBody struct {
  51. Id int64 `json:"id"`
  52. CowId int64 `json:"cowId"`
  53. DayAge int64 `json:"dayAge"`
  54. PlanDay string `json:"planDay"`
  55. Status pasturePb.IsShow_Kind `json:"status"`
  56. PenName string `json:"penName"`
  57. }