liuxiaolong
2020-07-30 f08eb62fe19cff6fc72dbfc72dae0519bce82ed7
routers/router.go
@@ -9,7 +9,11 @@
import (
   "car-service/controllers"
   "fmt"
   "github.com/astaxie/beego/plugins/cors"
   "os"
   "os/exec"
   "path/filepath"
   "github.com/astaxie/beego"
)
@@ -39,7 +43,9 @@
   //)
   //beego.AddNamespace(ns)
   //beego.Router("/basic/api/car/app/user", &controllers.UserController{})
   beego.SetStaticPath("/download", "download")
   rootPath := getAppRootPath()
   fmt.Println("rootPath:", rootPath)
   beego.SetStaticPath("/download", rootPath+"/download")
   preApi := "/basic/api"
   beego.Router(preApi+"/car/statistic", &controllers.CarController{}, "*:Statistic")
   beego.Router(preApi+"/car/spaceNo", &controllers.CarController{}, "*:SpaceNo")
@@ -54,3 +60,15 @@
   beego.Router(preApi+"/user/all", &controllers.UserController{}, "*:GetUserAll")
}
func getAppRootPath() string {
   file,err:= exec.LookPath(os.Args[0])
   if err != nil {
      return ""
   }
   p, err := filepath.Abs(file)
   if err != nil {
      return ""
   }
   return filepath.Dir(p)
}