disease.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package model
  2. import (
  3. "strings"
  4. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  5. )
  6. type Disease struct {
  7. Id int64 `json:"id"`
  8. Name string `json:"name"`
  9. Symptoms string `json:"symptoms"`
  10. DiseaseType int32 `json:"disease_type"`
  11. IsShow pasturePb.IsShow_Kind `json:"is_show"`
  12. Remarks string `json:"remarks"`
  13. OperationId int64 `json:"operation_id"`
  14. CreatedAt int64 `json:"created_at"`
  15. UpdatedAt int64 `json:"updated_at"`
  16. }
  17. func (d *Disease) TableName() string {
  18. return "disease"
  19. }
  20. type DiseaseSlice []*Disease
  21. func (d DiseaseSlice) ToPB(user []*SystemUser, diseaseTypeList []*ConfigDiseaseType) []*pasturePb.SearchDiseaseList {
  22. res := make([]*pasturePb.SearchDiseaseList, len(d))
  23. for i, dl := range d {
  24. operationName, diseaseTypeName := "", ""
  25. for _, u := range user {
  26. if u.Id == dl.OperationId {
  27. operationName = u.NickName
  28. break
  29. }
  30. }
  31. for _, dt := range diseaseTypeList {
  32. if dt.Id == int64(dl.DiseaseType) {
  33. diseaseTypeName = dt.Name
  34. break
  35. }
  36. }
  37. res[i] = &pasturePb.SearchDiseaseList{
  38. Id: int32(dl.Id),
  39. Remarks: dl.Remarks,
  40. OperationId: int32(dl.OperationId),
  41. OperationName: operationName,
  42. Name: dl.Name,
  43. DiseaseTypeId: dl.DiseaseType,
  44. DiseaseTypeName: diseaseTypeName,
  45. Symptoms: strings.Split(dl.Symptoms, "|"),
  46. IsShow: dl.IsShow,
  47. CreatedAt: int32(dl.CreatedAt),
  48. UpdatedAt: int32(dl.UpdatedAt),
  49. }
  50. }
  51. return res
  52. }
  53. func (c DiseaseSlice) ToPB2() []*pasturePb.ConfigOptionsList {
  54. res := make([]*pasturePb.ConfigOptionsList, len(c))
  55. for i, d := range c {
  56. res[i] = &pasturePb.ConfigOptionsList{
  57. Value: int32(d.Id),
  58. Label: d.Name,
  59. Disabled: true,
  60. }
  61. }
  62. return res
  63. }