zwxi 1 жил өмнө
parent
commit
d2c6341810
1 өөрчлөгдсөн 11 нэмэгдсэн , 10 устгасан
  1. 11 10
      services/comein/comein.go

+ 11 - 10
services/comein/comein.go

@@ -279,16 +279,6 @@ func InitAddWhiteList() (err error) {
 
 	postUrl := utils.COMEIN_URL
 
-	timestamp := fmt.Sprintf("%d", time.Now().UnixNano()/1e6)
-
-	signature := GetSignature("1", timestamp)
-
-	request := yb.SyncWhitelist{
-		Opt:       1,
-		Timestamp: timestamp,
-		AppID:     utils.COMEIN_WHITELIST_APPID,
-		Signature: signature,
-	}
 
 	list, err := models.GetComeinWhiteUserMulti()
 	if err != nil {
@@ -317,12 +307,22 @@ func InitAddWhiteList() (err error) {
 	// 分批发送请求
 	var count int
 	for i, v := range whiteList {
+		request := yb.SyncWhitelist{
+			Opt:       1,
+			AppID:     utils.COMEIN_WHITELIST_APPID,
+		}
 		request.Whitelist = append(request.Whitelist, v)
 		if count < 10000 && (len(whiteList)-i-1) > 0 {
 			count++
 			continue
 		}
 		count = 0
+
+		timestamp := fmt.Sprintf("%d", time.Now().UnixNano()/1e6)
+		signature := GetSignature("1", timestamp)
+		request.Signature = signature
+		request.Timestamp = timestamp
+
 		jsonData, e := json.Marshal(request)
 		if e != nil {
 			err = e
@@ -377,6 +377,7 @@ func InitAddWhiteList() (err error) {
 	return
 }
 
+
 func GetSignature(opt, timestamp string) (signature string) {
 	//获取map的下标切片,然后对下标进行排序
 	keySlice := make([]string, 0)