config_cow_purpose.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 ConfigCowPurpose struct {
  7. Id int64 `json:"id"`
  8. PastureId int64 `json:"pastureId"`
  9. Kind pasturePb.Purpose_Kind `json:"kind"`
  10. I18NFieldTag string `json:"i18nFieldTag"`
  11. Remarks string `json:"remarks"`
  12. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  13. CreatedAt int64 `json:"createdAt"`
  14. UpdatedAt int64 `json:"updatedAt"`
  15. }
  16. func (c *ConfigCowPurpose) TableName() string {
  17. return "config_cow_purpose"
  18. }
  19. type ConfigCowPurposeSlice []*ConfigCowPurpose
  20. func (c ConfigCowPurposeSlice) ToPB(userModel *UserModel) []*pasturePb.ConfigOptionsList {
  21. res := make([]*pasturePb.ConfigOptionsList, 0)
  22. for _, v := range c {
  23. label, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
  24. MessageID: v.I18NFieldTag,
  25. })
  26. res = append(res, &pasturePb.ConfigOptionsList{
  27. Value: int32(v.Kind),
  28. Label: label,
  29. Disabled: true,
  30. })
  31. }
  32. return res
  33. }