mirror of
https://github.com/beego/bee.git
synced 2024-11-25 20:10:55 +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() {
|
func main() {
|
||||||
if beego.RunMode == "dev" {
|
if beego.BConfig.RunMode == "dev" {
|
||||||
beego.DirectoryIndex = true
|
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||||
beego.StaticDir["/swagger"] = "swagger"
|
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||||
}
|
}
|
||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
@ -100,9 +100,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if beego.RunMode == "dev" {
|
if beego.BConfig.RunMode == "dev" {
|
||||||
beego.DirectoryIndex = true
|
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||||
beego.StaticDir["/swagger"] = "swagger"
|
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||||
}
|
}
|
||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ func (o *ObjectController) Post() {
|
|||||||
// @Failure 403 :objectId is empty
|
// @Failure 403 :objectId is empty
|
||||||
// @router /:objectId [get]
|
// @router /:objectId [get]
|
||||||
func (o *ObjectController) Get() {
|
func (o *ObjectController) Get() {
|
||||||
objectId := o.Ctx.Input.Params[":objectId"]
|
objectId := o.Ctx.Input.Param(":objectId")
|
||||||
if objectId != "" {
|
if objectId != "" {
|
||||||
ob, err := models.GetOne(objectId)
|
ob, err := models.GetOne(objectId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -350,7 +350,7 @@ func (o *ObjectController) GetAll() {
|
|||||||
// @Failure 403 :objectId is empty
|
// @Failure 403 :objectId is empty
|
||||||
// @router /:objectId [put]
|
// @router /:objectId [put]
|
||||||
func (o *ObjectController) Put() {
|
func (o *ObjectController) Put() {
|
||||||
objectId := o.Ctx.Input.Params[":objectId"]
|
objectId := o.Ctx.Input.Param(":objectId")
|
||||||
var ob models.Object
|
var ob models.Object
|
||||||
json.Unmarshal(o.Ctx.Input.RequestBody, &ob)
|
json.Unmarshal(o.Ctx.Input.RequestBody, &ob)
|
||||||
|
|
||||||
@ -370,7 +370,7 @@ func (o *ObjectController) Put() {
|
|||||||
// @Failure 403 objectId is empty
|
// @Failure 403 objectId is empty
|
||||||
// @router /:objectId [delete]
|
// @router /:objectId [delete]
|
||||||
func (o *ObjectController) Delete() {
|
func (o *ObjectController) Delete() {
|
||||||
objectId := o.Ctx.Input.Params[":objectId"]
|
objectId := o.Ctx.Input.Param(":objectId")
|
||||||
models.Delete(objectId)
|
models.Delete(objectId)
|
||||||
o.Data["json"] = "delete success!"
|
o.Data["json"] = "delete success!"
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
|
1
bee.go
1
bee.go
@ -85,6 +85,7 @@ var commands = []*Command{
|
|||||||
cmdGenerate,
|
cmdGenerate,
|
||||||
//cmdRundocs,
|
//cmdRundocs,
|
||||||
cmdMigrate,
|
cmdMigrate,
|
||||||
|
cmdFix,
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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
|
// @Failure 403 :id is empty
|
||||||
// @router /:id [get]
|
// @router /:id [get]
|
||||||
func (c *{{ctrlName}}Controller) GetOne() {
|
func (c *{{ctrlName}}Controller) GetOne() {
|
||||||
idStr := c.Ctx.Input.Params[":id"]
|
idStr := c.Ctx.Input.Param(":id")
|
||||||
id, _ := strconv.Atoi(idStr)
|
id, _ := strconv.Atoi(idStr)
|
||||||
v, err := models.Get{{ctrlName}}ById(id)
|
v, err := models.Get{{ctrlName}}ById(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1273,7 +1273,7 @@ func (c *{{ctrlName}}Controller) GetAll() {
|
|||||||
// @Failure 403 :id is not int
|
// @Failure 403 :id is not int
|
||||||
// @router /:id [put]
|
// @router /:id [put]
|
||||||
func (c *{{ctrlName}}Controller) Put() {
|
func (c *{{ctrlName}}Controller) Put() {
|
||||||
idStr := c.Ctx.Input.Params[":id"]
|
idStr := c.Ctx.Input.Param(":id")
|
||||||
id, _ := strconv.Atoi(idStr)
|
id, _ := strconv.Atoi(idStr)
|
||||||
v := models.{{ctrlName}}{Id: id}
|
v := models.{{ctrlName}}{Id: id}
|
||||||
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &v); err == nil {
|
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
|
// @Failure 403 id is empty
|
||||||
// @router /:id [delete]
|
// @router /:id [delete]
|
||||||
func (c *{{ctrlName}}Controller) Delete() {
|
func (c *{{ctrlName}}Controller) Delete() {
|
||||||
idStr := c.Ctx.Input.Params[":id"]
|
idStr := c.Ctx.Input.Param(":id")
|
||||||
id, _ := strconv.Atoi(idStr)
|
id, _ := strconv.Atoi(idStr)
|
||||||
if err := models.Delete{{ctrlName}}(id); err == nil {
|
if err := models.Delete{{ctrlName}}(id); err == nil {
|
||||||
c.Data["json"] = "OK"
|
c.Data["json"] = "OK"
|
||||||
|
@ -192,7 +192,7 @@ func (c *{{controllerName}}Controller) Post() {
|
|||||||
// @Failure 403 :id is empty
|
// @Failure 403 :id is empty
|
||||||
// @router /:id [get]
|
// @router /:id [get]
|
||||||
func (c *{{controllerName}}Controller) GetOne() {
|
func (c *{{controllerName}}Controller) GetOne() {
|
||||||
idStr := c.Ctx.Input.Params[":id"]
|
idStr := c.Ctx.Input.Param(":id")
|
||||||
id, _ := strconv.ParseInt(idStr, 0, 64)
|
id, _ := strconv.ParseInt(idStr, 0, 64)
|
||||||
v, err := models.Get{{controllerName}}ById(id)
|
v, err := models.Get{{controllerName}}ById(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -273,7 +273,7 @@ func (c *{{controllerName}}Controller) GetAll() {
|
|||||||
// @Failure 403 :id is not int
|
// @Failure 403 :id is not int
|
||||||
// @router /:id [put]
|
// @router /:id [put]
|
||||||
func (c *{{controllerName}}Controller) Put() {
|
func (c *{{controllerName}}Controller) Put() {
|
||||||
idStr := c.Ctx.Input.Params[":id"]
|
idStr := c.Ctx.Input.Param(":id")
|
||||||
id, _ := strconv.ParseInt(idStr, 0, 64)
|
id, _ := strconv.ParseInt(idStr, 0, 64)
|
||||||
v := models.{{controllerName}}{Id: id}
|
v := models.{{controllerName}}{Id: id}
|
||||||
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
json.Unmarshal(c.Ctx.Input.RequestBody, &v)
|
||||||
@ -292,7 +292,7 @@ func (c *{{controllerName}}Controller) Put() {
|
|||||||
// @Failure 403 id is empty
|
// @Failure 403 id is empty
|
||||||
// @router /:id [delete]
|
// @router /:id [delete]
|
||||||
func (c *{{controllerName}}Controller) Delete() {
|
func (c *{{controllerName}}Controller) Delete() {
|
||||||
idStr := c.Ctx.Input.Params[":id"]
|
idStr := c.Ctx.Input.Param(":id")
|
||||||
id, _ := strconv.ParseInt(idStr, 0, 64)
|
id, _ := strconv.ParseInt(idStr, 0, 64)
|
||||||
if err := models.Delete{{controllerName}}(id); err == nil {
|
if err := models.Delete{{controllerName}}(id); err == nil {
|
||||||
c.Data["json"] = "OK"
|
c.Data["json"] = "OK"
|
||||||
|
@ -55,7 +55,7 @@ var rootapi swagger.ResourceListing
|
|||||||
var apilist map[string]*swagger.APIDeclaration
|
var apilist map[string]*swagger.APIDeclaration
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if beego.EnableDocs {
|
if beego.Bconfig.WebConifg.EnableDocs {
|
||||||
err := json.Unmarshal([]byte(Rootinfo), &rootapi)
|
err := json.Unmarshal([]byte(Rootinfo), &rootapi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
beego.Error(err)
|
beego.Error(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user