feed_formula_detail.go 1.9 KB

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