From f08eb62fe19cff6fc72dbfc72dae0519bce82ed7 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期四, 30 七月 2020 10:40:04 +0800
Subject: [PATCH] test static rootPath

---
 routers/router.go |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/routers/router.go b/routers/router.go
index b25ea35..0a88743 100644
--- a/routers/router.go
+++ b/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,6 +43,9 @@
 	//)
 	//beego.AddNamespace(ns)
 	//beego.Router("/basic/api/car/app/user", &controllers.UserController{})
+	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")
@@ -49,4 +56,19 @@
 	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)
+}
\ No newline at end of file

--
Gitblit v1.8.0