1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package model
- import (
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- "github.com/nicksnyder/go-i18n/v2/i18n"
- )
- type ConfigBreedStatus struct {
- Id int64 `json:"id"`
- PastureId int64 `json:"pastureId"`
- Kind pasturePb.BreedStatus_Kind `json:"kind"`
- I18NFieldTag string `json:"i18NFieldTag"`
- Remarks string `json:"remarks"`
- IsShow pasturePb.IsShow_Kind `json:"isShow"`
- CreatedAt int64 `json:"createdAt"`
- UpdatedAt int64 `json:"updatedAt"`
- }
- func (c *ConfigBreedStatus) TableName() string {
- return "config_breed_status"
- }
- type ConfigBreedStatusSlice []*ConfigBreedStatus
- func (c ConfigBreedStatusSlice) ToPB(userModel *UserModel) []*pasturePb.SearchBaseConfigList {
- res := make([]*pasturePb.SearchBaseConfigList, len(c))
- for i, d := range c {
- name, _ := userModel.LanguageContent.Localize(&i18n.LocalizeConfig{
- MessageID: d.I18NFieldTag,
- })
- res[i] = &pasturePb.SearchBaseConfigList{
- Id: int32(d.Id),
- Name: name,
- Remarks: d.Remarks,
- IsShow: d.IsShow,
- CreatedAt: int32(d.CreatedAt),
- UpdatedAt: int32(d.UpdatedAt),
- }
- }
- return res
- }
- func (c ConfigBreedStatusSlice) ToPB2(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: int32(v.Kind),
- Label: label,
- Disabled: true,
- })
- }
- return res
- }
|