event_cow_treatment.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package model
  2. import (
  3. "encoding/json"
  4. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  5. )
  6. type EventCowTreatment struct {
  7. Id int64 `json:"id"`
  8. CowId int64 `json:"cowId"`
  9. CowDiseaseId int64 `json:"cowDiseaseId"`
  10. DiseaseId int64 `json:"diseaseId"`
  11. DiseaseName string `json:"diseaseName"`
  12. PrescriptionId int32 `json:"prescriptionId"`
  13. PrescriptionName string `json:"prescriptionName"`
  14. PrescriptionDetail string `json:"prescriptionDetail"`
  15. TreatmentResult pasturePb.TreatmentResult_Kind `json:"treatmentResult"`
  16. OperationId int64 `json:"operationId"`
  17. OperationName string `json:"operationName"`
  18. Remarks string `json:"remarks"`
  19. TreatmentAt int64 `json:"treatmentAt"`
  20. CreatedAt int64 `json:"createdAt"`
  21. UpdatedAt int64 `json:"updatedAt"`
  22. }
  23. func (e *EventCowTreatment) TableName() string {
  24. return "event_cow_treatment"
  25. }
  26. func NewEventCowTreatment(prescription *Prescription, req *pasturePb.CowTreatmentRequest, operation *SystemUser) *EventCowTreatment {
  27. b, _ := json.Marshal(req.PrescriptionDetail)
  28. return &EventCowTreatment{
  29. CowId: int64(req.CowId),
  30. CowDiseaseId: int64(req.Id),
  31. DiseaseId: int64(req.DiseaseId),
  32. DiseaseName: req.DiseaseName,
  33. PrescriptionId: req.PrescriptionId,
  34. PrescriptionName: prescription.Name,
  35. PrescriptionDetail: string(b),
  36. TreatmentResult: req.TreatmentResult,
  37. OperationId: operation.Id,
  38. OperationName: operation.Name,
  39. Remarks: req.Remarks,
  40. }
  41. }