| | |
| | | pushMasterSecret = vFiErCTBqqAcufPzB0Tl45 |
| | | pushPackageName = uni.UNIEDF0B5C |
| | | pushBaseUrl = https://restapi.getui.com/v2/ |
| | | dbUrl = ./conf/app.db |
| | | dbUrl = conf/app.db |
| | | hikUrl = https://111.205.161.131:1443 |
| | |
| | | "encoding/hex" |
| | | "fmt" |
| | | "math/rand" |
| | | "os" |
| | | "os/exec" |
| | | "path/filepath" |
| | | "strconv" |
| | | "strings" |
| | | "time" |
| | |
| | | return max |
| | | } |
| | | return rand.Intn(max-min) + min |
| | | } |
| | | |
| | | |
| | | 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) |
| | | } |
| | |
| | | package models |
| | | |
| | | import ( |
| | | "car-service/extend/util" |
| | | "github.com/astaxie/beego" |
| | | "github.com/astaxie/beego/orm" |
| | | _ "github.com/mattn/go-sqlite3" |
| | |
| | | |
| | | func InitDb() { |
| | | dbUrl := beego.AppConfig.String("dbUrl") |
| | | |
| | | rootPath := util.GetAppRootPath() |
| | | dbPath := rootPath + dbUrl |
| | | orm.RegisterDriver("sqlite", orm.DRSqlite) |
| | | _ = orm.RegisterDataBase("default", "sqlite3", dbUrl) |
| | | _ = orm.RegisterDataBase("default", "sqlite3", dbPath) |
| | | orm.RegisterModel(new(User), new(UserCar), new(SysUpgrade)) |
| | | _ = orm.RunSyncdb("default", false, true) |
| | | } |
| | |
| | | |
| | | import ( |
| | | "car-service/controllers" |
| | | "car-service/extend/util" |
| | | "fmt" |
| | | "github.com/astaxie/beego/plugins/cors" |
| | | "os" |
| | | "os/exec" |
| | | "path/filepath" |
| | | |
| | | "github.com/astaxie/beego" |
| | | "github.com/astaxie/beego/plugins/cors" |
| | | ) |
| | | |
| | | func init() { |
| | |
| | | //) |
| | | //beego.AddNamespace(ns) |
| | | //beego.Router("/basic/api/car/app/user", &controllers.UserController{}) |
| | | rootPath := getAppRootPath() |
| | | rootPath := util.GetAppRootPath() |
| | | fmt.Println("rootPath:", rootPath) |
| | | beego.SetStaticPath("/download", rootPath+"/download") |
| | | preApi := "/basic/api" |
| | |
| | | |
| | | 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) |
| | | } |