update
This commit is contained in:
@@ -84,11 +84,11 @@ type TaxEvalQueryResponse struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
Data struct {
|
||||
Status int `json:"status"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Detail struct {
|
||||
Files []string `json:"files"`
|
||||
Error string `json:"error"`
|
||||
} `json:"detail"`
|
||||
Files []string `json:"files,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
} `json:"detail,omitempty"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
@@ -188,7 +188,6 @@ func (s *TaxHealthService) EvaluateTaxHealth(request TaxEvalRequest) (*TaxEvalRe
|
||||
// 序列化请求体
|
||||
jsonData, err := json.Marshal(request)
|
||||
jsonDataStr := string(jsonData)
|
||||
fmt.Println(jsonDataStr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("序列化请求体失败: %v", err)
|
||||
}
|
||||
@@ -204,6 +203,8 @@ func (s *TaxHealthService) EvaluateTaxHealth(request TaxEvalRequest) (*TaxEvalRe
|
||||
headers := map[string]string{
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
"origin": "https://api.cmdp.cn",
|
||||
"referer": "https://api.cmdp.cn/",
|
||||
"x-gi-user-id": s.userID,
|
||||
"x-gi-user-sig": signature,
|
||||
"x-gi-nonce": nonce,
|
||||
@@ -211,7 +212,6 @@ func (s *TaxHealthService) EvaluateTaxHealth(request TaxEvalRequest) (*TaxEvalRe
|
||||
}
|
||||
// 发送POST请求
|
||||
response, err := s.httpClient.Post(apiURL, []byte(jsonDataStr), "application/json", headers)
|
||||
fmt.Println(string(response))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("发送请求失败: %v", err)
|
||||
}
|
||||
@@ -251,6 +251,7 @@ func (s *TaxHealthService) QueryTaxEvalResult(orderNo string) (*TaxEvalQueryResp
|
||||
|
||||
// 发送GET请求
|
||||
response, err := s.httpClient.Get(apiURL, headers)
|
||||
fmt.Println(string(response))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("发送请求失败: %v", err)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ func (c *HTTPClient) Get(url string, headers map[string]string) ([]byte, error)
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
return nil, fmt.Errorf("GET请求失败,状态码: %d", resp.StatusCode)
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
return nil, fmt.Errorf("GET请求失败,状态码: %d, 响应体: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
@@ -62,7 +63,6 @@ func (c *HTTPClient) PostJSON(url string, data interface{}, headers map[string]s
|
||||
|
||||
// Post 发送POST请求
|
||||
func (c *HTTPClient) Post(url string, data []byte, contentType string, headers map[string]string) ([]byte, error) {
|
||||
fmt.Println(string(data))
|
||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("创建POST请求失败: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user