event_weaning.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. }