fix(admin): workspace_billing_history user column + rbac listUsers pagination params order

This commit is contained in:
ZhenYi 2026-04-22 20:53:22 +08:00
parent 623faf8c55
commit c41f4efc04
2 changed files with 7 additions and 10 deletions

View File

@ -66,7 +66,7 @@ export async function POST(
// Insert billing history
await client.query(
`INSERT INTO workspace_billing_history
(workspace_id, user, amount, reason, extra, currency)
(workspace_id, user_id, amount, reason, extra, currency)
VALUES ($1, NULL, $2, 'admin_credit', $3, $4)`,
[id, amount, JSON.stringify({ description: description || "Admin 手动充值" }), currency]
);

View File

@ -201,15 +201,12 @@ export async function listUsers(
const pageSize = options.pageSize ?? 20;
const offset = (page - 1) * pageSize;
const params: unknown[] = [pageSize, offset];
let whereClause = "";
let paramIdx = 3;
if (options.search) {
whereClause = `WHERE username ILIKE $1`;
params.unshift(`%${options.search}%`);
paramIdx = 3;
}
const params: unknown[] = [
...(options.search ? [`%${options.search}%`] : []),
pageSize,
offset,
];
const whereClause = options.search ? `WHERE username ILIKE $1` : "";
const countParams = options.search ? [`%${options.search}%`] : [];
const countResult = await query<{ count: string }>(