feat: add superadmin user library detail

This commit is contained in:
2026-01-15 16:17:32 +08:00
parent 339fd4fb1d
commit c8ec0af07f
10 changed files with 1104 additions and 10 deletions

View File

@@ -186,6 +186,45 @@ export const UserService = {
items: normalizeItems(data?.items)
};
},
async listUserLibrary(userID, { page, limit, tenant_id, tenant_code, tenant_name, content_id, keyword, status, order_id, order_status, paid_at_from, paid_at_to, accessed_at_from, accessed_at_to, sortField, sortOrder } = {}) {
if (!userID) throw new Error('userID is required');
const iso = (d) => {
if (!d) return undefined;
const date = d instanceof Date ? d : new Date(d);
if (Number.isNaN(date.getTime())) return undefined;
return date.toISOString();
};
const query = {
page,
limit,
tenant_id,
tenant_code,
tenant_name,
content_id,
keyword,
status,
order_id,
order_status,
paid_at_from: iso(paid_at_from),
paid_at_to: iso(paid_at_to),
accessed_at_from: iso(accessed_at_from),
accessed_at_to: iso(accessed_at_to)
};
if (sortField && sortOrder) {
if (sortOrder === 1) query.asc = sortField;
if (sortOrder === -1) query.desc = sortField;
}
const data = await requestJson(`/super/v1/users/${userID}/library`, { query });
return {
page: data?.page ?? page ?? 1,
limit: data?.limit ?? limit ?? 10,
total: data?.total ?? 0,
items: normalizeItems(data?.items)
};
},
async listUserFollowing(userID, { page, limit, tenant_id, code, name, status, created_at_from, created_at_to, sortField, sortOrder } = {}) {
if (!userID) throw new Error('userID is required');