feat: ✨ 添加用户管理页
This commit is contained in:
54
frontend/src/services/adminUsersService.ts
Normal file
54
frontend/src/services/adminUsersService.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import api from '../utils/api';
|
||||
|
||||
export enum AdminRole {
|
||||
SUPER_ADMIN = 'super_admin',
|
||||
OPERATOR = 'operator',
|
||||
VIEWER = 'viewer',
|
||||
}
|
||||
|
||||
export interface AdminUser {
|
||||
id: number;
|
||||
username: string;
|
||||
role: AdminRole;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface CreateAdminUserDto {
|
||||
username: string;
|
||||
password: string;
|
||||
role: AdminRole;
|
||||
}
|
||||
|
||||
export interface UpdateAdminUserDto {
|
||||
username?: string;
|
||||
password?: string;
|
||||
role?: AdminRole;
|
||||
}
|
||||
|
||||
export const adminUsersService = {
|
||||
async findAll(): Promise<AdminUser[]> {
|
||||
const response = await api.get<AdminUser[]>('/admin/admin-users');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async findOne(id: number): Promise<AdminUser> {
|
||||
const response = await api.get<AdminUser>(`/admin/admin-users/${id}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async create(data: CreateAdminUserDto): Promise<AdminUser> {
|
||||
const response = await api.post<AdminUser>('/admin/admin-users', data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async update(id: number, data: UpdateAdminUserDto): Promise<AdminUser> {
|
||||
const response = await api.put<AdminUser>(`/admin/admin-users/${id}`, data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async remove(id: number): Promise<{ message: string }> {
|
||||
const response = await api.delete<{ message: string }>(`/admin/admin-users/${id}`);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user