// @Title Update // @Description update the PmpDemandPlatformDesk // @Param id path string true "The id you want to update" // @Param body body models.PmpDemandPlatformDesk true "body for PmpDemandPlatformDesk content" // @Success 200 {object} models.PmpDemandPlatformDesk // @Failure 403 :id is not int // @router /:id [put] func (c *PmpDemandPlatformDeskController) Put() { idStr := c.Ctx.Input.Params[":id"] id, _ := strconv.Atoi(idStr) v := models.PmpDemandPlatformDesk{Id: id} json.Unmarshal(c.Ctx.Input.RequestBody, &v) if err := models.UpdatePmpDemandPlatformDeskById(&v); err == nil { c.Data["json"] = "OK" } else { c.Data["json"] = err.Error() } c.ServeJson() }
// save or upate demand func (c *PmpDemandPlatformDeskController) SaveOrUpdateDemand() { var v models.PmpDemandPlatformDesk c.ParseForm(&v) beego.Info("*********** pased form values:", v) if v.Id == 0 { if id, err := models.AddPmpDemandPlatformDesk(&v); err == nil { c.Data["json"] = map[string]int64{"id": id} } else { c.Data["json"] = err.Error() } } else { if err := models.UpdatePmpDemandPlatformDeskById(&v); err == nil { c.Data["json"] = "OK" } else { c.Data["json"] = err.Error() } } c.ServeJson() }