config_lact.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package model
  2. import (
  3. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  4. "github.com/nicksnyder/go-i18n/v2/i18n"
  5. )
  6. type ConfigLact struct {
  7. Id int32 `json:"id"`
  8. PastureId int64 `json:"pastureId"`
  9. Kind int32 `json:"kind"`
  10. I18nFieldTag string `json:"i18nFieldTag"`
  11. Category pasturePb.PastureCategory_Kind `json:"category"`
  12. Remarks string `json:"remarks"`
  13. IsShow pasturePb.IsShow_Kind `json:"is_show"`
  14. CreatedAt int64 `json:"created_at"`
  15. UpdatedAt int64 `json:"updated_at"`
  16. }
  17. func (c *ConfigLact) TableName() string {
  18. return "config_lact"
  19. }
  20. type ConfigLactSlice []*ConfigLact
  21. func (c ConfigLactSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
  22. res := make([]*pasturePb.ConfigOptionsList, 0)
  23. for _, v := range c {
  24. label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
  25. MessageID: v.I18nFieldTag,
  26. })
  27. res = append(res, &pasturePb.ConfigOptionsList{
  28. Value: v.Kind,
  29. Label: label,
  30. Disabled: true,
  31. })
  32. }
  33. return res
  34. }