Пример #1
0
// @Title Post
// @Description create PmpDemandPlatformDesk
// @Param	body		body 	models.PmpDemandPlatformDesk	true		"body for PmpDemandPlatformDesk content"
// @Success 200 {int} models.PmpDemandPlatformDesk.Id
// @Failure 403 body is empty
// @router / [post]
func (c *PmpDemandPlatformDeskController) Post() {
	var v models.PmpDemandPlatformDesk
	//	json.Unmarshal(c.Ctx.Input.RequestBody, &v)
	c.ParseForm(&v)
	if id, err := models.AddPmpDemandPlatformDesk(&v); err == nil {
		c.Data["json"] = map[string]int64{"id": id}
	} else {
		c.Data["json"] = err.Error()
	}
	c.ServeJson()
}
Пример #2
0
// 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()
}