caipin 3 年之前
父节点
当前提交
70225d5f13
共有 6 个文件被更改,包括 26 次插入30 次删除
  1. 6 7
      datasource/dbhelper.go
  2. 4 8
      lib/jlzf.go
  3. 1 7
      services/jl_service.go
  4. 5 0
      web/config-uat.yaml
  5. 4 8
      web/external/jl_ex.go
  6. 6 0
      web/utils/utils.go

+ 6 - 7
datasource/dbhelper.go

@@ -15,6 +15,7 @@ import (
 	"github.com/go-xorm/xorm"
 	"github.com/spf13/viper"
 	"go.mod/conf"
+	"go.mod/web/utils"
 )
 
 //互斥锁
@@ -34,20 +35,18 @@ func InstanceDbMaster() *xorm.Engine {
 	return NewDbMaster()
 }
 
-func GetEnvInfo(env string) bool {
-	viper.AutomaticEnv()
-	return viper.GetBool(env)
-}
-
 func NewDbMaster() *xorm.Engine {
 
-	debug := GetEnvInfo("DEBUG")
+	debug := utils.GetEnvInfo("DEBUG")
 	configFilePrefix := "config"
 	configFileName := fmt.Sprintf("%s-pro.yaml", configFilePrefix)
 
-	if debug {
+	if debug == "qa" {
 		fmt.Println("读取QA配置文件成功")
 		configFileName = fmt.Sprintf("%s-debug.yaml", configFilePrefix)
+	} else if debug == "uat" {
+		fmt.Println("读取UAT配置文件成功")
+		configFileName = fmt.Sprintf("%s-uat.yaml", configFilePrefix)
 	} else {
 		fmt.Println("读取PROD配置文件成功")
 	}

+ 4 - 8
lib/jlzf.go

@@ -14,7 +14,6 @@ import (
 	"time"
 
 	"github.com/dgrijalva/jwt-go"
-	"github.com/spf13/viper"
 	"go.mod/conf"
 	"go.mod/web/utils"
 	"go.mod/web/viewmodels"
@@ -46,10 +45,12 @@ type jlAccountResult struct {
 //创建项目用户service
 func NewJlzf() *Jlzf {
 	// 自动识别开发环境和生产环境
-	debug := getEnvInfo("DEBUG")
+	debug := utils.GetEnvInfo("DEBUG")
 	AuthUrl := "https://jl.smartcost.com.cn"
-	if debug {
+	if debug == "qa" {
 		AuthUrl = "http://192.168.1.76:7002"
+	} else if debug == "uat" {
+		AuthUrl = "https://jluat.smartcost.com.cn"
 	}
 	return &Jlzf{
 		AuthUrl: AuthUrl,
@@ -179,8 +180,3 @@ func (j *Jlzf) LoginValid(loginData viewmodels.Login) error {
 	}
 	return nil
 }
-
-func getEnvInfo(env string) bool {
-	viper.AutomaticEnv()
-	return viper.GetBool(env)
-}

+ 1 - 7
services/jl_service.go

@@ -16,7 +16,6 @@ import (
 	"time"
 
 	"github.com/dgrijalva/jwt-go"
-	"github.com/spf13/viper"
 	"go.mod/comm"
 	"go.mod/conf"
 	"go.mod/dao"
@@ -305,7 +304,7 @@ func (s *JlService) ProjectExist(projectId int, accountId int) (map[string]inter
 		return nil, errors.New("计量 校验失败-未找到项目或账号")
 	}
 
-	debug := GetEnvInfo("DEBUG")
+	debug := utils.GetEnvInfo("DEBUG")
 	expirationTime := time.Now().Add(6 * time.Second)
 	tokenString, _ := utils.CreateJlToken(jwt.MapClaims{
 		"data": map[string]string{"code": projectData.Code, "account": accountData.Account},
@@ -315,11 +314,6 @@ func (s *JlService) ProjectExist(projectId int, accountId int) (map[string]inter
 	return map[string]interface{}{"env": debug, "token": tokenString}, nil
 }
 
-func GetEnvInfo(env string) bool {
-	viper.AutomaticEnv()
-	return viper.GetBool(env)
-}
-
 // 项目存在
 func (s *JlService) AccountUpdate(claimsData *viewmodels.Jl) error {
 

+ 5 - 0
web/config-uat.yaml

@@ -0,0 +1,5 @@
+host: "39.108.111.147"
+port: 3306
+user: "zongheng"
+pwd: "@)!(smartcost#*%)"
+datebase: "construction_uat"

+ 4 - 8
web/external/jl_ex.go

@@ -10,7 +10,6 @@ import (
 	"fmt"
 
 	"github.com/kataras/iris/v12"
-	"github.com/spf13/viper"
 	"go.mod/dao"
 	"go.mod/datasource"
 	"go.mod/lib"
@@ -112,10 +111,12 @@ func (c *JlEx) PostProjectAdd() {
 // 授权登陆
 func (c *JlEx) PostAuthLogin() {
 
-	debug := getEnvInfo("DEBUG")
+	debug := utils.GetEnvInfo("DEBUG")
 	AuthUrl := "https://jl.smartcost.com.cn"
-	if debug {
+	if debug == "qa" {
 		AuthUrl = "http://jlqa.smartcost.com.cn:7002"
+	} else if debug == "uat" {
+		AuthUrl = "https://jluat.smartcost.com.cn"
 	}
 
 	// 1.获得数据
@@ -252,8 +253,3 @@ func (c *JlEx) PostSync() {
 	}
 
 }
-
-func getEnvInfo(env string) bool {
-	viper.AutomaticEnv()
-	return viper.GetBool(env)
-}

+ 6 - 0
web/utils/utils.go

@@ -19,6 +19,7 @@ import (
 
 	"github.com/dgrijalva/jwt-go"
 	"github.com/kataras/iris/v12"
+	"github.com/spf13/viper"
 	"go.mod/comm"
 	"go.mod/conf"
 )
@@ -208,6 +209,11 @@ func ValidateJwt(tokenStr string) (map[string]interface{}, error) {
 	return data, nil
 }
 
+func GetEnvInfo(env string) string {
+	viper.AutomaticEnv()
+	return viper.GetString(env)
+}
+
 type jlRequest struct {
 	Data map[string]interface{} `json:"data" `
 }