From b09865fcbdcff0fc76de18a43a92bd66f58048f3 Mon Sep 17 00:00:00 2001 From: zhouyonggao <1971162852@qq.com> Date: Thu, 18 Dec 2025 21:09:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=E4=BF=AE=E6=AD=A3=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=8E=A5=E5=8F=A3=E4=B8=AD=E7=94=A8=E6=88=B7ID?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优先从请求参数中获取 current_user_id - 若 current_user_id 为空则退回获取 userId - 保证查询用户导出任务时使用正确的用户ID参数 - 提升接口的兼容性和灵活性 --- server/internal/api/exports.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/internal/api/exports.go b/server/internal/api/exports.go index 53916e1..ebf964a 100644 --- a/server/internal/api/exports.go +++ b/server/internal/api/exports.go @@ -342,10 +342,14 @@ func (a *ExportsAPI) create(w http.ResponseWriter, r *http.Request) { } } } - // owner from query userId if provided + // owner from query current_user_id or userId if provided owner := uint64(0) - if uidStr := r.URL.Query().Get("userId"); uidStr != "" { - first := strings.TrimSpace(strings.Split(uidStr, ",")[0]) + ownStr := r.URL.Query().Get("current_user_id") + if ownStr == "" { + ownStr = r.URL.Query().Get("userId") + } + if ownStr != "" { + first := strings.TrimSpace(strings.Split(ownStr, ",")[0]) if n, err := strconv.ParseUint(first, 10, 64); err == nil { owner = n } @@ -1455,7 +1459,10 @@ func (a *ExportsAPI) list(w http.ResponseWriter, r *http.Request) { offset := (page - 1) * size rrepo := repo.NewExportRepo() var totalCount int64 - uidStr := q.Get("userId") + uidStr := q.Get("current_user_id") + if uidStr == "" { + uidStr = q.Get("userId") + } totalCount = rrepo.CountJobs(a.meta, tplID, uidStr) itemsRaw, err := rrepo.ListJobs(a.meta, tplID, uidStr, size, offset) if err != nil {