修正west url环境区分
This commit is contained in:
parent
b8d9a72dac
commit
a8e6836731
@ -16,5 +16,6 @@ KqPusherConf:
|
||||
- 127.0.0.1:9092
|
||||
Topic: apirequest
|
||||
WestConfig:
|
||||
Url: "http://proxy.tianyuanapi.com/api/invoke"
|
||||
Key: "121a1e41fc1690dd6b90afbcacd80cf4"
|
||||
SecretId: "449159"
|
@ -16,5 +16,6 @@ KqPusherConf:
|
||||
- tyapi_kafka:9092
|
||||
Topic: apirequest
|
||||
WestConfig:
|
||||
Url: "https://apimaster.westdex.com.cn/api/invoke"
|
||||
key: "121a1e41fc1690dd6b90afbcacd80cf4"
|
||||
secretId: "449159"
|
@ -19,6 +19,7 @@ type KqPusherConf struct {
|
||||
Topic string
|
||||
}
|
||||
type WestConfig struct {
|
||||
Url string
|
||||
Key string
|
||||
SecretId string
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -45,6 +45,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
UserProductRpc: userProductRpc,
|
||||
ApiAuthInterceptor: middleware.NewApiAuthInterceptorMiddleware(whitelistRpc, secretRpc, userProductRpc, rds).Handle,
|
||||
KqPusherClient: kq.NewPusher(c.KqPusherConf.Brokers, c.KqPusherConf.Topic),
|
||||
WestDexService: service.NewWestDexService(c.WestConfig.Key, c.WestConfig.SecretId), // 假设你将密钥和 ID 配置在 config 中
|
||||
WestDexService: service.NewWestDexService(c.WestConfig), // 假设你将密钥和 ID 配置在 config 中
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
version: '3'
|
||||
services:e
|
||||
services:
|
||||
tyapi_etcd:
|
||||
image: bitnami/etcd
|
||||
container_name: tyapi_etcd
|
||||
@ -183,6 +183,7 @@ services:e
|
||||
- tyapi_mysql
|
||||
- tyapi_redis
|
||||
- tyapi_etcd
|
||||
- tyapi_sentinel
|
||||
networks:
|
||||
- tyapi_network
|
||||
restart: always
|
||||
|
@ -170,6 +170,7 @@ services:
|
||||
- tyapi_mysql
|
||||
- tyapi_redis
|
||||
- tyapi_etcd
|
||||
- tyapi_sentinel
|
||||
networks:
|
||||
- tyapi_network
|
||||
restart: always
|
||||
|
Loading…
Reference in New Issue
Block a user