瀏覽代碼

token和日志

xuzhiheng 4 年之前
父節點
當前提交
8d09975998
共有 2 個文件被更改,包括 47 次插入6 次删除
  1. 4 4
      src/config.json
  2. 43 2
      src/push/push.go

+ 4 - 4
src/config.json

@@ -10,12 +10,12 @@
   "subday": 15,
   "customer": {
     "api": "http://web-jytest.jydev.jianyu360.com/api1/user/jy_newuser",
-    "mgodb": "192.168.3.128:27080",
+    "mgodb": "192.168.3.206:27080",
     "dbname": "jyqyfw",
     "dbsize": 5
   },
   "preview_href": "http://192.168.20.214:5500/data-preview.html",
-  "elasticsearch": "http://192.168.3.128:9800",
+  "elasticsearch": "http://192.168.3.206:9800",
   "elasticsearch_index": "bidding",
   "elasticsearch_type": "bidding",
   "elasticPoolSize": 10,
@@ -58,13 +58,13 @@
     "coll_project": "usermail_history_projectid"
   },
   "extract": {
-    "addr": "192.168.3.128:27080",
+    "addr": "192.168.3.206:27080",
     "coll": "result_20200917",
     "db": "qfw",
     "size": 15
   },
   "es": {
-    "addr": "http://192.168.3.128:9800",
+    "addr": "http://192.168.3.206:9800",
     "index": "bidding_v5",
     "itype": "bidding",
     "pool": 15

+ 43 - 2
src/push/push.go

@@ -5,8 +5,12 @@ import (
 	"encoding/json"
 	"log"
 	qutil "qfw/util"
+	"time"
 	. "util"
 
+	"fmt"
+	"net/url"
+
 	"github.com/go-xweb/xweb"
 	"github.com/tealeg/xlsx"
 )
@@ -43,17 +47,32 @@ func (this *Push) DataPush() {
 	}
 	log.Println(dataArr)
 	databyte, _ := json.Marshal(dataArr)
+	respCode, result := "", map[string]interface{}{}
 	response, err := HttpPost("url", map[string]string{"Content-Type": ContentTypeJson}, bytes.NewBuffer(databyte))
 	if err == nil {
 		resMap := qutil.ObjToMap(string(response))
-		if *resMap != nil {
-			if qutil.ObjToString((*resMap)["respCode"]) == "00000" {
+		if resMap != nil && *resMap != nil {
+			respCode = qutil.ObjToString((*resMap)["respCode"])
+			if respCode == "00000" {
 				log.Println("成功")
 			} else {
 				log.Println("异常")
+				results := qutil.ObjToMap((*resMap)["result"])
+				if results != nil && *results != nil {
+					result = *results
+				}
 			}
 		}
 	}
+	Mgo.Save("dataPushLog", map[string]interface{}{
+		"respCode":    respCode,
+		"dataLenth":   len(dataArr),
+		"createtime":  time.Now().Unix(),
+		"appid":       appid,
+		"getDataType": getDataType,
+		"dataType":    "",
+		"result":      result,
+	})
 }
 
 func ExcelParse() []map[string]interface{} {
@@ -90,3 +109,25 @@ func ExcelParse() []map[string]interface{} {
 	}
 	return resourceArr
 }
+
+func getAccessToken() {
+	apiurl := ""
+	appid := ""
+	appKey := ""
+	data := make(url.Values)
+	data["method"] = []string{"OSP_CHECK_TOKEN"}
+	data["appId"] = []string{appid}
+	data["appKey"] = []string{appKey}
+	now := time.Now().Unix()
+	bs, _ := HttpPostForm(apiurl, map[string]string{
+		"timestamp": fmt.Sprint(now),
+	}, data)
+	resMap := qutil.ObjToMap(string(bs))
+	if *resMap != nil {
+		if qutil.ObjToString((*resMap)["respCode"]) == "00000" {
+			log.Println("成功")
+		} else {
+			log.Println("异常")
+		}
+	}
+}