本文整理汇总了Golang中github.com/asvins/core/models.Treatment类的典型用法代码示例。如果您正苦于以下问题:Golang Treatment类的具体用法?Golang Treatment怎么用?Golang Treatment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Treatment类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: deleteTreatment
func deleteTreatment(w http.ResponseWriter, r *http.Request) errors.Http {
t := models.Treatment{}
if err := FillTreatmentIdWIthUrlValue(&t, r.URL.Query()); err != nil {
return errors.BadRequest(err.Error())
}
if err := t.Delete(db); err != nil {
return errors.InternalServerError(err.Error())
}
rend.JSON(w, http.StatusOK, t.ID)
return nil
}
开发者ID:asvins,项目名称:core,代码行数:13,代码来源:treatment_controller.go
示例2: insertTreatment
func insertTreatment(w http.ResponseWriter, r *http.Request) errors.Http {
t := models.Treatment{}
if err := BuildStructFromReqBody(&t, r.Body); err != nil {
return errors.BadRequest(err.Error())
}
if err := t.Save(db); err != nil {
return errors.InternalServerError(err.Error())
}
sendTreatmentCreated(&t)
rend.JSON(w, http.StatusOK, t)
return nil
}
开发者ID:asvins,项目名称:core,代码行数:15,代码来源:treatment_controller.go
示例3: sendTreatmentCreated
func sendTreatmentCreated(t *models.Treatment) {
topic, _ := common_io.BuildTopicFromCommonEvent(common_io.EVENT_CREATED, "treatment")
/*
* marshal
*/
patient := models.Patient{}
patient.ID = t.PatientId
ps, err := patient.Retrieve(db)
if err != nil {
fmt.Println("[ERROR] ", err.Error())
return
}
if len(ps) != 1 {
fmt.Println("[FATAL] More then one patient with the same ID...")
return
}
t.Email = ps[0].Email
b, err := json.Marshal(&t)
if err != nil {
fmt.Println("[ERROR] ", err.Error())
return
}
producer.Publish(topic, b)
}
开发者ID:asvins,项目名称:core,代码行数:30,代码来源:common_io.go
示例4: updateTreatment
func updateTreatment(w http.ResponseWriter, r *http.Request) errors.Http {
t := models.Treatment{}
if err := BuildStructFromReqBody(&t, r.Body); err != nil {
return errors.BadRequest(err.Error())
}
if err := FillTreatmentIdWIthUrlValue(&t, r.URL.Query()); err != nil {
return errors.BadRequest(err.Error())
}
if err := t.Update(db); err != nil {
return errors.InternalServerError(err.Error())
}
rend.JSON(w, http.StatusOK, t)
return nil
}
开发者ID:asvins,项目名称:core,代码行数:18,代码来源:treatment_controller.go
示例5: FillTreatmentIdWIthUrlValue
func FillTreatmentIdWIthUrlValue(t *models.Treatment, params url.Values) error {
id, err := strconv.Atoi(params.Get("id"))
if err != nil {
return err
}
t.ID = id
return nil
}
开发者ID:asvins,项目名称:core,代码行数:9,代码来源:treatment_controller.go
示例6: retreiveTreatments
func retreiveTreatments(w http.ResponseWriter, r *http.Request) errors.Http {
t := models.Treatment{}
if err := BuildStructFromQueryString(&t, r.URL.Query()); err != nil {
return errors.BadRequest(err.Error())
}
t.Base.Query = r.URL.Query()
treatments, err := t.Retrieve(db)
if err != nil {
return errors.BadRequest(err.Error())
}
if len(treatments) == 0 {
return errors.NotFound("record not found")
}
rend.JSON(w, http.StatusOK, treatments)
return nil
}
开发者ID:asvins,项目名称:core,代码行数:20,代码来源:treatment_controller.go
示例7: handleTreatmentApproved
func handleTreatmentApproved(msg []byte) {
t := models.Treatment{}
if err := json.Unmarshal(msg, &t); err != nil {
fmt.Println("[ERROR] ", err.Error())
return
}
ts, err := t.Retrieve(db)
if err != nil {
fmt.Println("[ERROR] ", err.Error())
return
}
if len(ts) != 1 {
fmt.Println("[ERROR] Not able to handle treatment approved msg... query for given id returned len != 1")
return
}
createFeedEvent(ts[0])
}
开发者ID:asvins,项目名称:core,代码行数:20,代码来源:common_io.go
注:本文中的github.com/asvins/core/models.Treatment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论