package model import ( pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" "github.com/nicksnyder/go-i18n/v2/i18n" ) type ConfigLact struct { Id int32 `json:"id"` PastureId int64 `json:"pastureId"` Kind int32 `json:"kind"` I18nFieldTag string `json:"i18nFieldTag"` Category pasturePb.PastureCategory_Kind `json:"category"` Remarks string `json:"remarks"` IsShow pasturePb.IsShow_Kind `json:"is_show"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` } func (c *ConfigLact) TableName() string { return "config_lact" } type ConfigLactSlice []*ConfigLact func (c ConfigLactSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList { res := make([]*pasturePb.ConfigOptionsList, 0) for _, v := range c { label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{ MessageID: v.I18nFieldTag, }) res = append(res, &pasturePb.ConfigOptionsList{ Value: v.Kind, Label: label, Disabled: true, }) } return res }