Ver código fonte

Merge branch 'master' of http://git.shengws.com/csx/gdyb

csx 3 anos atrás
pai
commit
0e00bafb46

+ 3 - 3
conf/app.conf Ver arquivo

@@ -45,7 +45,7 @@ appsecret="61ee2e6268497d5aa9de0b0187c39aea"
45 45
 
46 46
 
47 47
 [prod]
48
-org_id = 10215
48
+org_id = 10188
49 49
 mobile_token_expiration_second = 86400
50 50
 httpdomain = https://api.xt.kuyicloud.com
51 51
 sso_domain = https://sso.kuyicloud.com
@@ -57,11 +57,11 @@ gdyb_url = "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/"
57 57
 # gdyb_url="http://igb.hsa.gdgov.cn/ebus/sz_prd/hsa/hgs/"
58 58
 #内蒙古
59 59
 # gdyb_url = "http://10.38.23.105:8090/uif-hsaf-med-api/api/medical/service/"
60
-# gdyb_paasid = "sg03_prd"
60
+gdyb_paasid = "sg03_prd"
61 61
 # gdyb_paasid = "jm_sc_yjyy"
62 62
 #gdyb_paasid="zh_prd_yrojyy"
63 63
 #gdyb_paasid = "sz_prd_yjyy"
64
-gdyb_paasid = "zq_prd_yjyy"
64
+# gdyb_paasid = "zq_prd_yjyy"
65 65
 
66 66
 
67 67
 

+ 5 - 6
main.go Ver arquivo

