package model import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" type PrescriptionDrugs struct { Id int64 `json:"id"` PrescriptionId int64 `json:"prescription_id"` DrugsId int64 `json:"drugs_id"` UseDays int32 `json:"use_days"` Dosages int32 `json:"dosages"` Unit pasturePb.Unit_Kind `json:"unit"` UnitName string `json:"unit_name"` IsShow pasturePb.IsShow_Kind `json:"is_show"` CreatedAt int64 `json:"created_at"` UpdatedAt int64 `json:"updated_at"` } func (p *PrescriptionDrugs) TableName() string { return "prescription_drugs" } func NewPrescriptionDrugs(prescriptionId int64, req *pasturePb.PrescriptionRequest) []*PrescriptionDrugs { res := make([]*PrescriptionDrugs, len(req.PrescriptionDrugsItem)) for i, v := range req.PrescriptionDrugsItem { res[i] = &PrescriptionDrugs{ PrescriptionId: prescriptionId, DrugsId: int64(v.DrugsId), UseDays: v.UseDays, Dosages: v.Dosages, Unit: v.Unit, UnitName: v.UnitName, IsShow: pasturePb.IsShow_Ok, } } return res }