feed_formula_detail.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package model
  2. import (
  3. operationPb "kpt-tmr-group/proto/go/backend/operation"
  4. "time"
  5. )
  6. type FeedFormulaDetail struct {
  7. Id int64 `json:"id"`
  8. PastureId int64 `json:"pasture_id"`
  9. PastureName string `json:"pasture_name"`
  10. PastureDataId int64 `json:"pasture_data_id"`
  11. FeedFormulaId int64 `json:"feed_formula_id"`
  12. ForageId int64 `json:"forage_id"`
  13. ForageName string `json:"forage_name"`
  14. ForageGroupName string `json:"forage_group_name"`
  15. Weight int32 `json:"weight"`
  16. StirDelay int32 `json:"stir_delay"`
  17. AllowError int32 `json:"allow_error"`
  18. Prefit int64 `json:"prefit"`
  19. IsShow operationPb.IsShow_Kind `json:"is_show"`
  20. IsLockCowCountRatio operationPb.IsShow_Kind `json:"is_lock_cow_count_ratio"`
  21. Sort int32 `json:"sort"`
  22. CreatedAt int64 `json:"created_at"`
  23. UpdatedAt int64 `json:"updated_at"`
  24. }
  25. func (f *FeedFormulaDetail) TableName() string {
  26. return "feed_formula_detail"
  27. }
  28. type FeedFormulaDetailSlice []*FeedFormulaDetail
  29. func (f FeedFormulaDetailSlice) ToPB() []*operationPb.AddFeedFormulaDetail {
  30. res := make([]*operationPb.AddFeedFormulaDetail, len(f))
  31. for i, v := range f {
  32. res[i] = &operationPb.AddFeedFormulaDetail{
  33. Id: int32(v.Id),
  34. FeedFormulaId: int32(v.FeedFormulaId),
  35. ForageId: int32(v.ForageId),
  36. ForageName: v.ForageName,
  37. ForageGroupName: v.ForageGroupName,
  38. Weight: float32(v.Weight / 100),
  39. StirDelay: v.StirDelay,
  40. AllowError: v.AllowError,
  41. CreatedAt: int32(v.CreatedAt),
  42. PreFit: int32(v.Prefit),
  43. CreatedAtFormat: time.Unix(v.CreatedAt, 0).Format(LayoutTime),
  44. }
  45. }
  46. return res
  47. }