Roc 2 жил өмнө
parent
commit
4e7e64ed32

+ 10 - 26
services/quanshi/quanshi.go

@@ -13,22 +13,6 @@ import (
 	"time"
 )
 
-const (
-	QsAppID     = "ed1cc7c87c97089263fc899fbab193b0"
-	QsSecretKey = "d92b91265dbbc5e3af44edfb82503635"
-
-	//UserId   = 9821234
-	//UserName = "hzhu@hzinsights.com"
-
-	UserId   = 19896481
-	UserName = "pyan@hzinsights.com"
-	//UserId   = 20804877
-	//UserName = "ljjiang@hzinsights.com"
-
-	//有效期24小时
-	Token = "8563737a3c6be564b91be8cab8881058"
-)
-
 // QsResp 全时数据返回结构体
 type QsResp struct {
 	Code      int64       `json:"code"`
@@ -58,8 +42,8 @@ func getToken() (dataResp TokenResp, err error) {
 		}
 	}()
 	user := new(QsUser)
-	user.UserId = UserId
-	user.UserName = UserName
+	user.UserId = utils.QsUserId
+	user.UserName = utils.QsUserName
 
 	postData, err := json.Marshal(user)
 	if err != nil {
@@ -92,7 +76,7 @@ func postCurl(urlStr string, postDataStr string, num int, isNeedToken bool) (res
 	nonce := utils.GetRandStringNoSpecialChar(32)
 	curTime := time.Now().Local().UnixNano() / 1e6
 	curTimeStr := strconv.FormatInt(curTime, 10)
-	checkSumStr := QsSecretKey + nonce + curTimeStr
+	checkSumStr := utils.QsSecretKey + nonce + curTimeStr
 	checkSum := utils.Sha1(checkSumStr)
 
 	if isNeedToken {
@@ -102,7 +86,7 @@ func postCurl(urlStr string, postDataStr string, num int, isNeedToken bool) (res
 		}
 		req.Header.Set("token", token)
 	}
-	req.Header.Set("AppKey", QsAppID)
+	req.Header.Set("AppKey", utils.QsAppID)
 	req.Header.Set("Content-Type", "application/json")
 	req.Header.Set("accept", "application/json")
 	req.Header.Set("Nonce", nonce)
@@ -173,7 +157,7 @@ func refreshAccessToken() (token string, err error) {
 }
 
 type QsUser struct {
-	UserId   int    `json:"userId"`
+	UserId   int64  `json:"userId"`
 	UserName string `json:"userName"`
 }
 
@@ -329,7 +313,7 @@ func QsEventCreate(title string, meetingTime, eventForm int, startTime time.Time
 	isManualService := 2 //是否需要项目经理提醒(默认不需要)
 	joinLimit := 0
 	params := EventCreateParams{
-		HostId:        UserId,
+		HostId:        utils.QsUserId,
 		Title:         title,
 		StartTime:     startTime.Unix(),
 		Length:        meetingTime,
@@ -537,10 +521,10 @@ func GetQsUserInfoByPhone() {
 	nonce := utils.GetRandStringNoSpecialChar(32)
 	curTime := time.Now().Local().UnixNano() / 1e6
 	curTimeStr := strconv.FormatInt(curTime, 10)
-	checkSumStr := QsSecretKey + nonce + curTimeStr
+	checkSumStr := utils.QsSecretKey + nonce + curTimeStr
 	checkSum := utils.Sha1(checkSumStr)
 
-	req.Header.Set("AppKey", QsAppID)
+	req.Header.Set("AppKey", utils.QsAppID)
 	req.Header.Set("Content-Type", "application/json")
 	req.Header.Set("accept", "application/json")
 	req.Header.Set("Nonce", nonce)
@@ -783,10 +767,10 @@ func GetSign(signStr string) string {
 //	nonce := utils.GetRandStringNoSpecialChar(32)
 //	curTime := time.Now().Local().UnixNano()/1e6
 //	curTimeStr := strconv.FormatInt(curTime, 10)
-//	checkSumStr := QsSecretKey + nonce + curTimeStr
+//	checkSumStr := utils.QsSecretKey + nonce + curTimeStr
 //	fmt.Println("nonce:" + nonce)
 //	fmt.Println("curTimeStr:" + curTimeStr)
-//	fmt.Println("QsSecretKey:" + QsSecretKey)
+//	fmt.Println("utils.QsSecretKey:" + utils.QsSecretKey)
 //	checkSum := utils.Sha1(checkSumStr)
 //	fmt.Println(checkSum)
 //	fmt.Println("end")

+ 24 - 0
utils/config.go

@@ -33,6 +33,14 @@ var (
 	ReportSecret      string
 )
 
+//全时会议账号信息
+var (
+	QsAppID     string
+	QsSecretKey string
+	QsUserId    int64
+	QsUserName  string
+)
+
 func init() {
 	tmpRunMode, err := web.AppConfig.String("run_mode")
 	if err != nil {
@@ -92,6 +100,9 @@ func init() {
 
 	//初始化系统用户角色map集合
 	initRoleType()
+
+	//初始化全时开放api配置
+	initQsOpenApiConfig()
 }
 
 type RoleType struct {
@@ -201,3 +212,16 @@ func initRoleType() {
 		}
 	}
 }
+
+// initQsOpenApiConfig 全时开放api配置
+func initQsOpenApiConfig() {
+	QsAppID = "ed1cc7c87c97089263fc899fbab193b0"
+	QsSecretKey = "d92b91265dbbc5e3af44edfb82503635"
+	if RunMode == "release" {
+		QsUserId = 22330940
+		QsUserName = "1406228535@qq.com"
+	} else {
+		QsUserId = 19896481
+		QsUserName = "pyan@hzinsights.com"
+	}
+}