From 87cad05224d857ec0e113ae03b006d2a52ec3049 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 16 八月 2023 11:55:26 +0800
Subject: [PATCH] Merge branch 'zq'

---
 conf/config.go |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/conf/config.go b/conf/config.go
index a998029..d6541dd 100644
--- a/conf/config.go
+++ b/conf/config.go
@@ -8,6 +8,7 @@
 	"flag"
 	"github.com/spf13/viper"
 	"log"
+	"os"
 )
 
 var (
@@ -38,6 +39,13 @@
 		Issuer      string // 绛惧彂鑰�
 	}
 
+	JWT2 struct {
+		SigningKey  string // jwt绛惧悕
+		ExpiresTime string // 杩囨湡鏃堕棿
+		BufferTime  string // 缂撳啿鏃堕棿
+		Issuer      string // 绛惧彂鑰�
+	}
+
 	System struct {
 		Env           string // 鐜鍊� develop test public
 		Port          int    // 绔彛
@@ -48,6 +56,10 @@
 		LimitTimeIP   int
 		RouterPrefix  string // 璺敱鍓嶇紑
 		SudoPassword  string // sudo瀵嗙爜
+	}
+
+	GrpcServiceAddr struct {
+		Aps string // jwt绛惧悕
 	}
 
 	config struct {
@@ -68,6 +80,8 @@
 
 		// JWT閰嶇疆
 		JWT JWT
+
+		GrpcServiceAddr GrpcServiceAddr
 	}
 )
 
@@ -98,6 +112,20 @@
 	if err := Viper.Unmarshal(&Conf); err != nil {
 		log.Fatalf("Unmarshal err:%v", err)
 	}
+
+	DBHost := os.Getenv("DB_HOST")
+	DBName := os.Getenv("DB_NAME")
+	DBPort := os.Getenv("DB_PORT")
+	DBUser := os.Getenv("DB_USER")
+	DBPasswd := os.Getenv("DB_PASSWD")
+	if len(DBHost) > 0 &&
+		len(DBName) > 0 &&
+		len(DBPort) > 0 &&
+		len(DBUser) > 0 &&
+		len(DBPasswd) > 0 {
+		Conf.Mysql.Dsn = DBUser + ":" + DBPasswd + "@tcp(" + DBHost + ":" + DBPort + ")/" + DBName + "?charset=utf8&parseTime=True&loc=Local"
+	}
+
 	ShowConfig()
 }
 
@@ -117,5 +145,6 @@
 	log.Printf("   Mysql:                 %+v", Conf.Mysql)
 	log.Printf("   Captcha:               %+v", Conf.Captcha)
 	log.Printf("   JWT:                   %+v", Conf.JWT)
+	log.Printf("   GrpcServiceAddr:       %+v", Conf.GrpcServiceAddr)
 	log.Println("......................................................")
 }

--
Gitblit v1.8.0