disease.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. DiseaseTypeName string `json:"disease_type_name"`
  12. IsShow pasturePb.IsShow_Kind `json:"is_show"`
  13. Remarks string `json:"remarks"`
  14. OperationId int64 `json:"operation_id"`
  15. CreatedAt int64 `json:"created_at"`
  16. UpdatedAt int64 `json:"updated_at"`
  17. }
  18. func (d *Disease) TableName() string {
  19. return "disease"
  20. }
  21. type DiseaseSlice []*Disease
  22. func (d DiseaseSlice) ToPB(user []*SystemUser, diseaseTypeList []*ConfigDiseaseType) []*pasturePb.SearchDiseaseList {
  23. res := make([]*pasturePb.SearchDiseaseList, len(d))
  24. for i, dl := range d {
  25. operationName, diseaseTypeName := "", ""
  26. for _, u := range user {
  27. if u.Id == dl.OperationId {
  28. operationName = u.NickName
  29. break
  30. }
  31. }
  32. for _, dt := range diseaseTypeList {
  33. if dt.Id == int64(dl.DiseaseType) {
  34. diseaseTypeName = dt.Name
  35. break
  36. }
  37. }
  38. res[i] = &pasturePb.SearchDiseaseList{
  39. Id: int32(dl.Id),
  40. Remarks: dl.Remarks,
  41. OperationId: int32(dl.OperationId),
  42. OperationName: operationName,
  43. Name: dl.Name,
  44. DiseaseTypeId: dl.DiseaseType,
  45. DiseaseTypeName: diseaseTypeName,
  46. Symptoms: strings.Split(dl.Symptoms, "|"),
  47. IsShow: dl.IsShow,
  48. CreatedAt: int32(dl.CreatedAt),
  49. UpdatedAt: int32(dl.UpdatedAt),
  50. }
  51. }
  52. return res
  53. }
  54. func (d DiseaseSlice) ToPB2() []*pasturePb.ConfigOptionsList {
  55. res := make([]*pasturePb.ConfigOptionsList, len(d))
  56. for i, d := range d {
  57. res[i] = &pasturePb.ConfigOptionsList{
  58. Value: int32(d.Id),
  59. Label: d.Name,
  60. Disabled: true,
  61. }
  62. }
  63. return res
  64. }