config_disease_type.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package model
  2. import (
  3. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  4. )
  5. type ConfigDiseaseType struct {
  6. Id int64 `json:"id"`
  7. Name string `json:"name"`
  8. Remarks string `json:"remarks"`
  9. IsShow pasturePb.IsShow_Kind `json:"is_show"`
  10. CreatedAt int64 `json:"created_at"`
  11. UpdatedAt int64 `json:"updated_at"`
  12. }
  13. func (c *ConfigDiseaseType) TableName() string {
  14. return "config_disease_type"
  15. }
  16. type ConfigDiseaseTypeSlice []*ConfigDiseaseType
  17. func (c ConfigDiseaseTypeSlice) ToPB() []*pasturePb.SearchBaseConfigList {
  18. res := make([]*pasturePb.SearchBaseConfigList, len(c))
  19. for i, d := range c {
  20. res[i] = &pasturePb.SearchBaseConfigList{
  21. Id: int32(d.Id),
  22. Name: d.Name,
  23. Remarks: d.Remarks,
  24. IsShow: d.IsShow,
  25. CreatedAt: int32(d.CreatedAt),
  26. UpdatedAt: int32(d.UpdatedAt),
  27. }
  28. }
  29. return res
  30. }
  31. func (c ConfigDiseaseTypeSlice) ToPB2(diseaseList []*Disease) []*pasturePb.ConfigOptionsList {
  32. res := make([]*pasturePb.ConfigOptionsList, len(c))
  33. for i, d := range c {
  34. children := make([]*pasturePb.ConfigOptionsList, 0)
  35. if len(diseaseList) > 0 {
  36. for _, v := range diseaseList {
  37. if int64(v.DiseaseType) != d.Id {
  38. continue
  39. }
  40. children = append(children, &pasturePb.ConfigOptionsList{
  41. Value: int32(v.Id),
  42. Label: v.Name,
  43. Disabled: true,
  44. })
  45. }
  46. }
  47. res[i] = &pasturePb.ConfigOptionsList{
  48. Value: int32(d.Id),
  49. Label: d.Name,
  50. Disabled: true,
  51. Children: children,
  52. }
  53. }
  54. return res
  55. }