event_cow_treatment.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. PrescriptionId int32 `json:"prescriptionId"`
  11. PrescriptionDetail string `json:"prescriptionDetail"`
  12. TreatmentResult pasturePb.TreatmentResult_Kind `json:"treatmentResult"`
  13. OperationId int64 `json:"operationId"`
  14. OperationName string `json:"operationName"`
  15. Remarks string `json:"remarks"`
  16. TreatmentAt int64 `json:"treatmentAt"`
  17. CreatedAt int64 `json:"createdAt"`
  18. UpdatedAt int64 `json:"updatedAt"`
  19. }
  20. func (e *EventCowTreatment) TableName() string {
  21. return "event_cow_treatment"
  22. }
  23. func NewEventCowTreatment(req *pasturePb.CowTreatmentRequest, systemUser *SystemUser) *EventCowTreatment {
  24. b, _ := json.Marshal(req.PrescriptionDetail)
  25. return &EventCowTreatment{
  26. CowId: int64(req.CowId),
  27. CowDiseaseId: int64(req.Id),
  28. PrescriptionId: req.PrescriptionId,
  29. PrescriptionDetail: string(b),
  30. TreatmentResult: req.TreatmentResult,
  31. OperationId: systemUser.Id,
  32. OperationName: systemUser.Name,
  33. Remarks: req.Remarks,
  34. }
  35. }