|
@@ -1,12 +1,15 @@
|
1
|
1
|
package service
|
2
|
2
|
|
3
|
3
|
import (
|
|
4
|
+ "bytes"
|
4
|
5
|
"crypto/hmac"
|
5
|
6
|
"crypto/sha1"
|
6
|
7
|
"encoding/base64"
|
7
|
8
|
"encoding/json"
|
8
|
9
|
"fmt"
|
9
|
10
|
"gdyb/utils/csbhttp"
|
|
11
|
+ "io/ioutil"
|
|
12
|
+ "net/http"
|
10
|
13
|
"strconv"
|
11
|
14
|
"time"
|
12
|
15
|
)
|
|
@@ -50,17 +53,45 @@ func Jsyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
|
50
|
53
|
input["data"] = inputData
|
51
|
54
|
inputMessage["input"] = input //交易输入
|
52
|
55
|
|
53
|
|
- var inputLog string
|
|
56
|
+ //var inputLog string
|
54
|
57
|
bytesData, err := json.Marshal(inputMessage)
|
55
|
|
- inputLog = string(bytesData)
|
|
58
|
+ //inputLog = string(bytesData)
|
56
|
59
|
fmt.Println(string(bytesData))
|
57
|
60
|
if err != nil {
|
58
|
61
|
fmt.Println(err.Error())
|
59
|
62
|
return err.Error(), ""
|
60
|
63
|
}
|
|
64
|
+ reader := bytes.NewReader(bytesData)
|
61
|
65
|
|
62
|
|
- return HttpRequest(request_url, access_key, secret_key, timestamp, bytesData, string(bytesData)), inputLog
|
|
66
|
+ request, err := http.NewRequest("POST", "http://10.72.3.83:8086/CSB", reader)
|
|
67
|
+ if err != nil {
|
|
68
|
+ fmt.Println(err.Error())
|
|
69
|
+ return err.Error(), ""
|
|
70
|
+ }
|
|
71
|
+ key := "_api_access_key=" + access_key + "&_api_name=" + "hssServives" + "&_api_timestamp=" + strconv.FormatInt(timestamp, 10) + "&_api_version=" + "1.0.0"
|
63
|
72
|
|
|
73
|
+ request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
|
74
|
+ request.Header.Set("_api_timestamp", strconv.FormatInt(timestamp, 10))
|
|
75
|
+ request.Header.Set("_api_name", "hssServives")
|
|
76
|
+ request.Header.Set("_api_version", "1.0.0")
|
|
77
|
+ request.Header.Set("_api_access_key", access_key)
|
|
78
|
+ request.Header.Set("_api_access_key", hmacsha1(key, secret_key))
|
|
79
|
+
|
|
80
|
+ client := http.Client{}
|
|
81
|
+ resp, err := client.Do(request)
|
|
82
|
+ if err != nil {
|
|
83
|
+ fmt.Println(err.Error())
|
|
84
|
+ return err.Error(), ""
|
|
85
|
+ }
|
|
86
|
+ respBytes, err := ioutil.ReadAll(resp.Body)
|
|
87
|
+ if err != nil {
|
|
88
|
+ fmt.Println(err.Error())
|
|
89
|
+ return err.Error(), ""
|
|
90
|
+ }
|
|
91
|
+ fmt.Println(string(respBytes))
|
|
92
|
+ str := string(respBytes)
|
|
93
|
+ return str, ""
|
|
94
|
+ //return HttpRequest(request_url, access_key, secret_key, timestamp, bytesData, string(bytesData)), inputLog
|
64
|
95
|
}
|
65
|
96
|
func HttpRequest(url string, ak string, sk string, timestamp int64, requestByte []byte, json string) string {
|
66
|
97
|
fmt.Println(url)
|