Browse Source

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

csx 3 years ago
parent
commit
0e00bafb46

+ 3 - 3
conf/app.conf View File

45
 
45
 
46
 
46
 
47
 [prod]
47
 [prod]
48
-org_id = 10215
48
+org_id = 10188
49
 mobile_token_expiration_second = 86400
49
 mobile_token_expiration_second = 86400
50
 httpdomain = https://api.xt.kuyicloud.com
50
 httpdomain = https://api.xt.kuyicloud.com
51
 sso_domain = https://sso.kuyicloud.com
51
 sso_domain = https://sso.kuyicloud.com
57
 # gdyb_url="http://igb.hsa.gdgov.cn/ebus/sz_prd/hsa/hgs/"
57
 # gdyb_url="http://igb.hsa.gdgov.cn/ebus/sz_prd/hsa/hgs/"
58
 #内蒙古
58
 #内蒙古
59
 # gdyb_url = "http://10.38.23.105:8090/uif-hsaf-med-api/api/medical/service/"
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
 # gdyb_paasid = "jm_sc_yjyy"
61
 # gdyb_paasid = "jm_sc_yjyy"
62
 #gdyb_paasid="zh_prd_yrojyy"
62
 #gdyb_paasid="zh_prd_yrojyy"
63
 #gdyb_paasid = "sz_prd_yjyy"
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 View File

5
 	"fmt"
5
 	"fmt"
6
 	"gdyb/models"
6
 	"gdyb/models"
7
 	_ "gdyb/routers"
7
 	_ "gdyb/routers"
8
-	"gdyb/service"
9
 	"github.com/astaxie/beego"
8
 	"github.com/astaxie/beego"
10
 	"github.com/qiniu/api.v7/auth/qbox"
9
 	"github.com/qiniu/api.v7/auth/qbox"
11
 	"github.com/qiniu/api.v7/storage"
10
 	"github.com/qiniu/api.v7/storage"
15
 )
14
 )
16
 
15
 
