feed_formula.go 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package model
  2. import (
  3. operationPb "kpt-tmr-group/proto/go/backend/operation"
  4. "time"
  5. )
  6. type FeedFormula struct {
  7. Id int64 `json:"id"`
  8. Name string `json:"name"`
  9. Colour string `json:"colour"`
  10. EncodeNumber string `json:"encode_number"`
  11. CattleCategoryId operationPb.CattleCategoryParent_Kind `json:"cattle_category_id"`
  12. CattleCategoryName string `json:"cattle_category_name"`
  13. FormulaTypeId operationPb.FormulaType_Kind `json:"formula_type_id"`
  14. FormulaTypeName string `json:"formula_type_name"`
  15. DataSourceId operationPb.DataSource_Kind `json:"data_source_id"`
  16. DataSourceName string `json:"data_source_name"`
  17. Remarks string `json:"remarks"`
  18. Version int64 `json:"version"`
  19. PastureId int64 `json:"pasture_id"`
  20. PastureName string `json:"pasture_name"`
  21. PastureDataId int64 `json:"pasture_data_id"`
  22. IsShow operationPb.IsShow_Kind `json:"is_show"`
  23. IsModify operationPb.IsShow_Kind `json:"is_modify"`
  24. IsDelete operationPb.IsShow_Kind `json:"is_delete"`
  25. CreatedAt int64 `json:"created_at"`
  26. UpdatedAt int64 `json:"updated_at"`
  27. }
  28. func (f *FeedFormula) TableName() string {
  29. return "feed_formula"
  30. }
  31. func NewFeedFormula(req *operationPb.AddFeedFormulaRequest) *FeedFormula {
  32. return &FeedFormula{
  33. Name: req.Name,
  34. Colour: req.Colour,
  35. EncodeNumber: req.EncodeNumber,
  36. CattleCategoryId: req.CattleCategoryId,
  37. CattleCategoryName: req.CattleCategoryName,
  38. FormulaTypeId: req.FormulaTypeId,
  39. FormulaTypeName: req.FormulaTypeName,
  40. DataSourceId: req.DataSourceId,
  41. DataSourceName: req.DataSourceName,
  42. Remarks: req.Remarks,
  43. Version: 0,
  44. PastureId: 0,
  45. PastureName: "集团",
  46. IsShow: req.IsShow,
  47. IsDelete: operationPb.IsShow_OK,
  48. IsModify: operationPb.IsShow_OK,
  49. }
  50. }
  51. type FeedFormulaSlice []*FeedFormula
  52. func (f FeedFormulaSlice) ToPB() []*operationPb.AddFeedFormulaRequest {
  53. res := make([]*operationPb.AddFeedFormulaRequest, len(f))
  54. for i, v := range f {
  55. res[i] = &operationPb.AddFeedFormulaRequest{
  56. Id: int32(v.Id),
  57. Name: v.Name,
  58. Colour: v.Colour,
  59. EncodeNumber: v.EncodeNumber,
  60. CattleCategoryId: v.CattleCategoryId,
  61. CattleCategoryName: v.CattleCategoryName,
  62. FormulaTypeId: v.FormulaTypeId,
  63. FormulaTypeName: v.FormulaTypeName,
  64. DataSourceName: v.DataSourceName,
  65. DataSourceId: v.DataSourceId,
  66. Remarks: v.Remarks,
  67. Version: int32(v.Version),
  68. PastureName: v.PastureName,
  69. IsShow: v.IsShow,
  70. IsModify: v.IsModify,
  71. CreatedAt: int32(v.CreatedAt),
  72. CreatedAtFormat: time.Unix(v.CreatedAt, 0).Format(LayoutTime),
  73. }
  74. }
  75. return res
  76. }
  77. type DistributeData struct {
  78. PastureList []*GroupPasture
  79. FeedFormulaList []*FeedFormula
  80. FeedFormulaDetail []*FeedFormulaDetail
  81. }