timeSliceQuery 8
This commit is contained in:
parent
87820f6836
commit
881600758d
|
|
@ -281,32 +281,69 @@ func (s *CmbMixRepoImpl) Request(ctx context.Context, req *v1.CmbRequest, uri st
|
||||||
uv.Set(kv.Key, fmt.Sprintf("%v", kv.Value))
|
uv.Set(kv.Key, fmt.Sprintf("%v", kv.Value))
|
||||||
}
|
}
|
||||||
|
|
||||||
requestUrl := uri + "?" + uv.Encode()
|
h := http.Header{
|
||||||
|
"Content-Type": []string{"application/x-www-form-urlencoded"},
|
||||||
_, bodyBytes, err := request.POST(ctx, requestUrl, nil, s.options)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("请求掌上生活错误,url:%s,err:%v", requestUrl, err)
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(bodyBytes) == 0 {
|
r := uri + "?" + uv.Encode()
|
||||||
return nil, errors.New("请求掌上生活错误,请求失败,返回数据为空")
|
|
||||||
|
_, bodyBytes, err := request.Post(ctx, r, nil, request.WithHeaders(h), request.WithTimeout(time.Second*20))
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("请求掌上生活报错,url:%s,err:%v", r, err)
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var response *v1.CmbReply
|
var response *v1.CmbReply
|
||||||
if err = json.Unmarshal(bodyBytes, &response); err != nil {
|
if err = json.Unmarshal(bodyBytes, &response); err != nil {
|
||||||
log.Errorf("请求掌上生活错误,数据解析报错:%s,url:%s,bodyBytes:%s", err.Error(), requestUrl, string(bodyBytes))
|
log.Errorf("请求掌上生活返回数据解析报错:%s,url:%s,bodyBytes:%s", err.Error(), r, string(bodyBytes))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.RespCode != vo.CmbResponseStatusSuccess.GetValue() {
|
if response.RespCode != vo.CmbResponseStatusSuccess.GetValue() {
|
||||||
log.Errorf("请求掌上生活错误:msg:%s,url:%s,bodyBytes:%s", response.RespMsg, requestUrl, string(bodyBytes))
|
log.Errorf("请求掌上生活返回报错:msg:%s,url:%s,bodyBytes:%s", response.RespMsg, r, string(bodyBytes))
|
||||||
return nil, fmt.Errorf(response.RespMsg)
|
return nil, fmt.Errorf(response.RespMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//func (s *CmbMixRepoImpl) Request(ctx context.Context, req *v1.CmbRequest, uri string) (*v1.CmbReply, error) {
|
||||||
|
//
|
||||||
|
// kvRows := helper.SortStructFieldsByKey(req)
|
||||||
|
//
|
||||||
|
// uv := url.Values{}
|
||||||
|
//
|
||||||
|
// for _, kv := range kvRows {
|
||||||
|
// uv.Set(kv.Key, fmt.Sprintf("%v", kv.Value))
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// requestUrl := uri + "?" + uv.Encode()
|
||||||
|
//
|
||||||
|
// _, bodyBytes, err := request.POST(ctx, requestUrl, nil, s.options)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Errorf("请求掌上生活错误,url:%s,err:%v", requestUrl, err)
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if len(bodyBytes) == 0 {
|
||||||
|
// return nil, errors.New("请求掌上生活错误,请求失败,返回数据为空")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var response *v1.CmbReply
|
||||||
|
// if err = json.Unmarshal(bodyBytes, &response); err != nil {
|
||||||
|
// log.Errorf("请求掌上生活错误,数据解析报错:%s,url:%s,bodyBytes:%s", err.Error(), requestUrl, string(bodyBytes))
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if response.RespCode != vo.CmbResponseStatusSuccess.GetValue() {
|
||||||
|
// log.Errorf("请求掌上生活返回报错:msg:%s,url:%s,bodyBytes:%s", response.RespMsg, requestUrl, string(bodyBytes))
|
||||||
|
// return nil, fmt.Errorf(response.RespMsg)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return response, nil
|
||||||
|
//}
|
||||||
|
|
||||||
func (s *CmbMixRepoImpl) Decrypt(_ context.Context, encryptBody string) (string, error) {
|
func (s *CmbMixRepoImpl) Decrypt(_ context.Context, encryptBody string) (string, error) {
|
||||||
|
|
||||||
if len(s.bc.Cmb.CmbSm2Pik) == 0 {
|
if len(s.bc.Cmb.CmbSm2Pik) == 0 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue