feat(后台用户): 用户列表按班级看、「重置密码」常驻;批量建号粘进名单当场列出会建成的账号,重名和已有的先点出来,建好能下载名单、打印账号条
用户列表去掉 ID、真名、占位邮箱和四颗彩色按钮。下载的名单开头带 BOM,Excel 打开中文不再乱码。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba823ecb7d
commit
5561e0bc3a
5 files changed
+607
-158
No files matched your search
@@ -51,6 +51,7 @@ import type {
|
||||
GenerateTestInputsRequest,
|
||||
GenerateTestInputsResponse,
|
||||
TestCaseFiles,
|
||||
CheckUsernamesResponse,
|
||||
} from "@oj2/contract"
|
||||
|
||||
export function getBaseInfo() {
|
||||
@@ -182,7 +183,15 @@ export function getAdminUserRank(offset: number, limit: number, keyword: string)
|
||||
}
|
||||
|
||||
// 用户列表
|
||||
export function getUserList(offset = 0, limit = 10, type = "", keyword: string, orderBy = "") {
|
||||
export function getUserList(
|
||||
offset = 0,
|
||||
limit = 10,
|
||||
type = "",
|
||||
keyword: string,
|
||||
orderBy = "",
|
||||
/** 班级,NO_CLASS 是「没填班级」 */
|
||||
className = "",
|
||||
) {
|
||||
return api.get<AdminUserList>("admin/users", {
|
||||
// "-last_login" 是旧接口传下来的取值(路由 query 里可能还存着),改叫 "-lastLogin";
|
||||
// "-online" 是新增的,原样透传
|
||||
@@ -192,10 +201,16 @@ export function getUserList(offset = 0, limit = 10, type = "", keyword: string,
|
||||
keyword,
|
||||
type,
|
||||
orderBy: orderBy === "-last_login" ? "-lastLogin" : orderBy,
|
||||
className: className || undefined,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/** 批量建号之前查重:这些用户名哪些已经有了 */
|
||||
export function checkUsernames(usernames: string[]) {
|
||||
return api.post<CheckUsernamesResponse>("admin/users/check", { usernames })
|
||||
}
|
||||
|
||||
// 编辑用户
|
||||
export function editUser(user: AdminUserForm) {
|
||||
return api.put<AdminUser>(`admin/users/${user.id}`, {
|
||||
@@ -216,8 +231,9 @@ export async function resetPassword(userID: number) {
|
||||
}
|
||||
|
||||
// 导入用户
|
||||
/** 批量建号。addedClasses:这批里的新班级,后端已经顺手加进了班级列表 */
|
||||
export function importUsers(users: string[][]) {
|
||||
return api.post("admin/users", { users })
|
||||
return api.post<{ imported: number; addedClasses: string[] }>("admin/users", { users })
|
||||
}
|
||||
|
||||
// 批量删除用户
|
||||
|
||||
Reference in new issue
Block a user