feed_formula_detail.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. IsShow operationPb.IsShow_Kind `json:"is_show"`
  19. Sort int32 `json:"sort"`
  20. CreatedAt int64 `json:"created_at"`
  21. UpdatedAt int64 `json:"updated_at"`
  22. }
  23. func (f *FeedFormulaDetail) TableName() string {
  24. return "feed_formula_detail"
  25. }
  26. type FeedFormulaDetailSlice []*FeedFormulaDetail
  27. func (f FeedFormulaDetailSlice) ToPB() []*operationPb.AddFeedFormulaDetail {
  28. res := make([]*operationPb.AddFeedFormulaDetail, len(f))
  29. for i, v := range f {
  30. res[i] = &operationPb.AddFeedFormulaDetail{
  31. Id: int32(v.Id),
  32. FeedFormulaId: int32(v.FeedFormulaId),
  33. ForageId: int32(v.ForageId),
  34. ForageName: v.ForageName,
  35. ForageGroupName: v.ForageGroupName,
  36. Weight: float32(v.Weight / 100),
  37. StirDelay: v.StirDelay,
  38. AllowError: v.AllowError,
  39. CreatedAt: int32(v.CreatedAt),
  40. CreatedAtFormat: time.Unix(v.CreatedAt, 0).Format(LayoutTime),
  41. }
  42. }
  43. return res
  44. }