mirror of
https://github.com/beego/bee.git
synced 2024-11-26 01:11:30 +00:00
update the status cide
This commit is contained in:
parent
f11cad19ec
commit
e2ee2a8a79
@ -1167,14 +1167,15 @@ func (c *{{ctrlName}}Controller) URLMapping() {
|
|||||||
// @Title Post
|
// @Title Post
|
||||||
// @Description create {{ctrlName}}
|
// @Description create {{ctrlName}}
|
||||||
// @Param body body models.{{ctrlName}} true "body for {{ctrlName}} content"
|
// @Param body body models.{{ctrlName}} true "body for {{ctrlName}} content"
|
||||||
// @Success 200 {int} models.{{ctrlName}}.Id
|
// @Success 201 {int} models.{{ctrlName}}
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (c *{{ctrlName}}Controller) Post() {
|
func (c *{{ctrlName}}Controller) Post() {
|
||||||
var v models.{{ctrlName}}
|
var v models.{{ctrlName}}
|
||||||
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
||||||
if id, err := models.Add{{ctrlName}}(&v); err == nil {
|
if _, err := models.Add{{ctrlName}}(&v); err == nil {
|
||||||
c.Data["json"] = map[string]int64{"id": id}
|
c.Ctx.Output.SetStatus(201)
|
||||||
|
c.Data["json"] = v
|
||||||
} else {
|
} else {
|
||||||
c.Data["json"] = err.Error()
|
c.Data["json"] = err.Error()
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func (c *{{controllerName}}Controller) URLMapping() {
|
|||||||
// @Title Post
|
// @Title Post
|
||||||
// @Description create {{controllerName}}
|
// @Description create {{controllerName}}
|
||||||
// @Param body body models.{{controllerName}} true "body for {{controllerName}} content"
|
// @Param body body models.{{controllerName}} true "body for {{controllerName}} content"
|
||||||
// @Success 200 {int} models.{{controllerName}}.Id
|
// @Success 201 {object} models.{{controllerName}}
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (c *{{controllerName}}Controller) Post() {
|
func (c *{{controllerName}}Controller) Post() {
|
||||||
@ -170,14 +170,15 @@ func (c *{{controllerName}}Controller) URLMapping() {
|
|||||||
// @Title Post
|
// @Title Post
|
||||||
// @Description create {{controllerName}}
|
// @Description create {{controllerName}}
|
||||||
// @Param body body models.{{controllerName}} true "body for {{controllerName}} content"
|
// @Param body body models.{{controllerName}} true "body for {{controllerName}} content"
|
||||||
// @Success 200 {int} models.{{controllerName}}.Id
|
// @Success 201 {int} models.{{controllerName}}
|
||||||
// @Failure 403 body is empty
|
// @Failure 403 body is empty
|
||||||
// @router / [post]
|
// @router / [post]
|
||||||
func (c *{{controllerName}}Controller) Post() {
|
func (c *{{controllerName}}Controller) Post() {
|
||||||
var v models.{{controllerName}}
|
var v models.{{controllerName}}
|
||||||
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
||||||
if id, err := models.Add{{controllerName}}(&v); err == nil {
|
if _, err := models.Add{{controllerName}}(&v); err == nil {
|
||||||
c.Data["json"] = map[string]int64{"id": id}
|
c.Ctx.Output.SetStatus(201)
|
||||||
|
c.Data["json"] = v
|
||||||
} else {
|
} else {
|
||||||
c.Data["json"] = err.Error()
|
c.Data["json"] = err.Error()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user