mirror of
https://github.com/beego/bee.git
synced 2024-12-22 10:00:50 +00:00
fix issue with new version
This commit is contained in:
parent
20d77d9979
commit
807c3de8a7
18
apiapp.go
18
apiapp.go
@ -76,9 +76,9 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
if beego.RunMode == "dev" {
|
||||
beego.DirectoryIndex = true
|
||||
beego.StaticDir["/swagger"] = "swagger"
|
||||
if beego.BConfig.RunMode == "dev" {
|
||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||
}
|
||||
beego.Run()
|
||||
}
|
||||
@ -100,9 +100,9 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
if beego.RunMode == "dev" {
|
||||
beego.DirectoryIndex = true
|
||||
beego.StaticDir["/swagger"] = "swagger"
|
||||
if beego.BConfig.RunMode == "dev" {
|
||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||
}
|
||||
beego.Run()
|
||||
}
|
||||
@ -319,7 +319,7 @@ func (o *ObjectController) Post() {
|
||||
// @Failure 403 :objectId is empty
|
||||
// @router /:objectId [get]
|
||||
func (o *ObjectController) Get() {
|
||||
objectId := o.Ctx.Input.Params[":objectId"]
|
||||
objectId := o.Ctx.Input.Param(":objectId")
|
||||
if objectId != "" {
|
||||
ob, err := models.GetOne(objectId)
|
||||
if err != nil {
|
||||
@ -350,7 +350,7 @@ func (o *ObjectController) GetAll() {
|
||||
// @Failure 403 :objectId is empty
|
||||
// @router /:objectId [put]
|
||||
func (o *ObjectController) Put() {
|
||||
objectId := o.Ctx.Input.Params[":objectId"]
|
||||
objectId := o.Ctx.Input.Param(":objectId")
|
||||
var ob models.Object
|
||||
json.Unmarshal(o.Ctx.Input.RequestBody, &ob)
|
||||
|
||||
@ -370,7 +370,7 @@ func (o *ObjectController) Put() {
|
||||
// @Failure 403 objectId is empty
|
||||
// @router /:objectId [delete]
|
||||
func (o *ObjectController) Delete() {
|
||||
objectId := o.Ctx.Input.Params[":objectId"]
|
||||
objectId := o.Ctx.Input.Param(":objectId")
|
||||
models.Delete(objectId)
|
||||
o.Data["json"] = "delete success!"
|
||||
o.ServeJSON()
|
||||
|
1
bee.go
1
bee.go
@ -85,6 +85,7 @@ var commands = []*Command{
|
||||
cmdGenerate,
|
||||
//cmdRundocs,
|
||||
cmdMigrate,
|
||||
cmdFix,
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
19
fix.go
Normal file
19
fix.go
Normal file
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
var cmdFix = &Command{
|
||||
UsageLine: "fix",
|
||||
Short: "fix the beego application to compatibel with beego 1.6",
|
||||
Long: `
|
||||
As from beego1.6, there's some incompatible code with the old version.
|
||||
|
||||
bee fix help to upgrade the application to beego 1.6
|
||||
`,
|
||||
}
|
||||
|
||||
func init() {
|
||||
cmdFix.Run = runFix
|
||||
}
|
||||
|
||||
func runFix(cmd *Command, args []string) int {
|
||||
return 0
|
||||
}
|
@ -1192,7 +1192,7 @@ func (c *{{ctrlName}}Controller) Post() {
|
||||
// @Failure 403 :id is empty
|
||||
// @router /:id [get]
|
||||
func (c *{{ctrlName}}Controller) GetOne() {
|
||||
idStr := c.Ctx.Input.Params[":id"]
|
||||
idStr := c.Ctx.Input.Param(":id")
|
||||
id, _ := strconv.Atoi(idStr)
|
||||
v, err := models.Get{{ctrlName}}ById(id)
|
||||
if err != nil {
|
||||
@ -1273,7 +1273,7 @@ func (c *{{ctrlName}}Controller) GetAll() {
|
||||
// @Failure 403 :id is not int
|
||||
// @router /:id [put]
|
||||
func (c *{{ctrlName}}Controller) Put() {
|
||||
idStr := c.Ctx.Input.Params[":id"]
|
||||
idStr := c.Ctx.Input.Param(":id")
|
||||
id, _ := strconv.Atoi(idStr)
|
||||
v := models.{{ctrlName}}{Id: id}
|
||||
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &v); err == nil {
|
||||
@ -1295,7 +1295,7 @@ func (c *{{ctrlName}}Controller) Put() {
|
||||
// @Failure 403 id is empty
|
||||
// @router /:id [delete]
|
||||
func (c *{{ctrlName}}Controller) Delete() {
|
||||
idStr := c.Ctx.Input.Params[":id"]
|
||||
idStr := c.Ctx.Input.Param(":id")
|
||||
id, _ := strconv.Atoi(idStr)
|
||||
if err := models.Delete{{ctrlName}}(id); err == nil {
|
||||
c.Data["json"] = "OK"
|
||||
|
@ -192,7 +192,7 @@ func (c *{{controllerName}}Controller) Post() {
|
||||
// @Failure 403 :id is empty
|
||||
// @router /:id [get]
|
||||
func (c *{{controllerName}}Controller) GetOne() {
|
||||
idStr := c.Ctx.Input.Params[":id"]
|
||||
idStr := c.Ctx.Input.Param(":id")
|
||||
id, _ := strconv.ParseInt(idStr, 0, 64)
|
||||
v, err := models.Get{{controllerName}}ById(id)
|
||||
if err != nil {
|
||||
@ -273,7 +273,7 @@ func (c *{{controllerName}}Controller) GetAll() {
|
||||
// @Failure 403 :id is not int
|
||||
// @router /:id [put]
|
||||
func (c *{{controllerName}}Controller) Put() {
|
||||
idStr := c.Ctx.Input.Params[":id"]
|
||||
idStr := c.Ctx.Input.Param(":id")
|
||||
id, _ := strconv.ParseInt(idStr, 0, 64)
|
||||
v := models.{{controllerName}}{Id: id}
|
||||
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
||||
@ -292,7 +292,7 @@ func (c *{{controllerName}}Controller) Put() {
|
||||
// @Failure 403 id is empty
|
||||
// @router /:id [delete]
|
||||
func (c *{{controllerName}}Controller) Delete() {
|
||||
idStr := c.Ctx.Input.Params[":id"]
|
||||
idStr := c.Ctx.Input.Param(":id")
|
||||
id, _ := strconv.ParseInt(idStr, 0, 64)
|
||||
if err := models.Delete{{controllerName}}(id); err == nil {
|
||||
c.Data["json"] = "OK"
|
||||
|
Loading…
Reference in New Issue
Block a user