From 3ca8f937789c093358526b7364c142466f7f5156 Mon Sep 17 00:00:00 2001 From: qhd <1766646056@qq.com> Date: Wed, 1 Jul 2026 15:53:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E6=8E=A5=E5=8F=A3=E5=93=8D=E5=BA=94=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E5=8F=8AURL=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除VideoDurationResp中多余的嵌套Data字段,直接访问TotalDuration等属性; 修正API路径中缺失的字母a(medi -> media)。 --- common/util/billing.go | 2 +- service/gateway/gateway_http_service.go | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/common/util/billing.go b/common/util/billing.go index baf6975..485f5ce 100644 --- a/common/util/billing.go +++ b/common/util/billing.go @@ -148,7 +148,7 @@ func ExtractRequestBilling(ctx context.Context, config map[string]any, requestPa if len(urls) > 0 { resp, err := gateway.GetVideoDuration(ctx, urls) if err == nil { - data[targetField] = resp.Data.TotalDuration + data[targetField] = resp.TotalDuration } } } diff --git a/service/gateway/gateway_http_service.go b/service/gateway/gateway_http_service.go index 24a2e9e..db67b7e 100644 --- a/service/gateway/gateway_http_service.go +++ b/service/gateway/gateway_http_service.go @@ -180,14 +180,10 @@ func IsSuperAdmin(ctx context.Context) (res bool, err error) { // VideoDurationResp 视频时长接口返回 type VideoDurationResp struct { - Code int `json:"code"` - Message string `json:"message"` - Data struct { - Videos []VideoInfo `json:"videos"` - Count int `json:"count"` - TotalDuration float64 `json:"totalDuration"` // 秒 - TotalDurationStr string `json:"totalDurationStr"` - } `json:"data"` + Videos []VideoInfo `json:"videos"` + Count int `json:"count"` + TotalDuration float64 `json:"totalDuration"` + TotalDurationStr string `json:"totalDurationStr"` } type VideoInfo struct { @@ -199,7 +195,7 @@ type VideoInfo struct { // GetVideoDuration 获取视频时长 func GetVideoDuration(ctx context.Context, urls []string) (VideoDurationResp, error) { - apiURL := "medi/video/duration" + apiURL := "media/video/duration" headers := make(map[string]string) if r := g.RequestFromCtx(ctx); r != nil { for k, v := range r.Request.Header { @@ -219,7 +215,7 @@ func GetVideoDuration(ctx context.Context, urls []string) (VideoDurationResp, er return resp, err } - g.Log().Infof(ctx, "[视频时长] 获取成功 count=%d totalDuration=%.2f", resp.Data.Count, resp.Data.TotalDuration) + g.Log().Infof(ctx, "[视频时长] 获取成功 count=%d totalDuration=%.2f", resp.Count, resp.TotalDuration) return resp, nil }