feat: 对接用户管理相关接口字段
This commit is contained in:
+34
-19
@@ -6,48 +6,63 @@ import { USE_MOCK, MOCK_DELAY } from '@/config/mock';
|
||||
import { buildMockUserListPage } from '@/config/mock/userList';
|
||||
import type {
|
||||
UserListQueryParams,
|
||||
UserSaveParams,
|
||||
UserUpdateParams,
|
||||
UserActiveParams,
|
||||
TournamentAdminUserPageVO,
|
||||
UserUpdatePwdParams,
|
||||
TournamentAdminUserVO,
|
||||
PageData,
|
||||
ApiResult,
|
||||
} from './types';
|
||||
|
||||
export type {
|
||||
TournamentAdminUserPageVO,
|
||||
TournamentAdminUserVO,
|
||||
UserListQueryParams,
|
||||
UserSaveParams,
|
||||
UserUpdateParams,
|
||||
UserActiveParams,
|
||||
UserUpdatePwdParams,
|
||||
PageData,
|
||||
ApiResult,
|
||||
} from './types';
|
||||
|
||||
const delay = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms));
|
||||
const delay = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));
|
||||
|
||||
/**
|
||||
* 用户管理 - 用户分页
|
||||
* GET /admin/manager/user/page → /manager/user/page
|
||||
*/
|
||||
/** GET /sys/user/page — 用户分页 */
|
||||
export async function getUserList(
|
||||
params: UserListQueryParams,
|
||||
): Promise<ApiResult<PageData<TournamentAdminUserPageVO>>> {
|
||||
): Promise<ApiResult<PageData<TournamentAdminUserVO>>> {
|
||||
if (USE_MOCK) {
|
||||
await delay(MOCK_DELAY);
|
||||
const page = Number(params.page) || 1;
|
||||
const limit = Number(params.limit) || 10;
|
||||
return {
|
||||
code: 200,
|
||||
msg: 'success',
|
||||
data: buildMockUserListPage(page, limit),
|
||||
};
|
||||
return { code: 200, msg: 'success', data: buildMockUserListPage(page, limit) };
|
||||
}
|
||||
return get('/manager/user/page', params as Record<string, any>);
|
||||
return get('/sys/user/page', params as Record<string, any>);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户管理 - 启用/禁用
|
||||
* POST /admin/manager/user/active → /manager/user/active
|
||||
*/
|
||||
/** POST /sys/user/save — 新增用户 */
|
||||
export function saveUser(params: UserSaveParams): Promise<ApiResult<Record<string, never>>> {
|
||||
if (USE_MOCK) return delay(MOCK_DELAY).then(() => ({ code: 200, msg: 'success', data: {} }));
|
||||
return post('/sys/user/save', params);
|
||||
}
|
||||
|
||||
/** POST /sys/user/update — 更新用户 */
|
||||
export function updateUser(params: UserUpdateParams): Promise<ApiResult<Record<string, never>>> {
|
||||
if (USE_MOCK) return delay(MOCK_DELAY).then(() => ({ code: 200, msg: 'success', data: {} }));
|
||||
return post('/sys/user/update', params);
|
||||
}
|
||||
|
||||
/** POST /sys/user/active — 启用/禁用(直接调接口) */
|
||||
export function toggleUserActive(
|
||||
params: UserActiveParams,
|
||||
): Promise<ApiResult<Record<string, never>>> {
|
||||
return post('/manager/user/active', params);
|
||||
return post('/sys/user/active', params);
|
||||
}
|
||||
|
||||
/** POST /sys/user/updatepwd — 修改密码(直接调接口) */
|
||||
export function updateUserPwd(
|
||||
params: UserUpdatePwdParams,
|
||||
): Promise<ApiResult<Record<string, never>>> {
|
||||
return post('/sys/user/updatepwd', params);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user