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,8 +43,32 @@
   //)
   //beego.AddNamespace(ns)
   //beego.Router("/basic/api/car/app/user", &controllers.UserController{})
   beego.Router("/basic/api/car/statistic", &controllers.CarController{}, "*:Statistic")
   beego.Router("/basic/api/car/spaceNo", &controllers.CarController{}, "*:SpaceNo")
   beego.Router("/basic/api/car/app/version", &controllers.AppController{}, "*:Version")
   beego.Router("/basic/api/car/restriction", &controllers.RestrictionController{}, "*:Restriction")
   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")
   beego.Router(preApi+"/car/app/version", &controllers.AppController{}, "*:Version")
   beego.Router(preApi+"/car/restriction", &controllers.RestrictionController{}, "*:Restriction")
   beego.Router(preApi+"/code/new", &controllers.CodeController{}, "*:New")
   beego.Router(preApi+"/user/login", &controllers.UserController{}, "*:Login")
   beego.Router(preApi+"/user/logout", &controllers.UserController{}, "*:Logout")
   beego.Router(preApi+"/user/addPlateNo", &controllers.UserController{}, "*:AddPlateNo")
   beego.Router(preApi+"/user/myPlateNos", &controllers.UserController{}, "*:MyPlateNos")
   beego.Router(preApi+"/user/delPlateNo", &controllers.UserController{}, "*:DelPlateNo")
   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)
}