event_weaning.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. Remarks string `json:"remarks"`
  17. OperationId int32 `json:"operationId"`
  18. OperationName string `json:"operationName"`
  19. CreatedAt int64 `json:"createdAt"`
  20. UpdatedAt int64 `json:"updatedAt"`
  21. }
  22. func (c *EventWeaning) TableName() string {
  23. return "event_weaning"
  24. }
  25. func NewEventWeaning(cowId int64, penId int32) *EventWeaning {
  26. return &EventWeaning{
  27. CowId: cowId,
  28. PlanDay: util.TimeParseLocalUnix(time.Now().Format(LayoutDate2)),
  29. EndDay: util.TimeParseLocalEndUnix(time.Now().Format(LayoutDate2)),
  30. Status: pasturePb.IsShow_No,
  31. BeforePenId: penId,
  32. }
  33. }
  34. func NewEventWeaningList(cowList []*Cow) []*EventWeaning {
  35. var weaningList = make([]*EventWeaning, 0)
  36. for _, cow := range cowList {
  37. weaningList = append(weaningList, NewEventWeaning(cow.Id, cow.PenId))
  38. }
  39. return weaningList
  40. }