Merge remote-tracking branch 'origin/dev未优化' into dev未优化

This commit is contained in:
WangLiZhao
2026-07-01 15:54:11 +08:00
2 changed files with 7 additions and 11 deletions
+1 -1
View File
@@ -148,7 +148,7 @@ func ExtractRequestBilling(ctx context.Context, config map[string]any, requestPa
if len(urls) > 0 { if len(urls) > 0 {
resp, err := gateway.GetVideoDuration(ctx, urls) resp, err := gateway.GetVideoDuration(ctx, urls)
if err == nil { if err == nil {
data[targetField] = resp.Data.TotalDuration data[targetField] = resp.TotalDuration
} }
} }
} }
+6 -10
View File
@@ -182,14 +182,10 @@ func IsSuperAdmin(ctx context.Context) (res bool, err error) {
// VideoDurationResp 视频时长接口返回 // VideoDurationResp 视频时长接口返回
type VideoDurationResp struct { type VideoDurationResp struct {
Code int `json:"code"` Videos []VideoInfo `json:"videos"`
Message string `json:"message"` Count int `json:"count"`
Data struct { TotalDuration float64 `json:"totalDuration"`
Videos []VideoInfo `json:"videos"` TotalDurationStr string `json:"totalDurationStr"`
Count int `json:"count"`
TotalDuration float64 `json:"totalDuration"` // 秒
TotalDurationStr string `json:"totalDurationStr"`
} `json:"data"`
} }
type VideoInfo struct { type VideoInfo struct {
@@ -201,7 +197,7 @@ type VideoInfo struct {
// GetVideoDuration 获取视频时长 // GetVideoDuration 获取视频时长
func GetVideoDuration(ctx context.Context, urls []string) (VideoDurationResp, error) { func GetVideoDuration(ctx context.Context, urls []string) (VideoDurationResp, error) {
apiURL := "medi/video/duration" apiURL := "media/video/duration"
headers := make(map[string]string) headers := make(map[string]string)
if r := g.RequestFromCtx(ctx); r != nil { if r := g.RequestFromCtx(ctx); r != nil {
for k, v := range r.Request.Header { for k, v := range r.Request.Header {
@@ -221,7 +217,7 @@ func GetVideoDuration(ctx context.Context, urls []string) (VideoDurationResp, er
return resp, err 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 return resp, nil
} }