prescription_drugs.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. type PrescriptionDrugs struct {
  4. Id int32 `json:"id"`
  5. PastureId int64 `json:"pasture_id"`
  6. PrescriptionId int32 `json:"prescription_id"`
  7. DrugsId int64 `json:"drugs_id"`
  8. DrugsName string `json:"drugs_name"`
  9. UseDays int32 `json:"use_days"`
  10. Dosages float32 `json:"dosages"`
  11. Unit pasturePb.Unit_Kind `json:"unit"`
  12. UnitName string `json:"unit_name"`
  13. Specs string `json:"specs"`
  14. IsShow pasturePb.IsShow_Kind `json:"is_show"`
  15. CreatedAt int64 `json:"created_at"`
  16. UpdatedAt int64 `json:"updated_at"`
  17. }
  18. func (p *PrescriptionDrugs) TableName() string {
  19. return "prescription_drugs"
  20. }
  21. func NewPrescriptionDrugs(pastureId int64, prescriptionId int32, list []*pasturePb.PrescriptionDrugsList) []*PrescriptionDrugs {
  22. res := make([]*PrescriptionDrugs, len(list))
  23. for i, v := range list {
  24. res[i] = &PrescriptionDrugs{
  25. PrescriptionId: prescriptionId,
  26. DrugsId: int64(v.DrugsId),
  27. DrugsName: v.DrugsName,
  28. UseDays: v.UseDays,
  29. Dosages: v.Dosages,
  30. Unit: v.Unit,
  31. UnitName: v.UnitName,
  32. Specs: v.Specs,
  33. IsShow: pasturePb.IsShow_Ok,
  34. }
  35. }
  36. return res
  37. }
  38. type PrescriptionDrugsSlice []*PrescriptionDrugs
  39. func (p PrescriptionDrugsSlice) ToPB() []*pasturePb.PrescriptionDrugsList {
  40. res := make([]*pasturePb.PrescriptionDrugsList, len(p))
  41. for i, v := range p {
  42. res[i] = &pasturePb.PrescriptionDrugsList{
  43. DrugsId: int32(v.DrugsId),
  44. DrugsName: v.DrugsName,
  45. UseDays: v.UseDays,
  46. Dosages: v.Dosages,
  47. Unit: v.Unit,
  48. UnitName: v.UnitName,
  49. Specs: v.Specs,
  50. }
  51. }
  52. return res
  53. }