@@ -5,7 +5,6 @@ import (
5 5
 	"fmt"
6 6
 	"gdyb/models"
7 7
 	_ "gdyb/routers"
8
-	"gdyb/service"
9 8
 	"github.com/astaxie/beego"
10 9
 	"github.com/qiniu/api.v7/auth/qbox"
11 10
 	"github.com/qiniu/api.v7/storage"
@@ -15,11 +14,11 @@ import (
15 14
 )
16 15
 
17 16
 func init() {
18
-	service.ConnectDB()
19
-	org_id, _ := beego.AppConfig.Int64("org_id")
20
-	miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
21
-	CreateLog(miConfig)
22
-	UploadLog(miConfig)
17
+	//service.ConnectDB()
18
+	//org_id, _ := beego.AppConfig.Int64("org_id")
19
+	//miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
20
+	//CreateLog(miConfig)
21
+	//UploadLog(miConfig)
23 22
 
24 23
 }
25 24
 func main() {

+ 36 - 38
service/jsyb_service.go Ver arquivo

@@ -1,15 +1,12 @@
1 1
 package service
2 2
 
3 3
 import (
4
-	"bytes"
5 4
 	"crypto/hmac"
6 5
 	"crypto/sha1"
7 6
 	"encoding/base64"
8 7
 	"encoding/json"
9 8
 	"fmt"
10 9
 	"gdyb/utils/csbhttp"
11
-	"io/ioutil"
12
-	"net/http"
13 10
 	"strconv"
14 11
 	"time"
15 12
 )
@@ -53,50 +50,50 @@ func Jsyb1101(certNo string, org_name string, doctor string, fixmedins_code stri
53 50
 	input["data"] = inputData
54 51
 	inputMessage["input"] = input //交易输入
55 52
 
56
-	var inputLog string
53
+	//var inputLog string
57 54
 	bytesData, _ := json.Marshal(inputMessage)
58
-	inputLog = string(bytesData)
55
+	//inputLog = string(bytesData)
59 56
 	fmt.Println(string(bytesData))
60 57
 	if err != nil {
61 58
 		fmt.Println(err.Error())
62 59
 		return err.Error(), ""
63 60
 	}
64
-	reader := bytes.NewReader(bytesData)
61
+	//reader := bytes.NewReader(bytesData)
65 62
 
66
-	request, err := http.NewRequest("POST", "http://10.72.3.87:8086/CSB/1101", reader)
67
-	if err != nil {
68
-		fmt.Println(err.Error())
69
-		return err.Error(), ""
70
-	}
63
+	//request, err := http.NewRequest("POST", "http://10.72.3.87:8086/CSB/1101", reader)
64
+	//if err != nil {
65
+	//	fmt.Println(err.Error())
66
+	//	return err.Error(), ""
67
+	//}
71 68
 	//key := "_api_access_key=" + access_key + "&_api_name=" + "hssServives" + "&_api_timestamp=" + strconv.FormatInt(timestamp, 10) + "&_api_version=" + "1.0.0"
72 69
 
73
-	fmt.Println(skey)
74
-	fmt.Println(timestamp_str)
75
-	fmt.Println(access_key)
76
-
77
-	request.Header.Set("Content-Type", "application/json")
78
-	request.Header.Set("_api_timestamp", timestamp_str)
79
-	request.Header.Set("_api_name", "hssServives")
80
-	request.Header.Set("_api_version", "1.0.0")
81
-	request.Header.Set("_api_access_key", access_key)
82
-	request.Header.Set("_api_signature", skey)
83
-
84
-	client := http.Client{}
85
-	resp, err := client.Do(request)
86
-	if err != nil {
87
-		fmt.Println(err.Error())
88
-		return err.Error(), ""
89
-	}
90
-	respBytes, err := ioutil.ReadAll(resp.Body)
91
-	if err != nil {
92
-		fmt.Println(err.Error())
93
-		return err.Error(), ""
94
-	}
95
-	fmt.Println(string(respBytes))
96
-	str := string(respBytes)
97
-	return str, inputLog
70
+	//fmt.Println(skey)
71
+	//fmt.Println(timestamp_str)
72
+	//fmt.Println(access_key)
73
+	//
74
+	//request.Header.Set("Content-Type", "application/json")
75
+	//request.Header.Set("_api_timestamp", timestamp_str)
76
+	//request.Header.Set("_api_name", "hssServives")
77
+	//request.Header.Set("_api_version", "1.0.0")
78
+	//request.Header.Set("_api_access_key", access_key)
79
+	//request.Header.Set("_api_signature", skey)
80
+	//
81
+	//client := http.Client{}
82
+	//resp, err := client.Do(request)
83
+	//if err != nil {
84
+	//	fmt.Println(err.Error())
85
+	//	return err.Error(), ""
86
+	//}
87
+	//respBytes, err := ioutil.ReadAll(resp.Body)
88
+	//if err != nil {
89
+	//	fmt.Println(err.Error())
90
+	//	return err.Error(), ""
91
+	//}
92
+	//fmt.Println(string(respBytes))
93
+	//str := string(respBytes)
94
+	//return str, inputLog
98 95
 	//request_url = "http://10.72.3.87:8086/CSB/1101"
99
-	//return HttpRequest(request_url, access_key, secret_key, timestamp, bytesData, string(bytesData)), ""
96
+	return HttpRequest(request_url, access_key, secret_key, timestamp, bytesData, string(bytesData)), ""
100 97
 }
101 98
 func HttpRequest(url string, ak string, sk string, timestamp int64, requestByte []byte, json string) string {
102 99
 	fmt.Println(url)
@@ -128,7 +125,8 @@ func HttpRequest(url string, ak string, sk string, timestamp int64, requestByte
128 125
 	//打印请求参数信息
129 126
 	csbHP.Print()
130 127
 	//进行调用, 返回的第二项为resonse http headers (map[string][]string类型)
131
-	res, _, err := csbhttp.Invoke(*csbHP, requestByte)
128
+	//res, _, err := csbhttp.Invoke(*csbHP, requestByte)
129
+	res, _, err := csbhttp.Invoke(*csbHP)
132 130
 	//是否发成错误
133 131
 	if err != nil {
134 132
 		fmt.Println(err)

+ 12 - 29
utils/csbhttp/httpcaller.go Ver arquivo

@@ -19,9 +19,10 @@ CSB-HTTP-SDK based on GO language.
19 19
 package csbhttp
20 20
 
21 21
 import (
22
+	"fmt"
23
+	//"crypto/tls"
22 24
 	"bytes"
23 25
 	"encoding/json"
24
-	"fmt"
25 26
 	"io/ioutil"
26 27
 	"net"
27 28
 	"net/http"
@@ -29,7 +30,6 @@ import (
29 30
 	"strconv"
30 31
 	"strings"
31 32
 	"sync"
32
-	//"crypto/tls"
33 33
 	"time"
34 34
 )
35 35
 
@@ -128,7 +128,7 @@ func parseUrlParamsMap(reqUrl string) (params map[string]string, err *HttpCaller
128 128
 */
129 129
 func signParams(params map[string]string, api string, version string, ak string, sk string) (headMaps map[string]string) {
130 130
 	headMaps = make(map[string]string)
131
-	fmt.Println("sk=" + sk)
131
+
132 132
 	params[API_NAME_KEY] = api
133 133
 	headMaps[API_NAME_KEY] = api
134 134
 
@@ -164,7 +164,7 @@ func signParams(params map[string]string, api string, version string, ak string,
164 164
 当处理正常时,异常为nil
165 165
 
166 166
 */
167
-func Invoke(params HttpParams, bytesData []byte) (str string, rtnHeaders map[string][]string, hcError *HttpCallerException) {
167
+func Invoke(params HttpParams) (str string, rtnHeaders map[string][]string, hcError *HttpCallerException) {
168 168
 	//init rtnHeaders
169 169
 	rtnHeaders = make(map[string][]string)
170 170
 
@@ -212,40 +212,25 @@ func Invoke(params HttpParams, bytesData []byte) (str string, rtnHeaders map[str
212 212
 	}
213 213
 
214 214
 	reqUrl := params.requestUrl
215
-	//defaultContentType := "application/x-www-form-urlencoded"
216
-	fmt.Println("打印开始")
217
-	fmt.Println(params.ct.jsonBody)
218
-	fmt.Println(reqUrl)
219
-	fmt.Println(params)
220
-	fmt.Println(params.ct.bytesBody)
221 215
 
216
+	defaultContentType := "application/x-www-form-urlencoded"
222 217
 	if params.ct.jsonBody != "" {
223 218
 		_, err = json.Marshal(params.ct.jsonBody)
224
-		//if err == nil {
225
-		//	return str, rtnHeaders, &HttpCallerException{Message: "failed to bad content type json string", CauseErr: err}
226
-		//}
219
+		if err == nil {
220
+			return str, rtnHeaders, &HttpCallerException{Message: "failed to bad content type json string", CauseErr: err}
221
+		}
227 222
 		reqStr = params.ct.jsonBody
228
-		//defaultContentType = "application/json;charset=UTF-8"
223
+		defaultContentType = params.ct.contentType
229 224
 		reqUrl = appendParams(reqUrl, data.Encode())
230 225
 	} else if params.ct.bytesBody != nil {
231 226
 		reqStr = string(params.ct.bytesBody)
232
-		//defaultContentType = params.ct.contentType
227
+		defaultContentType = params.ct.contentType
233 228
 		reqUrl = appendParams(reqUrl, data.Encode())
234 229
 	} else {
235 230
 		reqStr = data.Encode()
236 231
 	}
237 232
 
238
-	fmt.Println("打印开始1")
239
-	fmt.Println(reqStr)
240
-	fmt.Println(method)
241
-	fmt.Println(reqUrl)
242
-	fmt.Println(bytesData)
243
-	fmt.Println(string(bytesData))
244
-
245
-	req, err := http.NewRequest(method, reqUrl, bytes.NewReader(bytesData))
246
-
247
-	fmt.Println("打印开始2")
248
-	fmt.Println(req)
233
+	req, err := http.NewRequest(method, reqUrl, bytes.NewBufferString(reqStr))
249 234
 
250 235
 	if err != nil {
251 236
 		return str, rtnHeaders, &HttpCallerException{Message: "failed to construct http post request", CauseErr: err}
@@ -262,7 +247,7 @@ func Invoke(params HttpParams, bytesData []byte) (str string, rtnHeaders map[str
262 247
 	signHeaders := signParams(urlParams, params.api, params.version, params.ak, params.sk)
263 248
 	printDebug("signHeaders", signHeaders)
264 249
 
265
-	req.Header.Add("Content-Type", "application/json;charset=UTF-8")
250
+	req.Header.Add("Content-Type", defaultContentType)
266 251
 	if params.headers != nil {
267 252
 		for k, v := range params.headers {
268 253
 			req.Header.Add(k, v)
@@ -276,11 +261,9 @@ func Invoke(params HttpParams, bytesData []byte) (str string, rtnHeaders map[str
276 261
 	}
277 262
 
278 263
 	//client.Timeout
279
-	req.Close = true
280 264
 	resp, err := client.Do(req)
281 265
 
282 266
 	if err != nil {
283
-		fmt.Println(err)
284 267
 		return str, rtnHeaders, &HttpCallerException{Message: "failed to invoke http post", CauseErr: err}
285 268
 	}
286 269
 

+ 0 - 0
utils/csbhttp/httpexception.go Ver arquivo


+ 5 - 15
utils/csbhttp/httpparams.go Ver arquivo

@@ -18,6 +18,7 @@ CSB-HTTP-SDK based on GO language.
18 18
 */
19 19
 package csbhttp
20 20
 
21
+import ()
21 22
 import (
22 23
 	"encoding/json"
23 24
 	"fmt"
@@ -107,31 +108,20 @@ func (hp *HttpParams) AddHeader(key string, value string) *HttpParams {
107 108
 }
108 109
 
109 110
 func (hp *HttpParams) SetContentBody(jsonStr string, byteArr []byte) error {
110
-
111
-	//if jsonStr != "" && byteArr != nil {
112
-	//	fmt.Println("11111112222222")
113
-	//
114
-	//	errRtn := HttpCallerException{Message: "can not set jsonStr and byteArr parameters together!"}
115
-	//	return errRtn
116
-	//}
111
+	if jsonStr != "" && byteArr != nil {
112
+		errRtn := HttpCallerException{Message: "can not set jsonStr and byteArr parameters together!"}
113
+		return errRtn
114
+	}
117 115
 
118 116
 	if jsonStr != "" {
119
-		fmt.Println("333333334444444")
120
-
121 117
 		hp.ct.jsonBody = jsonStr
122 118
 		hp.ct.contentType = JSON
123 119
 	}
124 120
 
125 121
 	if byteArr != nil {
126
-		fmt.Println("5555556666666")
127
-
128 122
 		hp.ct.bytesBody = byteArr //TODO: copy or pointer ?
129 123
 		hp.ct.contentType = BINARY
130 124
 	}
131
-	fmt.Println("------")
132
-	fmt.Println(hp.ct.jsonBody)
133
-	fmt.Println(hp.ct.bytesBody)
134
-	fmt.Println("------")
135 125
 
136 126
 	return nil
137 127
 }

+ 0 - 10
utils/csbhttp/signutil.go Ver arquivo

@@ -23,7 +23,6 @@ import (
23 23
 	"crypto/hmac"
24 24
 	"crypto/sha1"
25 25
 	"encoding/base64"
26
-	"fmt"
27 26
 	"hash"
28 27
 	"io"
29 28
 	"sort"
@@ -77,17 +76,8 @@ func (hs *paramsSorter) Swap(i, j int) {
77 76
 
78 77
 // 做签名处理
79 78
 func doSign(params map[string]string, secretKey string) string {
80
-	fmt.Println("params")
81
-	fmt.Println(params)
82
-
83
-	fmt.Println("secretKey")
84
-	fmt.Println(secretKey)
85
-
86 79
 	hs := newParamsSorter(params)
87 80
 
88
-	fmt.Println("hs")
89
-	fmt.Println(hs)
90
-
91 81
 	// Sort the temp by the Ascending Order
92 82
 	hs.Sort()
93 83
 

+ 0 - 0
utils/csbhttp/utils.go Ver arquivo