团队管理设置
This commit is contained in:
@@ -14,6 +14,7 @@ import type {
|
||||
VideoPromptSchemaPreviewPayload, VideoPromptSchemaPreviewOut, VideoPromptSchemaExportOut,
|
||||
AdminCreditRecordListResponse, AdminCreditRecordQueryParams,
|
||||
ResourceCapacityConfigOut, ResourceCapacityConfigPayload, AdminUserResourceCapacityOut,
|
||||
AdminTeam, AdminTeamListResponse, AdminTeamOption, AdminTeamPayload, AdminTeamQueryParams,
|
||||
} from '../types';
|
||||
|
||||
// ── Auth ──────────────────────────────────────────────────
|
||||
@@ -107,6 +108,7 @@ export async function getAdminUsers(
|
||||
search?: string,
|
||||
userType?: string,
|
||||
frontendUserKind?: string,
|
||||
teamId?: string,
|
||||
): Promise<{ items: AdminUser[]; total: number }> {
|
||||
const params = new URLSearchParams();
|
||||
params.set('page', String(page));
|
||||
@@ -114,6 +116,7 @@ export async function getAdminUsers(
|
||||
if (search) params.set('search', search);
|
||||
if (userType) params.set('user_type', userType);
|
||||
if (frontendUserKind) params.set('frontend_user_kind', frontendUserKind);
|
||||
if (teamId) params.set('team_id', teamId);
|
||||
return api.get(`/admin/users?${params.toString()}`);
|
||||
}
|
||||
|
||||
@@ -121,6 +124,40 @@ export async function updateFrontendUserKind(userId: string, frontendUserKind: '
|
||||
return api.put(`/admin/users/${userId}/frontend-kind`, { frontend_user_kind: frontendUserKind });
|
||||
}
|
||||
|
||||
export async function updateUserTeam(userId: string, teamId: string | null): Promise<AdminUser> {
|
||||
return api.put(`/admin/users/${userId}/team`, { team_id: teamId });
|
||||
}
|
||||
|
||||
export async function getAdminTeams(filters?: AdminTeamQueryParams): Promise<AdminTeamListResponse> {
|
||||
const params = new URLSearchParams();
|
||||
setMaybe(params, 'page', filters?.page);
|
||||
setMaybe(params, 'page_size', filters?.pageSize);
|
||||
setMaybe(params, 'keyword', filters?.keyword);
|
||||
setMaybe(params, 'status', filters?.status);
|
||||
const q = params.toString() ? `?${params}` : '';
|
||||
return api.get(`/admin/teams${q}`);
|
||||
}
|
||||
|
||||
export async function getTeamOptions(includeDisabled = true): Promise<AdminTeamOption[]> {
|
||||
return api.get(`/admin/teams/options?include_disabled=${includeDisabled ? 'true' : 'false'}`);
|
||||
}
|
||||
|
||||
export async function saveAdminTeam(team: Partial<AdminTeamPayload> & { id?: string }): Promise<AdminTeam> {
|
||||
const payload = {
|
||||
name: team.name,
|
||||
code: team.code || null,
|
||||
description: team.description || null,
|
||||
status: team.status || 'active',
|
||||
sort_order: team.sort_order ?? 0,
|
||||
};
|
||||
if (team.id) return api.put(`/admin/teams/${team.id}`, payload);
|
||||
return api.post('/admin/teams', payload);
|
||||
}
|
||||
|
||||
export async function deleteAdminTeam(id: string): Promise<void> {
|
||||
await api.delete(`/admin/teams/${id}`);
|
||||
}
|
||||
|
||||
export async function adjustCredits(userId: string, amount: number, description: string): Promise<void> {
|
||||
await api.post(`/admin/users/${userId}/credits`, { amount, description });
|
||||
}
|
||||
@@ -225,6 +262,7 @@ export async function getCreditRecords(filters?: AdminCreditRecordQueryParams):
|
||||
setMaybe(params, 'user_name', filters?.userName);
|
||||
setMaybe(params, 'user_type', filters?.userType);
|
||||
setMaybe(params, 'frontend_user_kind', filters?.frontendUserKind);
|
||||
setMaybe(params, 'team_id', filters?.teamId);
|
||||
setMaybe(params, 'record_type', filters?.recordType || filters?.type);
|
||||
setMaybe(params, 'credit_subject', filters?.creditSubject);
|
||||
setMaybe(params, 'media_type', filters?.mediaType);
|
||||
|
||||
Reference in New Issue
Block a user