1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- package model
- import (
- operationPb "kpt-tmr-group/proto/go/backend/operation"
- "time"
- )
- type FeedFormula struct {
- Id int64 `json:"id"`
- Name string `json:"name"`
- Colour string `json:"colour"`
- EncodeNumber string `json:"encode_number"`
- CattleCategoryId operationPb.CattleCategoryParent_Kind `json:"cattle_category_id"`
- CattleCategoryName string `json:"cattle_category_name"`
- FormulaTypeId int32 `json:"formula_type_id"`
- FormulaTypeName string `json:"formula_type_name"`
- DataSourceId operationPb.DataSource_Kind `json:"data_source_id"`
- DataSourceName string `json:"data_source_name"`
- Remarks string `json:"remarks"`
- Version int64 `json:"version"`
- PastureId int64 `json:"pasture_id"`
- PastureName string `json:"pasture_name"`
- IsShow operationPb.IsShow_Kind `json:"is_show"`
- IsModify operationPb.IsShow_Kind `json:"is_modify"`
- IsDelete operationPb.IsShow_Kind `json:"is_delete"`
- CreatedAt int64 `json:"created_at"`
- UpdatedAt int64 `json:"updated_at"`
- }
- func (f *FeedFormula) TableName() string {
- return "feed_formula"
- }
- func NewFeedFormula(req *operationPb.AddFeedFormulaRequest) *FeedFormula {
- return &FeedFormula{
- Name: req.Name,
- Colour: req.Colour,
- EncodeNumber: req.EncodeNumber,
- CattleCategoryId: req.CattleCategoryId,
- CattleCategoryName: req.CattleCategoryName,
- FormulaTypeId: req.FormulaTypeId,
- FormulaTypeName: req.FormulaTypeName,
- DataSourceId: req.DataSourceId,
- DataSourceName: req.DataSourceName,
- Remarks: req.Remarks,
- Version: 0,
- PastureId: 0,
- PastureName: "",
- IsShow: req.IsShow,
- IsDelete: operationPb.IsShow_OK,
- IsModify: operationPb.IsShow_OK,
- }
- }
- type FeedFormulaSlice []*FeedFormula
- func (f FeedFormulaSlice) ToPB() []*operationPb.AddFeedFormulaRequest {
- res := make([]*operationPb.AddFeedFormulaRequest, len(f))
- for i, v := range f {
- res[i] = &operationPb.AddFeedFormulaRequest{
- Id: int32(v.Id),
- Name: v.Name,
- Colour: v.Colour,
- EncodeNumber: v.EncodeNumber,
- CattleCategoryId: v.CattleCategoryId,
- CattleCategoryName: v.CattleCategoryName,
- FormulaTypeId: v.FormulaTypeId,
- FormulaTypeName: v.FormulaTypeName,
- DataSourceName: v.DataSourceName,
- DataSourceId: v.DataSourceId,
- Remarks: v.Remarks,
- Version: int32(v.Version),
- PastureName: v.PastureName,
- IsShow: v.IsShow,
- IsModify: v.IsModify,
- CreatedAt: int32(v.CreatedAt),
- CreatedAtFormat: time.Unix(v.CreatedAt, 0).Format(LayoutTime),
- }
- }
- return res
- }
- type DistributeData struct {
- PastureList []*GroupPasture
- FeedFormulaList []*FeedFormula
- }
|