refactor(conf): 删除未使用的配置项

- 移除了 conf/app.conf 中的 [gateway2]配置节
- 删除了 internal/config/config.go 中的 GetGateway2 和 GetRechargeTMall 函数
- 在 internal/utils/client/client.go 和 internal/integrations/scan_shop.go 中添加了请求超时设置
This commit is contained in:
danial
2025-02-23 19:33:06 +08:00
parent eb1ec0cee0
commit a49e73bf33
6 changed files with 5 additions and 33 deletions

View File

@@ -24,9 +24,6 @@ db = 0
[gateway] [gateway]
url = http://127.0.0.1:12309 url = http://127.0.0.1:12309
[gateway2]
url = http://127.0.0.1:12401
[partial] [partial]
url = http://127.0.0.1:12310 url = http://127.0.0.1:12310

View File

@@ -17,14 +17,6 @@ func GetMMValue() (gUrl string) {
return fmt.Sprintf("%s/gateway/getAllowedMM", GetGateway()) return fmt.Sprintf("%s/gateway/getAllowedMM", GetGateway())
} }
func GetGateway2() (url string) {
url, err := web.AppConfig.String("gateway2::url")
if err != nil {
url = "http://localhost:12401"
}
return
}
func GetPartialUrl() (url string) { func GetPartialUrl() (url string) {
url, err := web.AppConfig.String("partial::url") url, err := web.AppConfig.String("partial::url")
if err != nil { if err != nil {
@@ -32,7 +24,3 @@ func GetPartialUrl() (url string) {
} }
return return
} }
func GetRechargeTMall() string {
return fmt.Sprintf("%s/api/recharge/tMallGame/account/getOneByRandom", GetGateway2())
}

View File

@@ -62,7 +62,9 @@ func (c *ScanShopController) Shop(ctx context.Context, requestHost, payKey strin
sign := utils.GetMD5SignMF(c.Params, merchantInfo.MerchantSecret) sign := utils.GetMD5SignMF(c.Params, merchantInfo.MerchantSecret)
c.Params["sign"] = sign c.Params["sign"] = sign
logs.Info(reqUrl, c.Params) logs.Info(reqUrl, c.Params)
//添加超时时间
req := httplib.NewBeegoRequestWithCtx(ctx, reqUrl, "POST") req := httplib.NewBeegoRequestWithCtx(ctx, reqUrl, "POST")
req.SetTimeout(30*time.Second, 30*time.Second)
req.SetTransport(otelhttp.NewTransport(http.DefaultTransport)) req.SetTransport(otelhttp.NewTransport(http.DefaultTransport))
for k, v := range c.Params { for k, v := range c.Params {
req.Param(k, v) req.Param(k, v)

View File

@@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"shop/internal/traceRouter" "shop/internal/traceRouter"
"time"
"github.com/beego/beego/v2/client/httplib" "github.com/beego/beego/v2/client/httplib"
"github.com/beego/beego/v2/core/logs" "github.com/beego/beego/v2/core/logs"
@@ -40,6 +41,7 @@ func Get(ctx context.Context, baseUrl string, params map[string]string) (result
req.Header.Set("tokenFrom", "iframe") req.Header.Set("tokenFrom", "iframe")
//设置trace //设置trace
client := http.Client{} client := http.Client{}
client.Timeout = time.Second * 30
otel.GetTextMapPropagator().Inject(ctx, propagation.HeaderCarrier(req.Header)) otel.GetTextMapPropagator().Inject(ctx, propagation.HeaderCarrier(req.Header))
resp, err := client.Do(req) resp, err := client.Do(req)
if resp != nil { if resp != nil {
@@ -66,6 +68,7 @@ func Post(ctx context.Context, baseUrl string, params map[string]string, data ma
realUrl.RawQuery = urlParams.Encode() realUrl.RawQuery = urlParams.Encode()
req := httplib.NewBeegoRequestWithCtx(ctx, realUrl.String(), "POST") req := httplib.NewBeegoRequestWithCtx(ctx, realUrl.String(), "POST")
otel.GetTextMapPropagator().Inject(ctx, propagation.HeaderCarrier(req.GetRequest().Header)) otel.GetTextMapPropagator().Inject(ctx, propagation.HeaderCarrier(req.GetRequest().Header))
req.SetTimeout(30*time.Second, 30*time.Second)
_, _ = req.JSONBody(data) _, _ = req.JSONBody(data)
response, err := req.String() response, err := req.String()
return response, err return response, err

View File

@@ -1,12 +1,3 @@
/***************************************************
** @Desc : This file for ...
** @Time : 2019/8/21 10:21
** @Author : yuebin
** @File : date_time
** @Last Modified by : yuebin
** @Last Modified time: 2019/8/21 10:21
** @Software: GoLand
****************************************************/
package utils package utils
import "time" import "time"

View File

@@ -1,12 +1,3 @@
/***************************************************
** @Desc : generate login verify code image
** @Time : 2019/8/7 17:14
** @Author : yuebin
** @File : login_verify_code
** @Last Modified by : yuebin
** @Last Modified time: 2019/8/7 17:14
** @Software: GoLand
****************************************************/
package utils package utils
import ( import (