修正west url环境区分
This commit is contained in:
@@ -6,10 +6,11 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"tianyuan-api/pkg/crypto"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"tianyuan-api/apps/api/internal/config"
|
||||
"tianyuan-api/pkg/crypto"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -25,15 +26,13 @@ type WestResp struct {
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
type WestDexService struct {
|
||||
Key string
|
||||
SecretID string
|
||||
config config.WestConfig
|
||||
}
|
||||
|
||||
// NewWestDexService 是一个构造函数,用于初始化 WestDexService
|
||||
func NewWestDexService(key, secretID string) *WestDexService {
|
||||
func NewWestDexService(config config.WestConfig) *WestDexService {
|
||||
return &WestDexService{
|
||||
Key: key,
|
||||
SecretID: secretID,
|
||||
config: config,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +42,7 @@ func (w *WestDexService) CallAPI(code string, reqData map[string]interface{}) (r
|
||||
timestamp := strconv.FormatInt(time.Now().UnixNano()/int64(time.Millisecond), 10)
|
||||
|
||||
// 构造请求URL
|
||||
//https://apimaster.westdex.com.cn
|
||||
reqUrl := fmt.Sprintf("http://proxy.tianyuanapi.com/api/invoke/%s/%s?timestamp=%s", w.SecretID, code, timestamp)
|
||||
reqUrl := fmt.Sprintf("%s/%s/%s?timestamp=%s", w.config.Url, w.config.SecretId, code, timestamp)
|
||||
|
||||
// 将请求参数编码为JSON格式
|
||||
data := map[string]interface{}{
|
||||
@@ -99,7 +97,7 @@ func (w *WestDexService) CallAPI(code string, reqData map[string]interface{}) (r
|
||||
}
|
||||
|
||||
// 解密响应数据
|
||||
decryptedData, DecryptErr := crypto.WestDexDecrypt(westDexResp.Data, w.Key)
|
||||
decryptedData, DecryptErr := crypto.WestDexDecrypt(westDexResp.Data, w.config.Key)
|
||||
if DecryptErr != nil {
|
||||
logx.Errorf("【西部数据请求】响应数据解密错误: %v", DecryptErr)
|
||||
return nil, DecryptErr
|
||||
|
||||
Reference in New Issue
Block a user