fix(api): 修正导出接口中用户ID参数获取逻辑

- 优先从请求参数中获取 current_user_id
- 若 current_user_id 为空则退回获取 userId
- 保证查询用户导出任务时使用正确的用户ID参数
- 提升接口的兼容性和灵活性
This commit is contained in:
zhouyonggao 2025-12-18 21:09:12 +08:00
parent f10dff016f
commit b09865fcbd
1 changed files with 11 additions and 4 deletions

View File

@ -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 {