超管后台 - 编辑管理员查看详情

This commit is contained in:
柳清爽
2025-04-10 09:30:16 +08:00
parent d33988aa4e
commit 3cf0ee2bcb
6 changed files with 231 additions and 135 deletions

View File

@@ -12,6 +12,19 @@ export interface Administrator {
permissions: string[];
}
// 管理员详情接口
export interface AdministratorDetail {
id: number;
username: string;
name: string;
authId: number;
roleName: string;
status: number;
createdAt: string;
lastLogin: string;
permissions: string[];
}
// 分页响应数据类型
export interface PaginatedResponse<T> {
list: T[];
@@ -71,4 +84,36 @@ export async function getAdministrators(
data: null
};
}
}
/**
* 获取管理员详情
* @param id 管理员ID
* @returns 管理员详情
*/
export async function getAdministratorDetail(id: number | string): Promise<ApiResponse<AdministratorDetail>> {
const { apiBaseUrl } = getConfig();
try {
// 发送请求
const response = await fetch(`${apiBaseUrl}/administrator/detail/${id}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
if (!response.ok) {
throw new Error(`请求失败,状态码: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error('获取管理员详情失败:', error);
return {
code: 500,
msg: '获取管理员详情失败',
data: null
};
}
}