Merge branch 'dev' into hugo-shipping-notice
This commit is contained in:
commit
a31735b689
47 files changed
+1931
-716
No files matched your search
@@ -7,7 +7,7 @@ import { requestJson } from '@/shared/api/client';
|
||||
import type { AdminUserRow } from '../types/admin.types';
|
||||
import type { AdminDashboardBadges, AdminDashboardSummary } from '../types/dashboard.types';
|
||||
import type { PaginatedResult } from '@/shared/types/pagination.types';
|
||||
import type { UsageReport } from '../types/report.types';
|
||||
import type { UsageReport, UsageRangeKey } from '../types/report.types';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getAuthHeaders() } });
|
||||
@@ -27,11 +27,15 @@ export interface ListAdminUsersPageParams {
|
||||
employee_id?: string;
|
||||
phone_number?: string;
|
||||
hideRejected?: boolean;
|
||||
/** 排序列:username | department */
|
||||
sortBy?: 'username' | 'department';
|
||||
/** 排序方向 */
|
||||
sortDir?: 'asc' | 'desc';
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页拉取用户列表(服务端筛选 + 分页,供用户管理页使用)。
|
||||
* @param params - 页码、每页条数与各字段模糊筛选
|
||||
* 分页拉取用户列表(服务端筛选 + 分页 + 排序,供用户管理页使用)。
|
||||
* @param params - 页码、每页条数、字段模糊筛选与 sortBy/sortDir
|
||||
*/
|
||||
export const listAdminUsersPage = (params: ListAdminUsersPageParams) => {
|
||||
const qs = new URLSearchParams();
|
||||
@@ -53,6 +57,8 @@ export const listAdminUsersPage = (params: ListAdminUsersPageParams) => {
|
||||
if (value) qs.set(queryKey, value);
|
||||
}
|
||||
if (params.hideRejected) qs.set('hide_rejected', 'true');
|
||||
if (params.sortBy) qs.set('sort_by', params.sortBy);
|
||||
if (params.sortDir) qs.set('sort_dir', params.sortDir);
|
||||
return requestJson<PaginatedResult<AdminUserRow>>(`/api/admin/users?${qs.toString()}`, auth());
|
||||
};
|
||||
export const createAdminUser = (payload: Record<string, unknown>) =>
|
||||
@@ -254,12 +260,15 @@ export const getAdminDashboardBadges = () =>
|
||||
export interface AdminUsageReportParams {
|
||||
user_page?: number;
|
||||
user_page_size?: number;
|
||||
/** 时间范围:7d | 30d | 90d | 180d | 365d */
|
||||
range?: UsageRangeKey;
|
||||
}
|
||||
|
||||
export const getAdminUsageReport = (params: AdminUsageReportParams = {}) => {
|
||||
const qs = new URLSearchParams();
|
||||
if (params.user_page != null) qs.set('user_page', String(params.user_page));
|
||||
if (params.user_page_size != null) qs.set('user_page_size', String(params.user_page_size));
|
||||
if (params.range) qs.set('range', params.range);
|
||||
const query = qs.toString();
|
||||
return requestJson<UsageReport>(
|
||||
`/api/admin/reports/usage${query ? `?${query}` : ''}`,
|
||||
|
||||
Reference in new issue
Block a user