17
 func init() {
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
 func main() {
24
 func main() {

+ 36 - 38
service/jsyb_service.go View File

1
 package service
1
 package service
2
 
2
 
3
 import (
3
 import (
4
-	"bytes"
5
 	"crypto/hmac"
4
 	"crypto/hmac"
6
 	"crypto/sha1"
5
 	"crypto/sha1"
7
 	"encoding/base64"
6
 	"encoding/base64"
8
 	"encoding/json"
7
 	"encoding/json"
9
 	"fmt"
8
 	"fmt"
10
 	"gdyb/utils/csbhttp"
9
 	"gdyb/utils/csbhttp"
11
-	"io/ioutil"
12
-	"net/http"
13
 	"strconv"
10
 	"strconv"
14
 	"time"
11
 	"time"
15
 )
12
 )
53
 	input["data"] = inputData
50
 	input["data"] = inputData
54
 	inputMessage["input"] = input //交易输入
51
 	inputMessage["input"] = input //交易输入
55
 
52
 
56
-	var inputLog string
53
+	//var inputLog string
57
 	bytesData, _ := json.Marshal(inputMessage)
54
 	bytesData, _ := json.Marshal(inputMessage)
58
-	inputLog = string(bytesData)
55
+	//inputLog = string(bytesData)
59
 	fmt.Println(string(bytesData))
56
 	fmt.Println(string(bytesData))
60
 	if err != nil {
57
 	if err != nil {
61
 		fmt.Println(err.Error())
58
 		fmt.Println(err.Error())
62
 		return err.Error(), ""
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
 	//key := "_api_access_key=" + access_key + "&_api_name=" + "hssServives" + "&_api_timestamp=" + strconv.FormatInt(timestamp, 10) + "&_api_version=" + "1.0.0"
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
 	//request_url = "http://10.72.3.87:8086/CSB/1101"
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
 func HttpRequest(url string, ak string, sk string, timestamp int64, requestByte []byte, json string) string {
98
 func HttpRequest(url string, ak string, sk string, timestamp int64, requestByte []byte, json string) string {
102
 	fmt.Println(url)
99
 	fmt.Println(url)
128
 	//打印请求参数信息
125
 	//打印请求参数信息
129
 	csbHP.Print()
126
 	csbHP.Print()
130
 	//进行调用, 返回的第二项为resonse http headers (map[string][]string类型)
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
 	if err != nil {
131
 	if err != nil {
134
 		fmt.Println(err)
132
 		fmt.Println(err)

+ 12 - 29
utils/csbhttp/httpcaller.go View File

19
 package csbhttp
19
 package csbhttp
20
 
20
 
21
 import (
21
 import (
22
+	"fmt"
23
+	//"crypto/tls"
22
 	"bytes"
24
 	"bytes"
23
 	"encoding/json"
25
 	"encoding/json"
24
-	"fmt"
25
 	"io/ioutil"
26
 	"io/ioutil"
26
 	"net"
27
 	"net"
27
 	"net/http"
28
 	"net/http"
29
 	"strconv"
30
 	"strconv"
30
 	"strings"
31
 	"strings"
31
 	"sync"
32
 	"sync"
32
-	//"crypto/tls"
33
 	"time"
33
 	"time"
34
 )
34
 )
35
 
35
 
128
 */
128
 */
129
 func signParams(params map[string]string, api string, version string, ak string, sk string) (headMaps map[string]string) {
129
 func signParams(params map[string]string, api string, version string, ak string, sk string) (headMaps map[string]string) {
130
 	headMaps = make(map[string]string)
130
 	headMaps = make(map[string]string)
131
-	fmt.Println("sk=" + sk)
131
+
132
 	params[API_NAME_KEY] = api
132
 	params[API_NAME_KEY] = api
133
 	headMaps[API_NAME_KEY] = api
133
 	headMaps[API_NAME_KEY] = api
134
 
134
 
164
 当处理正常时,异常为nil
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
 	//init rtnHeaders
168
 	//init rtnHeaders
169
 	rtnHeaders = make(map[string][]string)
169
 	rtnHeaders = make(map[string][]string)
170
 
170
 
212
 	}
212
 	}
213
 
213
 
214
 	reqUrl := params.requestUrl
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
 	if params.ct.jsonBody != "" {
217
 	if params.ct.jsonBody != "" {
223
 		_, err = json.Marshal(params.ct.jsonBody)
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
 		reqStr = params.ct.jsonBody
222
 		reqStr = params.ct.jsonBody
228
-		//defaultContentType = "application/json;charset=UTF-8"
223
+		defaultContentType = params.ct.contentType
229
 		reqUrl = appendParams(reqUrl, data.Encode())
224
 		reqUrl = appendParams(reqUrl, data.Encode())
230
 	} else if params.ct.bytesBody != nil {
225
 	} else if params.ct.bytesBody != nil {
231
 		reqStr = string(params.ct.bytesBody)
226
 		reqStr = string(params.ct.bytesBody)
232
-		//defaultContentType = params.ct.contentType
227
+		defaultContentType = params.ct.contentType
233
 		reqUrl = appendParams(reqUrl, data.Encode())
228
 		reqUrl = appendParams(reqUrl, data.Encode())
234
 	} else {
229
 	} else {
235
 		reqStr = data.Encode()
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
 	if err != nil {
235
 	if err != nil {
251
 		return str, rtnHeaders, &HttpCallerException{Message: "failed to construct http post request", CauseErr: err}
236
 		return str, rtnHeaders, &HttpCallerException{Message: "failed to construct http post request", CauseErr: err}
262
 	signHeaders := signParams(urlParams, params.api, params.version, params.ak, params.sk)
247
 	signHeaders := signParams(urlParams, params.api, params.version, params.ak, params.sk)
263
 	printDebug("signHeaders", signHeaders)
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
 	if params.headers != nil {
251
 	if params.headers != nil {
267
 		for k, v := range params.headers {
252
 		for k, v := range params.headers {
268
 			req.Header.Add(k, v)
253
 			req.Header.Add(k, v)
276
 	}
261
 	}
277
 
262
 
278
 	//client.Timeout
263
 	//client.Timeout
279
-	req.Close = true
280
 	resp, err := client.Do(req)
264
 	resp, err := client.Do(req)
281
 
265
 
282
 	if err != nil {
266
 	if err != nil {
283
-		fmt.Println(err)
284
 		return str, rtnHeaders, &HttpCallerException{Message: "failed to invoke http post", CauseErr: err}
267
 		return str, rtnHeaders, &HttpCallerException{Message: "failed to invoke http post", CauseErr: err}
285
 	}
268
 	}
286
 
269
 

+ 0 - 0
utils/csbhttp/httpexception.go View File


+ 5 - 15
utils/csbhttp/httpparams.go View File

18
 */
18
 */
19
 package csbhttp
19
 package csbhttp
20
 
20
 
21
+import ()
21
 import (
22
 import (
22
 	"encoding/json"
23
 	"encoding/json"
23
 	"fmt"
24
 	"fmt"
107
 }
108
 }
108
 
109
 
109
 func (hp *HttpParams) SetContentBody(jsonStr string, byteArr []byte) error {
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
 	if jsonStr != "" {
116
 	if jsonStr != "" {
119
-		fmt.Println("333333334444444")
120
-
121
 		hp.ct.jsonBody = jsonStr
117
 		hp.ct.jsonBody = jsonStr
122
 		hp.ct.contentType = JSON
118
 		hp.ct.contentType = JSON
123
 	}
119
 	}
124
 
120
 
125
 	if byteArr != nil {
121
 	if byteArr != nil {
126
-		fmt.Println("5555556666666")
127
-
128
 		hp.ct.bytesBody = byteArr //TODO: copy or pointer ?
122
 		hp.ct.bytesBody = byteArr //TODO: copy or pointer ?
129
 		hp.ct.contentType = BINARY
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
 	return nil
126
 	return nil
137
 }
127
 }

+ 0 - 10
utils/csbhttp/signutil.go View File

23
 	"crypto/hmac"
23
 	"crypto/hmac"
24
 	"crypto/sha1"
24
 	"crypto/sha1"
25
 	"encoding/base64"
25
 	"encoding/base64"
26
-	"fmt"
27
 	"hash"
26
 	"hash"
28
 	"io"
27
 	"io"
29
 	"sort"
28
 	"sort"
77
 
76
 
78
 // 做签名处理
77
 // 做签名处理
79
 func doSign(params map[string]string, secretKey string) string {
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
 	hs := newParamsSorter(params)
79
 	hs := newParamsSorter(params)
87
 
80
 
88
-	fmt.Println("hs")
89
-	fmt.Println(hs)
90
-
91
 	// Sort the temp by the Ascending Order
81
 	// Sort the temp by the Ascending Order
92
 	hs.Sort()
82
 	hs.Sort()
93
 
83
 

+ 0 - 0
utils/csbhttp/utils.go View File