|
@@ -15,6 +15,7 @@ import (
|
|
|
"time"
|
|
|
|
|
|
"github.com/dgrijalva/jwt-go"
|
|
|
+ "github.com/spf13/viper"
|
|
|
"go.mod/comm"
|
|
|
"go.mod/conf"
|
|
|
"go.mod/dao"
|
|
@@ -275,7 +276,7 @@ func (s *JlService) AuthLogin(claimsData *viewmodels.Jl, writer http.ResponseWri
|
|
|
|
|
|
// 项目存在
|
|
|
func (s *JlService) ProjectExist(projectId int, accountId int) (map[string]interface{}, error) {
|
|
|
- exist := 0
|
|
|
+
|
|
|
projectData := s.dao.Get(projectId)
|
|
|
if projectData.Id == 0 {
|
|
|
return nil, errors.New("项目未找到")
|
|
@@ -297,13 +298,20 @@ func (s *JlService) ProjectExist(projectId int, accountId int) (map[string]inter
|
|
|
if _, _, err := Jlzf.GetProjectAndAccount(projectData.Code, accountData.Account); err != nil {
|
|
|
return nil, errors.New("计量 校验失败-未找到项目或账号")
|
|
|
}
|
|
|
- exist = 1
|
|
|
+
|
|
|
+ debug := GetEnvInfo("DEBUG")
|
|
|
+
|
|
|
tokenString, _ := utils.CreateJlToken(jwt.MapClaims{
|
|
|
"code": projectData.Code,
|
|
|
"account": accountData.Account,
|
|
|
"exp": time.Now().Add(24 * time.Hour).Unix(),
|
|
|
})
|
|
|
- return map[string]interface{}{"exist": exist, "token": tokenString}, nil
|
|
|
+ return map[string]interface{}{"env": debug, "token": tokenString}, nil
|
|
|
+}
|
|
|
+
|
|
|
+func GetEnvInfo(env string) bool {
|
|
|
+ viper.AutomaticEnv()
|
|
|
+ return viper.GetBool(env)
|
|
|
}
|
|
|
|
|
|
// 项目存在
|