12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package model
- import (
- pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- )
- type ConfigDiseaseType struct {
- Id int64 `json:"id"`
- Name string `json:"name"`
- Remarks string `json:"remarks"`
- IsShow pasturePb.IsShow_Kind `json:"is_show"`
- CreatedAt int64 `json:"created_at"`
- UpdatedAt int64 `json:"updated_at"`
- }
- func (c *ConfigDiseaseType) TableName() string {
- return "config_disease_type"
- }
- type ConfigDiseaseTypeSlice []*ConfigDiseaseType
- func (c ConfigDiseaseTypeSlice) ToPB() []*pasturePb.SearchBaseConfigList {
- res := make([]*pasturePb.SearchBaseConfigList, len(c))
- for i, d := range c {
- res[i] = &pasturePb.SearchBaseConfigList{
- Id: int32(d.Id),
- Name: d.Name,
- Remarks: d.Remarks,
- IsShow: d.IsShow,
- CreatedAt: int32(d.CreatedAt),
- UpdatedAt: int32(d.UpdatedAt),
- }
- }
- return res
- }
- func (c ConfigDiseaseTypeSlice) ToPB2(diseaseList []*Disease) []*pasturePb.ConfigOptionsList {
- res := make([]*pasturePb.ConfigOptionsList, len(c))
- for i, d := range c {
- children := make([]*pasturePb.ConfigOptionsList, 0)
- if len(diseaseList) > 0 {
- for _, v := range diseaseList {
- if int64(v.DiseaseType) != d.Id {
- continue
- }
- children = append(children, &pasturePb.ConfigOptionsList{
- Value: int32(v.Id),
- Label: v.Name,
- Disabled: true,
- })
- }
- }
- res[i] = &pasturePb.ConfigOptionsList{
- Value: int32(d.Id),
- Label: d.Name,
- Disabled: true,
- Children: children,
- }
- }
- return res
- }
|