feed_formula_detail.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package model
  2. import (
  3. operationPb "gitee.com/xuyiping_admin/go_proto/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. IsModify operationPb.IsShow_Kind `json:"is_modify"`
  21. IsLockCowCountRatio operationPb.IsShow_Kind `json:"is_lock_cow_count_ratio"`
  22. Sort int32 `json:"sort"`
  23. CreatedAt int64 `json:"created_at"`
  24. UpdatedAt int64 `json:"updated_at"`
  25. }
  26. func (f *FeedFormulaDetail) TableName() string {
  27. return "feed_formula_detail"
  28. }
  29. type FeedFormulaDetailSlice []*FeedFormulaDetail
  30. func (f FeedFormulaDetailSlice) ToPB() []*operationPb.AddFeedFormulaDetail {
  31. res := make([]*operationPb.AddFeedFormulaDetail, len(f))
  32. for i, v := range f {
  33. res[i] = &operationPb.AddFeedFormulaDetail{
  34. Id: int32(v.Id),
  35. FeedFormulaId: int32(v.FeedFormulaId),
  36. ForageId: int32(v.ForageId),
  37. ForageName: v.ForageName,
  38. ForageGroupName: v.ForageGroupName,
  39. Weight: float32(v.Weight / 100),
  40. StirDelay: v.StirDelay,
  41. AllowError: v.AllowError,
  42. CreatedAt: int32(v.CreatedAt),
  43. PreFit: int32(v.Prefit),
  44. IsModify: v.IsModify,
  45. Sort: v.Sort,
  46. CreatedAtFormat: time.Unix(v.CreatedAt, 0).Format(LayoutTime),
  47. }
  48. }
  49. return res
  50. }