fix(api): 修正导出接口中用户ID参数获取逻辑
- 优先从请求参数中获取 current_user_id - 若 current_user_id 为空则退回获取 userId - 保证查询用户导出任务时使用正确的用户ID参数 - 提升接口的兼容性和灵活性
This commit is contained in:
parent
f10dff016f
commit
b09865fcbd
|
|
@ -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)
|
owner := uint64(0)
|
||||||
if uidStr := r.URL.Query().Get("userId"); uidStr != "" {
|
ownStr := r.URL.Query().Get("current_user_id")
|
||||||
first := strings.TrimSpace(strings.Split(uidStr, ",")[0])
|
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 {
|
if n, err := strconv.ParseUint(first, 10, 64); err == nil {
|
||||||
owner = n
|
owner = n
|
||||||
}
|
}
|
||||||
|
|
@ -1455,7 +1459,10 @@ func (a *ExportsAPI) list(w http.ResponseWriter, r *http.Request) {
|
||||||
offset := (page - 1) * size
|
offset := (page - 1) * size
|
||||||
rrepo := repo.NewExportRepo()
|
rrepo := repo.NewExportRepo()
|
||||||
var totalCount int64
|
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)
|
totalCount = rrepo.CountJobs(a.meta, tplID, uidStr)
|
||||||
itemsRaw, err := rrepo.ListJobs(a.meta, tplID, uidStr, size, offset)
|
itemsRaw, err := rrepo.ListJobs(a.meta, tplID, uidStr, size, offset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue