diff --git a/.gitignore b/.gitignore index 48b8bf9..52cbdc5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ vendor/ +rbac diff --git a/config/config.go b/config/config.go index d35e8a8..6ae596d 100644 --- a/config/config.go +++ b/config/config.go @@ -23,6 +23,7 @@ type Config struct { RedisHost string RedisPort int RedisPassword string + RedisDB int } var AppConfig Config @@ -30,16 +31,17 @@ var AppConfig Config func Init() { AppConfig = Config{ DB: DBConfig{ - Host: getEnv("DB_HOST", "localhost"), + Host: getEnv("DB_HOST", "192.168.65.5"), Port: getEnvAsInt("DB_PORT", 3306), User: getEnv("DB_USER", "root"), - Password: getEnv("DB_PASSWORD", ""), + Password: getEnv("DB_PASSWORD", "d8db*#00oS"), Name: getEnv("DB_NAME", "rbac"), }, JWTSecret: getEnv("JWT_SECRET", "secret"), - RedisHost: getEnv("REDIS_HOST", "localhost"), + RedisHost: getEnv("REDIS_HOST", "192.168.65.5"), RedisPort: getEnvAsInt("REDIS_PORT", 6379), RedisPassword: getEnv("REDIS_PASSWORD", ""), + RedisDB: getEnvAsInt("REDIS_DB", 2), } } diff --git a/main.go b/main.go index 504821b..9b90c5c 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,3 @@ -<<<<<<< HEAD package main import ( @@ -14,39 +13,3 @@ func main() { api.SetupRoutes(r) r.Run(":8080") } -======= -package main - -import ( - "gitea.zjmud.xyz/phyer/rbac/api" - "gitea.zjmud.xyz/phyer/rbac/config" - "gitea.zjmud.xyz/phyer/rbac/server" -) - -func main() { - config.Init() - server.InitDB() - r := server.NewServer() - api.SetupRoutes(r) - r.Run(":8080") -} ->>>>>>> Snippet - -// package main -// -// import ( -// "gitea.zjmud.xyz/phyer/rbac/config" -// "gitea.zjmud.xyz/phyer/rbac/server" -// "gitea.zjmud.xyz/phyer/rbac/utils" -// ) -// -// func main() { -// // 初始化配置 -// config.Init() -// -// // 初始化 Redis -// utils.InitRedis() -// -// // 启动服务器 -// server.Start() -// } diff --git a/rbac b/rbac deleted file mode 100755 index 4ea6190..0000000 Binary files a/rbac and /dev/null differ diff --git a/utils/redis.go b/utils/redis.go index 39ec6fb..61aaa6d 100644 --- a/utils/redis.go +++ b/utils/redis.go @@ -18,7 +18,7 @@ func InitRedis() error { RedisClient = redis.NewClient(&redis.Options{ Addr: fmt.Sprintf("%s:%d", config.AppConfig.RedisHost, config.AppConfig.RedisPort), Password: config.AppConfig.RedisPassword, - DB: 0, // 使用默认数据库 + DB: config.AppConfig.RedisDB, // 使用默认数据库 }) // 测试连接