diff --git a/src/admin/api.ts b/src/admin/api.ts index fe34e5b..403102c 100644 --- a/src/admin/api.ts +++ b/src/admin/api.ts @@ -2,6 +2,7 @@ import http from "utils/http" import { toProblemListItem } from "admin/transforms" import type { AdminProblem, + AdminTag, Announcement, AnnouncementEdit, BlankContest, @@ -84,6 +85,35 @@ export function getContestProblem(id: number) { return http.get("admin/contest/problem", { params: { id } }) } +// 标签管理 +export function getTagAdminList(keyword = "") { + return http.get("admin/problem/tag", { params: { keyword } }) +} + +export function renameTag(id: number, name: string) { + return http.put<{ + merged: boolean + id: number + name: string + affected_count: number + }>("admin/problem/tag", { id, name }) +} + +export function deleteTag(id: number) { + return http.delete("admin/problem/tag", { params: { id } }) +} + +export function batchTagProblems( + problemIds: number[], + tagNames: string[], + action: "add" | "remove", +) { + return http.post<{ problem_count: number; tag_count: number }>( + "admin/problem/batch_tag", + { problem_ids: problemIds, tag_names: tagNames, action }, + ) +} + // 用户列表 export function getUserList( offset = 0, diff --git a/src/utils/types.ts b/src/utils/types.ts index c3bf56f..20feef3 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -104,6 +104,12 @@ export interface Tag { name: string } +export interface AdminTag { + id: number + name: string + problem_count: number +} + export interface TestcaseUploadedReturns { id: string info: Testcase[]