From ed340b60984ee8e0e0e4c4a11b63050919792c04 Mon Sep 17 00:00:00 2001 From: GZTime Date: Mon, 17 Jul 2023 11:26:37 +0800 Subject: [PATCH] feat(frontend): update api client --- src/GZCTF/ClientApp/package.json | 2 +- src/GZCTF/ClientApp/src/Api.ts | 3040 +++++++++--------- src/GZCTF/ClientApp/template/http-client.eta | 86 +- 3 files changed, 1570 insertions(+), 1558 deletions(-) diff --git a/src/GZCTF/ClientApp/package.json b/src/GZCTF/ClientApp/package.json index a3e0b0b7f..79f304c37 100644 --- a/src/GZCTF/ClientApp/package.json +++ b/src/GZCTF/ClientApp/package.json @@ -8,7 +8,7 @@ "build": "tsc && vite build", "preview": "vite preview", "prettier": "prettier --write src", - "genapi": "swagger-typescript-api -p template/swagger.json -t template -o src --module-name-first-tag" + "genapi": "swagger-typescript-api -p template/swagger.json -t template -o src --module-name-first-tag --sort-routes" }, "dependencies": { "@babel/core": "^7.22.9", diff --git a/src/GZCTF/ClientApp/src/Api.ts b/src/GZCTF/ClientApp/src/Api.ts index cc8c645ad..fc8e5eabf 100644 --- a/src/GZCTF/ClientApp/src/Api.ts +++ b/src/GZCTF/ClientApp/src/Api.ts @@ -9,8 +9,15 @@ * --------------------------------------------------------------- */ -import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, ResponseType } from 'axios' -import useSWR, { mutate, MutatorOptions, SWRConfiguration } from 'swr' +import type { + AxiosInstance, + AxiosRequestConfig, + AxiosResponse, + HeadersDefaults, + ResponseType, +} from 'axios' +import axios from 'axios' +import useSWR, { MutatorOptions, SWRConfiguration, mutate } from 'swr' /** 请求响应 */ export interface RequestResponseOfRegisterStatus { @@ -150,7 +157,7 @@ export interface ProfileUpdateModel { realName?: string | null /** * 学工号 - * @maxLength 15 + * @maxLength 24 */ stdNumber?: string | null } @@ -443,12 +450,12 @@ export interface AdminUserInfoModel { phone?: string | null /** * 真实姓名 - * @maxLength 6 + * @maxLength 7 */ realName?: string | null /** * 学工号 - * @maxLength 10 + * @maxLength 24 */ stdNumber?: string | null /** 用户是否通过邮箱验证(可登录) */ @@ -1650,6 +1657,7 @@ export enum ContentType { Json = 'application/json', FormData = 'multipart/form-data', UrlEncoded = 'application/x-www-form-urlencoded', + Text = 'text/plain', } export class HttpClient { @@ -1675,47 +1683,44 @@ export class HttpClient { this.securityData = data } - private mergeRequestParams( + protected mergeRequestParams( params1: AxiosRequestConfig, params2?: AxiosRequestConfig ): AxiosRequestConfig { + const method = params1.method || (params2 && params2.method) + return { ...this.instance.defaults, ...params1, ...(params2 || {}), - headers: Object.assign( - {}, - this.instance.defaults.headers, - (params1 || {}).headers, - (params2 || {}).headers - ), + headers: { + ...((method && + this.instance.defaults.headers[method.toLowerCase() as keyof HeadersDefaults]) || + {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + } + } + + protected stringifyFormItem(formItem: unknown) { + if (typeof formItem === 'object' && formItem !== null) { + return JSON.stringify(formItem) + } else { + return `${formItem}` } } - private createFormData(input: Record): FormData { + protected createFormData(input: Record): FormData { return Object.keys(input || {}).reduce((formData, key) => { const property = input[key] - if (Array.isArray(property)) { - property.forEach((blob) => { - formData.append( - key, - blob instanceof Blob - ? blob - : typeof blob === 'object' && blob !== null - ? JSON.stringify(blob) - : `${blob}` - ) - }) - } else { - formData.append( - key, - property instanceof Blob - ? property - : typeof property === 'object' && property !== null - ? JSON.stringify(property) - : `${property}` - ) + const propertyContent: any[] = property instanceof Array ? property : [property] + + for (const formItem of propertyContent) { + const isFileType = formItem instanceof Blob || formItem instanceof File + formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem)) } + return formData }, new FormData()) } @@ -1735,21 +1740,22 @@ export class HttpClient { (await this.securityWorker(this.securityData))) || {} const requestParams = this.mergeRequestParams(params, secureParams) - const responseFormat = (format && this.format) || void 0 + const responseFormat = format || this.format || undefined if (type === ContentType.FormData && body && body !== null && typeof body === 'object') { - if (!requestParams.headers) requestParams.headers = { Accept: '*/*' } - body = this.createFormData(body as Record) } + if (type === ContentType.Text && body && body !== null && typeof body !== 'string') { + body = JSON.stringify(body) + } + return this.instance.request({ ...requestParams, - headers: Object.assign( - {}, - requestParams.headers, - type && type !== ContentType.FormData ? { 'Content-Type': type } : {} - ), + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}), + }, params: query, responseType: responseFormat, data: body, @@ -1767,35 +1773,41 @@ export class HttpClient { export class Api extends HttpClient { account = { /** - * @description 使用此接口注册新用户,Dev环境下不校验 GToken,邮件URL:/verify + * @description 使用此接口更新用户头像,需要User权限 * * @tags Account - * @name AccountRegister - * @summary 用户注册接口 - * @request POST:/api/account/register + * @name AccountAvatar + * @summary 更新用户头像接口 + * @request PUT:/api/account/avatar */ - accountRegister: (data: RegisterModel, params: RequestParams = {}) => - this.request({ - path: `/api/account/register`, - method: 'POST', + accountAvatar: ( + data: { + /** @format binary */ + file?: File + }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/account/avatar`, + method: 'PUT', body: data, - type: ContentType.Json, + type: ContentType.FormData, format: 'json', ...params, }), /** - * @description 使用此接口请求找回密码,向用户邮箱发送邮件,邮件URL:/reset + * @description 使用此接口更改用户邮箱,需要User权限,邮件URL:/confirm * * @tags Account - * @name AccountRecovery - * @summary 用户找回密码请求接口 - * @request POST:/api/account/recovery + * @name AccountChangeEmail + * @summary 用户邮箱更改接口 + * @request PUT:/api/account/changeemail */ - accountRecovery: (data: RecoveryModel, params: RequestParams = {}) => - this.request({ - path: `/api/account/recovery`, - method: 'POST', + accountChangeEmail: (data: MailChangeModel, params: RequestParams = {}) => + this.request({ + path: `/api/account/changeemail`, + method: 'PUT', body: data, type: ContentType.Json, format: 'json', @@ -1803,34 +1815,17 @@ export class Api extends HttpClient - this.request({ - path: `/api/account/passwordreset`, - method: 'POST', - body: data, - type: ContentType.Json, - ...params, - }), - - /** - * @description 使用此接口通过邮箱验证码确认邮箱 + * @description 使用此接口更新用户密码,需要User权限 * * @tags Account - * @name AccountVerify - * @summary 用户邮箱确认接口 - * @request POST:/api/account/verify + * @name AccountChangePassword + * @summary 用户密码更改接口 + * @request PUT:/api/account/changepassword */ - accountVerify: (data: AccountVerifyModel, params: RequestParams = {}) => + accountChangePassword: (data: PasswordChangeModel, params: RequestParams = {}) => this.request({ - path: `/api/account/verify`, - method: 'POST', + path: `/api/account/changepassword`, + method: 'PUT', body: data, type: ContentType.Json, ...params, @@ -1869,68 +1864,33 @@ export class Api extends HttpClient - this.request({ - path: `/api/account/update`, - method: 'PUT', - body: data, - type: ContentType.Json, - ...params, - }), - - /** - * @description 使用此接口更新用户密码,需要User权限 + * @description 使用此接口确认更改用户邮箱,需要邮箱验证码,需要User权限 * * @tags Account - * @name AccountChangePassword - * @summary 用户密码更改接口 - * @request PUT:/api/account/changepassword + * @name AccountMailChangeConfirm + * @summary 用户邮箱更改确认接口 + * @request POST:/api/account/mailchangeconfirm */ - accountChangePassword: (data: PasswordChangeModel, params: RequestParams = {}) => + accountMailChangeConfirm: (data: AccountVerifyModel, params: RequestParams = {}) => this.request({ - path: `/api/account/changepassword`, - method: 'PUT', - body: data, - type: ContentType.Json, - ...params, - }), - - /** - * @description 使用此接口更改用户邮箱,需要User权限,邮件URL:/confirm - * - * @tags Account - * @name AccountChangeEmail - * @summary 用户邮箱更改接口 - * @request PUT:/api/account/changeemail - */ - accountChangeEmail: (data: MailChangeModel, params: RequestParams = {}) => - this.request({ - path: `/api/account/changeemail`, - method: 'PUT', + path: `/api/account/mailchangeconfirm`, + method: 'POST', body: data, type: ContentType.Json, - format: 'json', ...params, }), /** - * @description 使用此接口确认更改用户邮箱,需要邮箱验证码,需要User权限 + * @description 使用此接口重置密码,需要邮箱验证码 * * @tags Account - * @name AccountMailChangeConfirm - * @summary 用户邮箱更改确认接口 - * @request POST:/api/account/mailchangeconfirm + * @name AccountPasswordReset + * @summary 用户重置密码接口 + * @request POST:/api/account/passwordreset */ - accountMailChangeConfirm: (data: AccountVerifyModel, params: RequestParams = {}) => + accountPasswordReset: (data: PasswordResetModel, params: RequestParams = {}) => this.request({ - path: `/api/account/mailchangeconfirm`, + path: `/api/account/passwordreset`, method: 'POST', body: data, type: ContentType.Json, @@ -1980,222 +1940,195 @@ export class Api extends HttpClient mutate(`/api/account/profile`, data, options), /** - * @description 使用此接口更新用户头像,需要User权限 + * @description 使用此接口请求找回密码,向用户邮箱发送邮件,邮件URL:/reset * * @tags Account - * @name AccountAvatar - * @summary 更新用户头像接口 - * @request PUT:/api/account/avatar + * @name AccountRecovery + * @summary 用户找回密码请求接口 + * @request POST:/api/account/recovery */ - accountAvatar: ( - data: { - /** @format binary */ - file?: File - }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/account/avatar`, - method: 'PUT', + accountRecovery: (data: RecoveryModel, params: RequestParams = {}) => + this.request({ + path: `/api/account/recovery`, + method: 'POST', body: data, - type: ContentType.FormData, + type: ContentType.Json, format: 'json', ...params, }), - } - admin = { + /** - * @description 使用此接口获取全局设置,需要Admin权限 + * @description 使用此接口注册新用户,Dev环境下不校验 GToken,邮件URL:/verify * - * @tags Admin - * @name AdminGetConfigs - * @summary 获取配置 - * @request GET:/api/admin/config + * @tags Account + * @name AccountRegister + * @summary 用户注册接口 + * @request POST:/api/account/register */ - adminGetConfigs: (params: RequestParams = {}) => - this.request({ - path: `/api/admin/config`, - method: 'GET', + accountRegister: (data: RegisterModel, params: RequestParams = {}) => + this.request({ + path: `/api/account/register`, + method: 'POST', + body: data, + type: ContentType.Json, format: 'json', ...params, }), + /** - * @description 使用此接口获取全局设置,需要Admin权限 + * @description 使用此接口更新用户用户名和描述,需要User权限 * - * @tags Admin - * @name AdminGetConfigs - * @summary 获取配置 - * @request GET:/api/admin/config + * @tags Account + * @name AccountUpdate + * @summary 用户数据更新接口 + * @request PUT:/api/account/update */ - useAdminGetConfigs: (options?: SWRConfiguration, doFetch: boolean = true) => - useSWR(doFetch ? `/api/admin/config` : null, options), + accountUpdate: (data: ProfileUpdateModel, params: RequestParams = {}) => + this.request({ + path: `/api/account/update`, + method: 'PUT', + body: data, + type: ContentType.Json, + ...params, + }), /** - * @description 使用此接口获取全局设置,需要Admin权限 + * @description 使用此接口通过邮箱验证码确认邮箱 * - * @tags Admin - * @name AdminGetConfigs - * @summary 获取配置 - * @request GET:/api/admin/config + * @tags Account + * @name AccountVerify + * @summary 用户邮箱确认接口 + * @request POST:/api/account/verify */ - mutateAdminGetConfigs: ( - data?: ConfigEditModel | Promise, - options?: MutatorOptions - ) => mutate(`/api/admin/config`, data, options), - + accountVerify: (data: AccountVerifyModel, params: RequestParams = {}) => + this.request({ + path: `/api/account/verify`, + method: 'POST', + body: data, + type: ContentType.Json, + ...params, + }), + } + admin = { /** - * @description 使用此接口更改全局设置,需要Admin权限 + * @description 使用此接口批量添加用户,需要Admin权限 * * @tags Admin - * @name AdminUpdateConfigs - * @summary 更改配置 - * @request PUT:/api/admin/config + * @name AdminAddUsers + * @summary 批量添加用户 + * @request POST:/api/admin/users */ - adminUpdateConfigs: (data: ConfigEditModel, params: RequestParams = {}) => + adminAddUsers: (data: UserCreateModel[], params: RequestParams = {}) => this.request({ - path: `/api/admin/config`, - method: 'PUT', + path: `/api/admin/users`, + method: 'POST', body: data, type: ContentType.Json, ...params, }), /** - * @description 使用此接口获取全部用户,需要Admin权限 + * @description 使用此接口删除队伍,需要Admin权限 * * @tags Admin - * @name AdminUsers - * @summary 获取全部用户 - * @request GET:/api/admin/users + * @name AdminDeleteTeam + * @summary 删除队伍 + * @request DELETE:/api/admin/teams/{id} */ - adminUsers: ( - query?: { - /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 - */ - skip?: number - }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/admin/users`, - method: 'GET', - query: query, + adminDeleteTeam: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/admin/teams/${id}`, + method: 'DELETE', format: 'json', ...params, }), + /** - * @description 使用此接口获取全部用户,需要Admin权限 + * @description 使用此接口删除用户,需要Admin权限 * * @tags Admin - * @name AdminUsers - * @summary 获取全部用户 - * @request GET:/api/admin/users + * @name AdminDeleteUser + * @summary 删除用户 + * @request DELETE:/api/admin/users/{userid} */ - useAdminUsers: ( - query?: { - /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 - */ - skip?: number - }, - options?: SWRConfiguration, - doFetch: boolean = true - ) => - useSWR( - doFetch ? [`/api/admin/users`, query] : null, - options - ), + adminDeleteUser: (userid: string, params: RequestParams = {}) => + this.request({ + path: `/api/admin/users/${userid}`, + method: 'DELETE', + format: 'json', + ...params, + }), /** - * @description 使用此接口获取全部用户,需要Admin权限 + * @description 使用此接口强制删除容器实例,需要Admin权限 * * @tags Admin - * @name AdminUsers - * @summary 获取全部用户 - * @request GET:/api/admin/users + * @name AdminDestroyInstance + * @summary 删除容器实例 + * @request DELETE:/api/admin/instances/{id} */ - mutateAdminUsers: ( - query?: { - /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 - */ - skip?: number - }, - data?: ArrayResponseOfUserInfoModel | Promise, - options?: MutatorOptions - ) => mutate([`/api/admin/users`, query], data, options), + adminDestroyInstance: (id: string, params: RequestParams = {}) => + this.request({ + path: `/api/admin/instances/${id}`, + method: 'DELETE', + ...params, + }), /** - * @description 使用此接口批量添加用户,需要Admin权限 + * @description 使用此接口下载全部 Writeup,需要Admin权限 * * @tags Admin - * @name AdminAddUsers - * @summary 批量添加用户 - * @request POST:/api/admin/users + * @name AdminDownloadAllWriteups + * @summary 下载全部 Writeup + * @request GET:/api/admin/writeups/{id}/all */ - adminAddUsers: (data: UserCreateModel[], params: RequestParams = {}) => + adminDownloadAllWriteups: (id: number, params: RequestParams = {}) => this.request({ - path: `/api/admin/users`, - method: 'POST', - body: data, - type: ContentType.Json, + path: `/api/admin/writeups/${id}/all`, + method: 'GET', ...params, }), + /** + * @description 使用此接口下载全部 Writeup,需要Admin权限 + * + * @tags Admin + * @name AdminDownloadAllWriteups + * @summary 下载全部 Writeup + * @request GET:/api/admin/writeups/{id}/all + */ + useAdminDownloadAllWriteups: ( + id: number, + options?: SWRConfiguration, + doFetch: boolean = true + ) => useSWR(doFetch ? `/api/admin/writeups/${id}/all` : null, options), /** - * @description 使用此接口搜索用户,需要Admin权限 + * @description 使用此接口下载全部 Writeup,需要Admin权限 * * @tags Admin - * @name AdminSearchUsers - * @summary 搜索用户 - * @request POST:/api/admin/users/search + * @name AdminDownloadAllWriteups + * @summary 下载全部 Writeup + * @request GET:/api/admin/writeups/{id}/all */ - adminSearchUsers: ( - query?: { - hint?: string - }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/admin/users/search`, - method: 'POST', - query: query, - format: 'json', - ...params, - }), + mutateAdminDownloadAllWriteups: ( + id: number, + data?: void | Promise, + options?: MutatorOptions + ) => mutate(`/api/admin/writeups/${id}/all`, data, options), /** - * @description 使用此接口获取全部队伍,需要Admin权限 + * @description 使用此接口获取全部文件,需要Admin权限 * * @tags Admin - * @name AdminTeams - * @summary 获取全部队伍信息 - * @request GET:/api/admin/teams + * @name AdminFiles + * @summary 获取全部文件 + * @request GET:/api/admin/files */ - adminTeams: ( + adminFiles: ( query?: { /** * @format int32 - * @default 100 + * @default 50 */ count?: number /** @@ -2206,26 +2139,26 @@ export class Api extends HttpClient - this.request({ - path: `/api/admin/teams`, + this.request({ + path: `/api/admin/files`, method: 'GET', query: query, format: 'json', ...params, }), /** - * @description 使用此接口获取全部队伍,需要Admin权限 + * @description 使用此接口获取全部文件,需要Admin权限 * * @tags Admin - * @name AdminTeams - * @summary 获取全部队伍信息 - * @request GET:/api/admin/teams + * @name AdminFiles + * @summary 获取全部文件 + * @request GET:/api/admin/files */ - useAdminTeams: ( + useAdminFiles: ( query?: { /** * @format int32 - * @default 100 + * @default 50 */ count?: number /** @@ -2237,24 +2170,24 @@ export class Api extends HttpClient - useSWR( - doFetch ? [`/api/admin/teams`, query] : null, + useSWR( + doFetch ? [`/api/admin/files`, query] : null, options ), /** - * @description 使用此接口获取全部队伍,需要Admin权限 + * @description 使用此接口获取全部文件,需要Admin权限 * * @tags Admin - * @name AdminTeams - * @summary 获取全部队伍信息 - * @request GET:/api/admin/teams + * @name AdminFiles + * @summary 获取全部文件 + * @request GET:/api/admin/files */ - mutateAdminTeams: ( + mutateAdminFiles: ( query?: { /** * @format int32 - * @default 100 + * @default 50 */ count?: number /** @@ -2263,156 +2196,90 @@ export class Api extends HttpClient, + data?: ArrayResponseOfLocalFile | Promise, options?: MutatorOptions - ) => mutate([`/api/admin/teams`, query], data, options), + ) => mutate([`/api/admin/files`, query], data, options), /** - * @description 使用此接口搜索队伍,需要Admin权限 + * @description 使用此接口获取全局设置,需要Admin权限 * * @tags Admin - * @name AdminSearchTeams - * @summary 搜索队伍 - * @request POST:/api/admin/teams/search + * @name AdminGetConfigs + * @summary 获取配置 + * @request GET:/api/admin/config */ - adminSearchTeams: ( - query?: { - hint?: string - }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/admin/teams/search`, - method: 'POST', - query: query, + adminGetConfigs: (params: RequestParams = {}) => + this.request({ + path: `/api/admin/config`, + method: 'GET', format: 'json', ...params, }), - /** - * @description 使用此接口修改队伍信息,需要Admin权限 + * @description 使用此接口获取全局设置,需要Admin权限 * * @tags Admin - * @name AdminUpdateTeam - * @summary 修改队伍信息 - * @request PUT:/api/admin/teams/{id} + * @name AdminGetConfigs + * @summary 获取配置 + * @request GET:/api/admin/config */ - adminUpdateTeam: (id: number, data: AdminTeamModel, params: RequestParams = {}) => - this.request({ - path: `/api/admin/teams/${id}`, - method: 'PUT', - body: data, - type: ContentType.Json, - ...params, - }), + useAdminGetConfigs: (options?: SWRConfiguration, doFetch: boolean = true) => + useSWR(doFetch ? `/api/admin/config` : null, options), /** - * @description 使用此接口删除队伍,需要Admin权限 + * @description 使用此接口获取全局设置,需要Admin权限 * * @tags Admin - * @name AdminDeleteTeam - * @summary 删除队伍 - * @request DELETE:/api/admin/teams/{id} + * @name AdminGetConfigs + * @summary 获取配置 + * @request GET:/api/admin/config */ - adminDeleteTeam: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/admin/teams/${id}`, - method: 'DELETE', - format: 'json', - ...params, - }), - - /** - * @description 使用此接口修改用户信息,需要Admin权限 - * - * @tags Admin - * @name AdminUpdateUserInfo - * @summary 修改用户信息 - * @request PUT:/api/admin/users/{userid} - */ - adminUpdateUserInfo: (userid: string, data: AdminUserInfoModel, params: RequestParams = {}) => - this.request({ - path: `/api/admin/users/${userid}`, - method: 'PUT', - body: data, - type: ContentType.Json, - ...params, - }), - - /** - * @description 使用此接口删除用户,需要Admin权限 - * - * @tags Admin - * @name AdminDeleteUser - * @summary 删除用户 - * @request DELETE:/api/admin/users/{userid} - */ - adminDeleteUser: (userid: string, params: RequestParams = {}) => - this.request({ - path: `/api/admin/users/${userid}`, - method: 'DELETE', - format: 'json', - ...params, - }), + mutateAdminGetConfigs: ( + data?: ConfigEditModel | Promise, + options?: MutatorOptions + ) => mutate(`/api/admin/config`, data, options), /** - * @description 使用此接口获取用户信息,需要Admin权限 + * @description 使用此接口获取全部容器实例,需要Admin权限 * * @tags Admin - * @name AdminUserInfo - * @summary 获取用户信息 - * @request GET:/api/admin/users/{userid} + * @name AdminInstances + * @summary 获取全部容器实例 + * @request GET:/api/admin/instances */ - adminUserInfo: (userid: string, params: RequestParams = {}) => - this.request({ - path: `/api/admin/users/${userid}`, + adminInstances: (params: RequestParams = {}) => + this.request({ + path: `/api/admin/instances`, method: 'GET', format: 'json', ...params, }), /** - * @description 使用此接口获取用户信息,需要Admin权限 + * @description 使用此接口获取全部容器实例,需要Admin权限 * * @tags Admin - * @name AdminUserInfo - * @summary 获取用户信息 - * @request GET:/api/admin/users/{userid} + * @name AdminInstances + * @summary 获取全部容器实例 + * @request GET:/api/admin/instances */ - useAdminUserInfo: (userid: string, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR( - doFetch ? `/api/admin/users/${userid}` : null, + useAdminInstances: (options?: SWRConfiguration, doFetch: boolean = true) => + useSWR( + doFetch ? `/api/admin/instances` : null, options ), /** - * @description 使用此接口获取用户信息,需要Admin权限 + * @description 使用此接口获取全部容器实例,需要Admin权限 * * @tags Admin - * @name AdminUserInfo - * @summary 获取用户信息 - * @request GET:/api/admin/users/{userid} + * @name AdminInstances + * @summary 获取全部容器实例 + * @request GET:/api/admin/instances */ - mutateAdminUserInfo: ( - userid: string, - data?: ProfileUserInfoModel | Promise, + mutateAdminInstances: ( + data?: ArrayResponseOfContainerInstanceModel | Promise, options?: MutatorOptions - ) => mutate(`/api/admin/users/${userid}`, data, options), - - /** - * @description 使用此接口重置用户密码,需要Admin权限 - * - * @tags Admin - * @name AdminResetPassword - * @summary 重置用户密码 - * @request DELETE:/api/admin/users/{userid}/password - */ - adminResetPassword: (userid: string, params: RequestParams = {}) => - this.request({ - path: `/api/admin/users/${userid}/password`, - method: 'DELETE', - format: 'json', - ...params, - }), + ) => mutate(`/api/admin/instances`, data, options), /** * @description 使用此接口获取全部日志,需要Admin权限 @@ -2520,160 +2387,256 @@ export class Api extends HttpClient - this.request({ - path: `/api/admin/writeups/${id}`, - method: 'GET', + adminResetPassword: (userid: string, params: RequestParams = {}) => + this.request({ + path: `/api/admin/users/${userid}/password`, + method: 'DELETE', format: 'json', ...params, }), + /** - * @description 使用此接口获取 Writeup 基本信息,需要Admin权限 + * @description 使用此接口搜索队伍,需要Admin权限 * * @tags Admin - * @name AdminWriteups - * @summary 获取全部 Writeup 基本信息 - * @request GET:/api/admin/writeups/{id} + * @name AdminSearchTeams + * @summary 搜索队伍 + * @request POST:/api/admin/teams/search */ - useAdminWriteups: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR( - doFetch ? `/api/admin/writeups/${id}` : null, - options - ), + adminSearchTeams: ( + query?: { + hint?: string + }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/admin/teams/search`, + method: 'POST', + query: query, + format: 'json', + ...params, + }), /** - * @description 使用此接口获取 Writeup 基本信息,需要Admin权限 + * @description 使用此接口搜索用户,需要Admin权限 * * @tags Admin - * @name AdminWriteups - * @summary 获取全部 Writeup 基本信息 - * @request GET:/api/admin/writeups/{id} + * @name AdminSearchUsers + * @summary 搜索用户 + * @request POST:/api/admin/users/search */ - mutateAdminWriteups: ( - id: number, - data?: WriteupInfoModel[] | Promise, - options?: MutatorOptions - ) => mutate(`/api/admin/writeups/${id}`, data, options), + adminSearchUsers: ( + query?: { + hint?: string + }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/admin/users/search`, + method: 'POST', + query: query, + format: 'json', + ...params, + }), /** - * @description 使用此接口下载全部 Writeup,需要Admin权限 + * @description 使用此接口获取全部队伍,需要Admin权限 * * @tags Admin - * @name AdminDownloadAllWriteups - * @summary 下载全部 Writeup - * @request GET:/api/admin/writeups/{id}/all + * @name AdminTeams + * @summary 获取全部队伍信息 + * @request GET:/api/admin/teams */ - adminDownloadAllWriteups: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/admin/writeups/${id}/all`, + adminTeams: ( + query?: { + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/admin/teams`, method: 'GET', + query: query, + format: 'json', ...params, }), /** - * @description 使用此接口下载全部 Writeup,需要Admin权限 + * @description 使用此接口获取全部队伍,需要Admin权限 * * @tags Admin - * @name AdminDownloadAllWriteups - * @summary 下载全部 Writeup - * @request GET:/api/admin/writeups/{id}/all + * @name AdminTeams + * @summary 获取全部队伍信息 + * @request GET:/api/admin/teams */ - useAdminDownloadAllWriteups: ( - id: number, + useAdminTeams: ( + query?: { + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, options?: SWRConfiguration, doFetch: boolean = true - ) => useSWR(doFetch ? `/api/admin/writeups/${id}/all` : null, options), + ) => + useSWR( + doFetch ? [`/api/admin/teams`, query] : null, + options + ), /** - * @description 使用此接口下载全部 Writeup,需要Admin权限 + * @description 使用此接口获取全部队伍,需要Admin权限 * * @tags Admin - * @name AdminDownloadAllWriteups - * @summary 下载全部 Writeup - * @request GET:/api/admin/writeups/{id}/all + * @name AdminTeams + * @summary 获取全部队伍信息 + * @request GET:/api/admin/teams */ - mutateAdminDownloadAllWriteups: ( - id: number, - data?: void | Promise, + mutateAdminTeams: ( + query?: { + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, + data?: ArrayResponseOfTeamInfoModel | Promise, options?: MutatorOptions - ) => mutate(`/api/admin/writeups/${id}/all`, data, options), + ) => mutate([`/api/admin/teams`, query], data, options), /** - * @description 使用此接口获取全部容器实例,需要Admin权限 + * @description 使用此接口更改全局设置,需要Admin权限 * * @tags Admin - * @name AdminInstances - * @summary 获取全部容器实例 - * @request GET:/api/admin/instances - */ - adminInstances: (params: RequestParams = {}) => - this.request({ - path: `/api/admin/instances`, - method: 'GET', - format: 'json', + * @name AdminUpdateConfigs + * @summary 更改配置 + * @request PUT:/api/admin/config + */ + adminUpdateConfigs: (data: ConfigEditModel, params: RequestParams = {}) => + this.request({ + path: `/api/admin/config`, + method: 'PUT', + body: data, + type: ContentType.Json, ...params, }), + /** - * @description 使用此接口获取全部容器实例,需要Admin权限 + * @description 使用此接口修改队伍信息,需要Admin权限 * * @tags Admin - * @name AdminInstances - * @summary 获取全部容器实例 - * @request GET:/api/admin/instances + * @name AdminUpdateTeam + * @summary 修改队伍信息 + * @request PUT:/api/admin/teams/{id} */ - useAdminInstances: (options?: SWRConfiguration, doFetch: boolean = true) => - useSWR( - doFetch ? `/api/admin/instances` : null, - options - ), + adminUpdateTeam: (id: number, data: AdminTeamModel, params: RequestParams = {}) => + this.request({ + path: `/api/admin/teams/${id}`, + method: 'PUT', + body: data, + type: ContentType.Json, + ...params, + }), /** - * @description 使用此接口获取全部容器实例,需要Admin权限 + * @description 使用此接口修改用户信息,需要Admin权限 * * @tags Admin - * @name AdminInstances - * @summary 获取全部容器实例 - * @request GET:/api/admin/instances + * @name AdminUpdateUserInfo + * @summary 修改用户信息 + * @request PUT:/api/admin/users/{userid} */ - mutateAdminInstances: ( - data?: ArrayResponseOfContainerInstanceModel | Promise, - options?: MutatorOptions - ) => mutate(`/api/admin/instances`, data, options), + adminUpdateUserInfo: (userid: string, data: AdminUserInfoModel, params: RequestParams = {}) => + this.request({ + path: `/api/admin/users/${userid}`, + method: 'PUT', + body: data, + type: ContentType.Json, + ...params, + }), /** - * @description 使用此接口强制删除容器实例,需要Admin权限 + * @description 使用此接口获取用户信息,需要Admin权限 * * @tags Admin - * @name AdminDestroyInstance - * @summary 删除容器实例 - * @request DELETE:/api/admin/instances/{id} + * @name AdminUserInfo + * @summary 获取用户信息 + * @request GET:/api/admin/users/{userid} */ - adminDestroyInstance: (id: string, params: RequestParams = {}) => - this.request({ - path: `/api/admin/instances/${id}`, - method: 'DELETE', + adminUserInfo: (userid: string, params: RequestParams = {}) => + this.request({ + path: `/api/admin/users/${userid}`, + method: 'GET', + format: 'json', ...params, }), + /** + * @description 使用此接口获取用户信息,需要Admin权限 + * + * @tags Admin + * @name AdminUserInfo + * @summary 获取用户信息 + * @request GET:/api/admin/users/{userid} + */ + useAdminUserInfo: (userid: string, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR( + doFetch ? `/api/admin/users/${userid}` : null, + options + ), /** - * @description 使用此接口获取全部文件,需要Admin权限 + * @description 使用此接口获取用户信息,需要Admin权限 * * @tags Admin - * @name AdminFiles - * @summary 获取全部文件 - * @request GET:/api/admin/files + * @name AdminUserInfo + * @summary 获取用户信息 + * @request GET:/api/admin/users/{userid} */ - adminFiles: ( + mutateAdminUserInfo: ( + userid: string, + data?: ProfileUserInfoModel | Promise, + options?: MutatorOptions + ) => mutate(`/api/admin/users/${userid}`, data, options), + + /** + * @description 使用此接口获取全部用户,需要Admin权限 + * + * @tags Admin + * @name AdminUsers + * @summary 获取全部用户 + * @request GET:/api/admin/users + */ + adminUsers: ( query?: { /** * @format int32 - * @default 50 + * @default 100 */ count?: number /** @@ -2684,26 +2647,26 @@ export class Api extends HttpClient - this.request({ - path: `/api/admin/files`, + this.request({ + path: `/api/admin/users`, method: 'GET', query: query, format: 'json', ...params, }), /** - * @description 使用此接口获取全部文件,需要Admin权限 + * @description 使用此接口获取全部用户,需要Admin权限 * * @tags Admin - * @name AdminFiles - * @summary 获取全部文件 - * @request GET:/api/admin/files + * @name AdminUsers + * @summary 获取全部用户 + * @request GET:/api/admin/users */ - useAdminFiles: ( + useAdminUsers: ( query?: { /** * @format int32 - * @default 50 + * @default 100 */ count?: number /** @@ -2715,24 +2678,24 @@ export class Api extends HttpClient - useSWR( - doFetch ? [`/api/admin/files`, query] : null, + useSWR( + doFetch ? [`/api/admin/users`, query] : null, options ), /** - * @description 使用此接口获取全部文件,需要Admin权限 + * @description 使用此接口获取全部用户,需要Admin权限 * * @tags Admin - * @name AdminFiles - * @summary 获取全部文件 - * @request GET:/api/admin/files + * @name AdminUsers + * @summary 获取全部用户 + * @request GET:/api/admin/users */ - mutateAdminFiles: ( + mutateAdminUsers: ( query?: { /** * @format int32 - * @default 50 + * @default 100 */ count?: number /** @@ -2741,11 +2704,69 @@ export class Api extends HttpClient, + data?: ArrayResponseOfUserInfoModel | Promise, options?: MutatorOptions - ) => mutate([`/api/admin/files`, query], data, options), + ) => mutate([`/api/admin/users`, query], data, options), + + /** + * @description 使用此接口获取 Writeup 基本信息,需要Admin权限 + * + * @tags Admin + * @name AdminWriteups + * @summary 获取全部 Writeup 基本信息 + * @request GET:/api/admin/writeups/{id} + */ + adminWriteups: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/admin/writeups/${id}`, + method: 'GET', + format: 'json', + ...params, + }), + /** + * @description 使用此接口获取 Writeup 基本信息,需要Admin权限 + * + * @tags Admin + * @name AdminWriteups + * @summary 获取全部 Writeup 基本信息 + * @request GET:/api/admin/writeups/{id} + */ + useAdminWriteups: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR( + doFetch ? `/api/admin/writeups/${id}` : null, + options + ), + + /** + * @description 使用此接口获取 Writeup 基本信息,需要Admin权限 + * + * @tags Admin + * @name AdminWriteups + * @summary 获取全部 Writeup 基本信息 + * @request GET:/api/admin/writeups/{id} + */ + mutateAdminWriteups: ( + id: number, + data?: WriteupInfoModel[] | Promise, + options?: MutatorOptions + ) => mutate(`/api/admin/writeups/${id}`, data, options), } assets = { + /** + * @description 按照文件哈希删除文件 + * + * @tags Assets + * @name AssetsDelete + * @summary 删除文件接口 + * @request DELETE:/api/assets/{hash} + */ + assetsDelete: (hash: string, params: RequestParams = {}) => + this.request({ + path: `/api/assets/${hash}`, + method: 'DELETE', + ...params, + }), + /** * @description 根据哈希获取文件,不匹配文件名 * @@ -2817,53 +2838,37 @@ export class Api extends HttpClient - this.request({ - path: `/api/assets/${hash}`, - method: 'DELETE', - ...params, - }), } edit = { /** - * @description 添加文章,需要管理员权限 + * @description 添加比赛题目 Flag,需要管理员权限 * * @tags Edit - * @name EditAddPost - * @summary 添加文章 - * @request POST:/api/edit/posts + * @name EditAddFlags + * @summary 添加比赛题目 Flag + * @request POST:/api/edit/games/{id}/challenges/{cId}/flags */ - editAddPost: (data: PostEditModel, params: RequestParams = {}) => - this.request({ - path: `/api/edit/posts`, + editAddFlags: (id: number, cId: number, data: FlagCreateModel[], params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/challenges/${cId}/flags`, method: 'POST', body: data, type: ContentType.Json, - format: 'json', ...params, }), /** - * @description 修改文章,需要管理员权限 + * @description 添加比赛,需要管理员权限 * * @tags Edit - * @name EditUpdatePost - * @summary 修改文章 - * @request PUT:/api/edit/posts/{id} + * @name EditAddGame + * @summary 添加比赛 + * @request POST:/api/edit/games */ - editUpdatePost: (id: string, data: PostEditModel, params: RequestParams = {}) => - this.request({ - path: `/api/edit/posts/${id}`, - method: 'PUT', + editAddGame: (data: GameInfoModel, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games`, + method: 'POST', body: data, type: ContentType.Json, format: 'json', @@ -2871,31 +2876,34 @@ export class Api extends HttpClient - this.request({ - path: `/api/edit/posts/${id}`, - method: 'DELETE', + editAddGameChallenge: (id: number, data: ChallengeInfoModel, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/challenges`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', ...params, }), /** - * @description 添加比赛,需要管理员权限 + * @description 添加比赛通知,需要管理员权限 * * @tags Edit - * @name EditAddGame - * @summary 添加比赛 - * @request POST:/api/edit/games + * @name EditAddGameNotice + * @summary 添加比赛通知 + * @request POST:/api/edit/games/{id}/notices */ - editAddGame: (data: GameInfoModel, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games`, + editAddGameNotice: (id: number, data: GameNoticeModel, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/notices`, method: 'POST', body: data, type: ContentType.Json, @@ -2904,70 +2912,99 @@ export class Api extends HttpClient - this.request({ - path: `/api/edit/games`, - method: 'GET', - query: query, + editAddPost: (data: PostEditModel, params: RequestParams = {}) => + this.request({ + path: `/api/edit/posts`, + method: 'POST', + body: data, + type: ContentType.Json, format: 'json', ...params, }), + /** - * @description 获取比赛列表,需要管理员权限 + * @description 测试比赛题目容器,需要管理员权限 * * @tags Edit - * @name EditGetGames - * @summary 获取比赛列表 - * @request GET:/api/edit/games + * @name EditCreateTestContainer + * @summary 测试比赛题目容器 + * @request POST:/api/edit/games/{id}/challenges/{cId}/container */ - useEditGetGames: ( - query?: { - /** @format int32 */ - count?: number - /** @format int32 */ - skip?: number - }, - options?: SWRConfiguration, - doFetch: boolean = true - ) => - useSWR( - doFetch ? [`/api/edit/games`, query] : null, - options - ), + editCreateTestContainer: (id: number, cId: number, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/challenges/${cId}/container`, + method: 'POST', + format: 'json', + ...params, + }), /** - * @description 获取比赛列表,需要管理员权限 + * @description 删除比赛,需要管理员权限 * * @tags Edit - * @name EditGetGames - * @summary 获取比赛列表 - * @request GET:/api/edit/games + * @name EditDeleteGame + * @summary 删除比赛 + * @request DELETE:/api/edit/games/{id} */ - mutateEditGetGames: ( - query?: { - /** @format int32 */ - count?: number - /** @format int32 */ - skip?: number - }, - data?: ArrayResponseOfGameInfoModel | Promise, - options?: MutatorOptions - ) => mutate([`/api/edit/games`, query], data, options), + editDeleteGame: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}`, + method: 'DELETE', + format: 'json', + ...params, + }), + + /** + * @description 删除比赛通知,需要管理员权限 + * + * @tags Edit + * @name EditDeleteGameNotice + * @summary 删除比赛通知 + * @request DELETE:/api/edit/games/{id}/notices/{noticeId} + */ + editDeleteGameNotice: (id: number, noticeId: number, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/notices/${noticeId}`, + method: 'DELETE', + ...params, + }), + + /** + * @description 删除文章,需要管理员权限 + * + * @tags Edit + * @name EditDeletePost + * @summary 删除文章 + * @request DELETE:/api/edit/posts/{id} + */ + editDeletePost: (id: string, params: RequestParams = {}) => + this.request({ + path: `/api/edit/posts/${id}`, + method: 'DELETE', + ...params, + }), + + /** + * @description 关闭测试比赛题目容器,需要管理员权限 + * + * @tags Edit + * @name EditDestroyTestContainer + * @summary 关闭测试比赛题目容器 + * @request DELETE:/api/edit/games/{id}/challenges/{cId}/container + */ + editDestroyTestContainer: (id: number, cId: number, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/challenges/${cId}/container`, + method: 'DELETE', + ...params, + }), /** * @description 获取比赛,需要管理员权限 @@ -3010,124 +3047,96 @@ export class Api extends HttpClient mutate(`/api/edit/games/${id}`, data, options), /** - * @description 修改比赛,需要管理员权限 + * @description 获取比赛题目,需要管理员权限 * * @tags Edit - * @name EditUpdateGame - * @summary 修改比赛 - * @request PUT:/api/edit/games/{id} + * @name EditGetGameChallenge + * @summary 获取比赛题目 + * @request GET:/api/edit/games/{id}/challenges/{cId} */ - editUpdateGame: (id: number, data: GameInfoModel, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}`, - method: 'PUT', - body: data, - type: ContentType.Json, + editGetGameChallenge: (id: number, cId: number, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/challenges/${cId}`, + method: 'GET', format: 'json', ...params, }), + /** + * @description 获取比赛题目,需要管理员权限 + * + * @tags Edit + * @name EditGetGameChallenge + * @summary 获取比赛题目 + * @request GET:/api/edit/games/{id}/challenges/{cId} + */ + useEditGetGameChallenge: ( + id: number, + cId: number, + options?: SWRConfiguration, + doFetch: boolean = true + ) => + useSWR( + doFetch ? `/api/edit/games/${id}/challenges/${cId}` : null, + options + ), /** - * @description 删除比赛,需要管理员权限 + * @description 获取比赛题目,需要管理员权限 * * @tags Edit - * @name EditDeleteGame - * @summary 删除比赛 - * @request DELETE:/api/edit/games/{id} + * @name EditGetGameChallenge + * @summary 获取比赛题目 + * @request GET:/api/edit/games/{id}/challenges/{cId} */ - editDeleteGame: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}`, - method: 'DELETE', - format: 'json', - ...params, - }), + mutateEditGetGameChallenge: ( + id: number, + cId: number, + data?: ChallengeEditDetailModel | Promise, + options?: MutatorOptions + ) => mutate(`/api/edit/games/${id}/challenges/${cId}`, data, options), /** - * @description 获取比赛队伍 Hash 的加盐,需要管理员权限 + * @description 获取全部比赛题目,需要管理员权限 * * @tags Edit - * @name EditGetTeamHashSalt - * @summary 获取比赛队伍 Hash 的加盐 - * @request GET:/api/edit/games/{id}/teamhashsalt + * @name EditGetGameChallenges + * @summary 获取全部比赛题目 + * @request GET:/api/edit/games/{id}/challenges */ - editGetTeamHashSalt: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/teamhashsalt`, + editGetGameChallenges: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/challenges`, method: 'GET', format: 'json', ...params, }), /** - * @description 获取比赛队伍 Hash 的加盐,需要管理员权限 + * @description 获取全部比赛题目,需要管理员权限 * * @tags Edit - * @name EditGetTeamHashSalt - * @summary 获取比赛队伍 Hash 的加盐 - * @request GET:/api/edit/games/{id}/teamhashsalt + * @name EditGetGameChallenges + * @summary 获取全部比赛题目 + * @request GET:/api/edit/games/{id}/challenges */ - useEditGetTeamHashSalt: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR( - doFetch ? `/api/edit/games/${id}/teamhashsalt` : null, + useEditGetGameChallenges: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR( + doFetch ? `/api/edit/games/${id}/challenges` : null, options ), /** - * @description 获取比赛队伍 Hash 的加盐,需要管理员权限 + * @description 获取全部比赛题目,需要管理员权限 * * @tags Edit - * @name EditGetTeamHashSalt - * @summary 获取比赛队伍 Hash 的加盐 - * @request GET:/api/edit/games/{id}/teamhashsalt + * @name EditGetGameChallenges + * @summary 获取全部比赛题目 + * @request GET:/api/edit/games/{id}/challenges */ - mutateEditGetTeamHashSalt: ( + mutateEditGetGameChallenges: ( id: number, - data?: string | Promise, + data?: ChallengeInfoModel[] | Promise, options?: MutatorOptions - ) => mutate(`/api/edit/games/${id}/teamhashsalt`, data, options), - - /** - * @description 使用此接口更新比赛头图,需要Admin权限 - * - * @tags Edit - * @name EditUpdateGamePoster - * @summary 更新比赛头图 - * @request PUT:/api/edit/games/{id}/poster - */ - editUpdateGamePoster: ( - id: number, - data: { - /** @format binary */ - file?: File - }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/edit/games/${id}/poster`, - method: 'PUT', - body: data, - type: ContentType.FormData, - format: 'json', - ...params, - }), - - /** - * @description 添加比赛通知,需要管理员权限 - * - * @tags Edit - * @name EditAddGameNotice - * @summary 添加比赛通知 - * @request POST:/api/edit/games/{id}/notices - */ - editAddGameNotice: (id: number, data: GameNoticeModel, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/notices`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params, - }), + ) => mutate(`/api/edit/games/${id}/challenges`, data, options), /** * @description 获取比赛通知,需要管理员权限 @@ -3173,152 +3182,185 @@ export class Api extends HttpClient mutate(`/api/edit/games/${id}/notices`, data, options), /** - * @description 更新比赛通知,需要管理员权限 + * @description 获取比赛列表,需要管理员权限 * * @tags Edit - * @name EditUpdateGameNotice - * @summary 更新比赛通知 - * @request PUT:/api/edit/games/{id}/notices/{noticeId} + * @name EditGetGames + * @summary 获取比赛列表 + * @request GET:/api/edit/games */ - editUpdateGameNotice: ( - id: number, - noticeId: number, - data: GameNoticeModel, + editGetGames: ( + query?: { + /** @format int32 */ + count?: number + /** @format int32 */ + skip?: number + }, params: RequestParams = {} ) => - this.request({ - path: `/api/edit/games/${id}/notices/${noticeId}`, - method: 'PUT', - body: data, - type: ContentType.Json, + this.request({ + path: `/api/edit/games`, + method: 'GET', + query: query, format: 'json', ...params, }), - /** - * @description 删除比赛通知,需要管理员权限 + * @description 获取比赛列表,需要管理员权限 * * @tags Edit - * @name EditDeleteGameNotice - * @summary 删除比赛通知 - * @request DELETE:/api/edit/games/{id}/notices/{noticeId} + * @name EditGetGames + * @summary 获取比赛列表 + * @request GET:/api/edit/games */ - editDeleteGameNotice: (id: number, noticeId: number, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/notices/${noticeId}`, - method: 'DELETE', - ...params, - }), + useEditGetGames: ( + query?: { + /** @format int32 */ + count?: number + /** @format int32 */ + skip?: number + }, + options?: SWRConfiguration, + doFetch: boolean = true + ) => + useSWR( + doFetch ? [`/api/edit/games`, query] : null, + options + ), /** - * @description 添加比赛题目,需要管理员权限 + * @description 获取比赛列表,需要管理员权限 * * @tags Edit - * @name EditAddGameChallenge - * @summary 添加比赛题目 - * @request POST:/api/edit/games/{id}/challenges + * @name EditGetGames + * @summary 获取比赛列表 + * @request GET:/api/edit/games */ - editAddGameChallenge: (id: number, data: ChallengeInfoModel, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/challenges`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params, - }), + mutateEditGetGames: ( + query?: { + /** @format int32 */ + count?: number + /** @format int32 */ + skip?: number + }, + data?: ArrayResponseOfGameInfoModel | Promise, + options?: MutatorOptions + ) => mutate([`/api/edit/games`, query], data, options), /** - * @description 获取全部比赛题目,需要管理员权限 + * @description 获取比赛队伍 Hash 的加盐,需要管理员权限 * * @tags Edit - * @name EditGetGameChallenges - * @summary 获取全部比赛题目 - * @request GET:/api/edit/games/{id}/challenges + * @name EditGetTeamHashSalt + * @summary 获取比赛队伍 Hash 的加盐 + * @request GET:/api/edit/games/{id}/teamhashsalt */ - editGetGameChallenges: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/challenges`, + editGetTeamHashSalt: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/teamhashsalt`, method: 'GET', format: 'json', ...params, }), /** - * @description 获取全部比赛题目,需要管理员权限 + * @description 获取比赛队伍 Hash 的加盐,需要管理员权限 * * @tags Edit - * @name EditGetGameChallenges - * @summary 获取全部比赛题目 - * @request GET:/api/edit/games/{id}/challenges + * @name EditGetTeamHashSalt + * @summary 获取比赛队伍 Hash 的加盐 + * @request GET:/api/edit/games/{id}/teamhashsalt */ - useEditGetGameChallenges: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR( - doFetch ? `/api/edit/games/${id}/challenges` : null, + useEditGetTeamHashSalt: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR( + doFetch ? `/api/edit/games/${id}/teamhashsalt` : null, options ), /** - * @description 获取全部比赛题目,需要管理员权限 + * @description 获取比赛队伍 Hash 的加盐,需要管理员权限 * * @tags Edit - * @name EditGetGameChallenges - * @summary 获取全部比赛题目 - * @request GET:/api/edit/games/{id}/challenges + * @name EditGetTeamHashSalt + * @summary 获取比赛队伍 Hash 的加盐 + * @request GET:/api/edit/games/{id}/teamhashsalt */ - mutateEditGetGameChallenges: ( + mutateEditGetTeamHashSalt: ( id: number, - data?: ChallengeInfoModel[] | Promise, + data?: string | Promise, options?: MutatorOptions - ) => mutate(`/api/edit/games/${id}/challenges`, data, options), + ) => mutate(`/api/edit/games/${id}/teamhashsalt`, data, options), /** - * @description 获取比赛题目,需要管理员权限 + * @description 删除比赛题目 Flag,需要管理员权限 * * @tags Edit - * @name EditGetGameChallenge - * @summary 获取比赛题目 - * @request GET:/api/edit/games/{id}/challenges/{cId} + * @name EditRemoveFlag + * @summary 删除比赛题目 Flag + * @request DELETE:/api/edit/games/{id}/challenges/{cId}/flags/{fId} */ - editGetGameChallenge: (id: number, cId: number, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/challenges/${cId}`, - method: 'GET', + editRemoveFlag: (id: number, cId: number, fId: number, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/challenges/${cId}/flags/${fId}`, + method: 'DELETE', format: 'json', ...params, }), + /** - * @description 获取比赛题目,需要管理员权限 + * @description 删除比赛题目,需要管理员权限 * * @tags Edit - * @name EditGetGameChallenge - * @summary 获取比赛题目 - * @request GET:/api/edit/games/{id}/challenges/{cId} + * @name EditRemoveGameChallenge + * @summary 删除比赛题目 + * @request DELETE:/api/edit/games/{id}/challenges/{cId} */ - useEditGetGameChallenge: ( + editRemoveGameChallenge: (id: number, cId: number, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}/challenges/${cId}`, + method: 'DELETE', + ...params, + }), + + /** + * @description 更新比赛题目附件,需要管理员权限,仅用于非动态附件题目 + * + * @tags Edit + * @name EditUpdateAttachment + * @summary 更新比赛题目附件 + * @request POST:/api/edit/games/{id}/challenges/{cId}/attachment + */ + editUpdateAttachment: ( id: number, cId: number, - options?: SWRConfiguration, - doFetch: boolean = true + data: AttachmentCreateModel, + params: RequestParams = {} ) => - useSWR( - doFetch ? `/api/edit/games/${id}/challenges/${cId}` : null, - options - ), + this.request({ + path: `/api/edit/games/${id}/challenges/${cId}/attachment`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params, + }), /** - * @description 获取比赛题目,需要管理员权限 + * @description 修改比赛,需要管理员权限 * * @tags Edit - * @name EditGetGameChallenge - * @summary 获取比赛题目 - * @request GET:/api/edit/games/{id}/challenges/{cId} + * @name EditUpdateGame + * @summary 修改比赛 + * @request PUT:/api/edit/games/{id} */ - mutateEditGetGameChallenge: ( - id: number, - cId: number, - data?: ChallengeEditDetailModel | Promise, - options?: MutatorOptions - ) => mutate(`/api/edit/games/${id}/challenges/${cId}`, data, options), + editUpdateGame: (id: number, data: GameInfoModel, params: RequestParams = {}) => + this.request({ + path: `/api/edit/games/${id}`, + method: 'PUT', + body: data, + type: ContentType.Json, + format: 'json', + ...params, + }), /** * @description 修改比赛题目,需要管理员权限 @@ -3344,304 +3386,242 @@ export class Api extends HttpClient - this.request({ - path: `/api/edit/games/${id}/challenges/${cId}`, - method: 'DELETE', - ...params, - }), - - /** - * @description 测试比赛题目容器,需要管理员权限 - * - * @tags Edit - * @name EditCreateTestContainer - * @summary 测试比赛题目容器 - * @request POST:/api/edit/games/{id}/challenges/{cId}/container + * @name EditUpdateGameNotice + * @summary 更新比赛通知 + * @request PUT:/api/edit/games/{id}/notices/{noticeId} */ - editCreateTestContainer: (id: number, cId: number, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/challenges/${cId}/container`, - method: 'POST', + editUpdateGameNotice: ( + id: number, + noticeId: number, + data: GameNoticeModel, + params: RequestParams = {} + ) => + this.request({ + path: `/api/edit/games/${id}/notices/${noticeId}`, + method: 'PUT', + body: data, + type: ContentType.Json, format: 'json', ...params, }), /** - * @description 关闭测试比赛题目容器,需要管理员权限 - * - * @tags Edit - * @name EditDestroyTestContainer - * @summary 关闭测试比赛题目容器 - * @request DELETE:/api/edit/games/{id}/challenges/{cId}/container - */ - editDestroyTestContainer: (id: number, cId: number, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/challenges/${cId}/container`, - method: 'DELETE', - ...params, - }), - - /** - * @description 更新比赛题目附件,需要管理员权限,仅用于非动态附件题目 + * @description 使用此接口更新比赛头图,需要Admin权限 * * @tags Edit - * @name EditUpdateAttachment - * @summary 更新比赛题目附件 - * @request POST:/api/edit/games/{id}/challenges/{cId}/attachment + * @name EditUpdateGamePoster + * @summary 更新比赛头图 + * @request PUT:/api/edit/games/{id}/poster */ - editUpdateAttachment: ( + editUpdateGamePoster: ( id: number, - cId: number, - data: AttachmentCreateModel, + data: { + /** @format binary */ + file?: File + }, params: RequestParams = {} ) => - this.request({ - path: `/api/edit/games/${id}/challenges/${cId}/attachment`, - method: 'POST', + this.request({ + path: `/api/edit/games/${id}/poster`, + method: 'PUT', body: data, - type: ContentType.Json, + type: ContentType.FormData, format: 'json', ...params, }), /** - * @description 添加比赛题目 Flag,需要管理员权限 + * @description 修改文章,需要管理员权限 * * @tags Edit - * @name EditAddFlags - * @summary 添加比赛题目 Flag - * @request POST:/api/edit/games/{id}/challenges/{cId}/flags + * @name EditUpdatePost + * @summary 修改文章 + * @request PUT:/api/edit/posts/{id} */ - editAddFlags: (id: number, cId: number, data: FlagCreateModel[], params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/challenges/${cId}/flags`, - method: 'POST', + editUpdatePost: (id: string, data: PostEditModel, params: RequestParams = {}) => + this.request({ + path: `/api/edit/posts/${id}`, + method: 'PUT', body: data, type: ContentType.Json, - ...params, - }), - - /** - * @description 删除比赛题目 Flag,需要管理员权限 - * - * @tags Edit - * @name EditRemoveFlag - * @summary 删除比赛题目 Flag - * @request DELETE:/api/edit/games/{id}/challenges/{cId}/flags/{fId} - */ - editRemoveFlag: (id: number, cId: number, fId: number, params: RequestParams = {}) => - this.request({ - path: `/api/edit/games/${id}/challenges/${cId}/flags/${fId}`, - method: 'DELETE', format: 'json', ...params, }), } game = { /** - * @description 获取最近十个比赛 + * @description 获取比赛的全部题目,需要User权限,需要当前激活队伍已经报名 * * @tags Game - * @name GameGamesAll - * @summary 获取最新的比赛 - * @request GET:/api/game + * @name GameChallengesWithTeamInfo + * @summary 获取全部比赛题目信息及当前队伍信息 + * @request GET:/api/game/{id}/details */ - gameGamesAll: (params: RequestParams = {}) => - this.request({ - path: `/api/game`, + gameChallengesWithTeamInfo: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}/details`, method: 'GET', format: 'json', ...params, }), /** - * @description 获取最近十个比赛 + * @description 获取比赛的全部题目,需要User权限,需要当前激活队伍已经报名 * * @tags Game - * @name GameGamesAll - * @summary 获取最新的比赛 - * @request GET:/api/game + * @name GameChallengesWithTeamInfo + * @summary 获取全部比赛题目信息及当前队伍信息 + * @request GET:/api/game/{id}/details */ - useGameGamesAll: (options?: SWRConfiguration, doFetch: boolean = true) => - useSWR(doFetch ? `/api/game` : null, options), + useGameChallengesWithTeamInfo: ( + id: number, + options?: SWRConfiguration, + doFetch: boolean = true + ) => + useSWR(doFetch ? `/api/game/${id}/details` : null, options), /** - * @description 获取最近十个比赛 + * @description 获取比赛的全部题目,需要User权限,需要当前激活队伍已经报名 * * @tags Game - * @name GameGamesAll - * @summary 获取最新的比赛 - * @request GET:/api/game + * @name GameChallengesWithTeamInfo + * @summary 获取全部比赛题目信息及当前队伍信息 + * @request GET:/api/game/{id}/details */ - mutateGameGamesAll: ( - data?: BasicGameInfoModel[] | Promise, + mutateGameChallengesWithTeamInfo: ( + id: number, + data?: GameDetailModel | Promise, options?: MutatorOptions - ) => mutate(`/api/game`, data, options), + ) => mutate(`/api/game/${id}/details`, data, options), /** - * @description 获取比赛的详细信息 + * @description 获取比赛作弊数据,需要Monitor权限 * * @tags Game - * @name GameGames - * @summary 获取比赛详细信息 - * @request GET:/api/game/{id} + * @name GameCheatInfo + * @summary 获取比赛作弊信息 + * @request GET:/api/game/{id}/cheatinfo */ - gameGames: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}`, + gameCheatInfo: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}/cheatinfo`, method: 'GET', format: 'json', ...params, }), /** - * @description 获取比赛的详细信息 + * @description 获取比赛作弊数据,需要Monitor权限 * * @tags Game - * @name GameGames - * @summary 获取比赛详细信息 - * @request GET:/api/game/{id} + * @name GameCheatInfo + * @summary 获取比赛作弊信息 + * @request GET:/api/game/{id}/cheatinfo */ - useGameGames: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR(doFetch ? `/api/game/${id}` : null, options), + useGameCheatInfo: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR( + doFetch ? `/api/game/${id}/cheatinfo` : null, + options + ), /** - * @description 获取比赛的详细信息 + * @description 获取比赛作弊数据,需要Monitor权限 * * @tags Game - * @name GameGames - * @summary 获取比赛详细信息 - * @request GET:/api/game/{id} + * @name GameCheatInfo + * @summary 获取比赛作弊信息 + * @request GET:/api/game/{id}/cheatinfo */ - mutateGameGames: ( + mutateGameCheatInfo: ( id: number, - data?: DetailedGameInfoModel | Promise, + data?: CheatInfoModel[] | Promise, options?: MutatorOptions - ) => mutate(`/api/game/${id}`, data, options), + ) => mutate(`/api/game/${id}/cheatinfo`, data, options), /** - * @description 加入一场比赛,需要User权限 + * @description 创建容器,需要User权限 * * @tags Game - * @name GameJoinGame - * @summary 加入一个比赛 - * @request POST:/api/game/{id} + * @name GameCreateContainer + * @summary 创建容器 + * @request POST:/api/game/{id}/container/{challengeId} */ - gameJoinGame: (id: number, data: GameJoinModel, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}`, + gameCreateContainer: (id: number, challengeId: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}/container/${challengeId}`, method: 'POST', - body: data, - type: ContentType.Json, + format: 'json', ...params, }), /** - * @description 退出一场比赛,需要User权限 + * @description 删除,需要User权限 * * @tags Game - * @name GameLeaveGame - * @summary 退出一个比赛 - * @request DELETE:/api/game/{id} + * @name GameDeleteContainer + * @summary 删除容器 + * @request DELETE:/api/game/{id}/container/{challengeId} */ - gameLeaveGame: (id: number, params: RequestParams = {}) => + gameDeleteContainer: (id: number, challengeId: number, params: RequestParams = {}) => this.request({ - path: `/api/game/${id}`, + path: `/api/game/${id}/container/${challengeId}`, method: 'DELETE', ...params, }), /** - * @description 获取积分榜数据 + * @description 获取比赛事件数据,需要Monitor权限 * * @tags Game - * @name GameScoreboard - * @summary 获取积分榜 - * @request GET:/api/game/{id}/scoreboard + * @name GameEvents + * @summary 获取比赛事件 + * @request GET:/api/game/{id}/events */ - gameScoreboard: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}/scoreboard`, + gameEvents: ( + id: number, + query?: { + /** + * 隐藏容器 + * @default false + */ + hideContainer?: boolean + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/game/${id}/events`, method: 'GET', + query: query, format: 'json', ...params, }), /** - * @description 获取积分榜数据 + * @description 获取比赛事件数据,需要Monitor权限 * * @tags Game - * @name GameScoreboard - * @summary 获取积分榜 - * @request GET:/api/game/{id}/scoreboard - */ - useGameScoreboard: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR( - doFetch ? `/api/game/${id}/scoreboard` : null, - options - ), - - /** - * @description 获取积分榜数据 - * - * @tags Game - * @name GameScoreboard - * @summary 获取积分榜 - * @request GET:/api/game/{id}/scoreboard - */ - mutateGameScoreboard: ( - id: number, - data?: ScoreboardModel | Promise, - options?: MutatorOptions - ) => mutate(`/api/game/${id}/scoreboard`, data, options), - - /** - * @description 获取比赛通知数据 - * - * @tags Game - * @name GameNotices - * @summary 获取比赛通知 - * @request GET:/api/game/{id}/notices + * @name GameEvents + * @summary 获取比赛事件 + * @request GET:/api/game/{id}/events */ - gameNotices: ( + useGameEvents: ( id: number, query?: { /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 + * 隐藏容器 + * @default false */ - skip?: number - }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/game/${id}/notices`, - method: 'GET', - query: query, - format: 'json', - ...params, - }), - /** - * @description 获取比赛通知数据 - * - * @tags Game - * @name GameNotices - * @summary 获取比赛通知 - * @request GET:/api/game/{id}/notices - */ - useGameNotices: ( - id: number, - query?: { + hideContainer?: boolean /** * @format int32 * @default 100 @@ -3656,37 +3636,11 @@ export class Api extends HttpClient - useSWR( - doFetch ? [`/api/game/${id}/notices`, query] : null, + useSWR( + doFetch ? [`/api/game/${id}/events`, query] : null, options ), - /** - * @description 获取比赛通知数据 - * - * @tags Game - * @name GameNotices - * @summary 获取比赛通知 - * @request GET:/api/game/{id}/notices - */ - mutateGameNotices: ( - id: number, - query?: { - /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 - */ - skip?: number - }, - data?: GameNotice[] | Promise, - options?: MutatorOptions - ) => mutate([`/api/game/${id}/notices`, query], data, options), - /** * @description 获取比赛事件数据,需要Monitor权限 * @@ -3695,7 +3649,7 @@ export class Api extends HttpClient extends HttpClient - this.request({ - path: `/api/game/${id}/events`, + data?: GameEvent[] | Promise, + options?: MutatorOptions + ) => mutate([`/api/game/${id}/events`, query], data, options), + + /** + * @description 获取比赛的详细信息 + * + * @tags Game + * @name GameGames + * @summary 获取比赛详细信息 + * @request GET:/api/game/{id} + */ + gameGames: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}`, method: 'GET', - query: query, format: 'json', ...params, }), /** - * @description 获取比赛事件数据,需要Monitor权限 + * @description 获取比赛的详细信息 * * @tags Game - * @name GameEvents - * @summary 获取比赛事件 - * @request GET:/api/game/{id}/events + * @name GameGames + * @summary 获取比赛详细信息 + * @request GET:/api/game/{id} */ - useGameEvents: ( - id: number, - query?: { - /** - * 隐藏容器 - * @default false - */ - hideContainer?: boolean - /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 - */ - skip?: number - }, - options?: SWRConfiguration, - doFetch: boolean = true - ) => - useSWR( - doFetch ? [`/api/game/${id}/events`, query] : null, - options - ), + useGameGames: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR(doFetch ? `/api/game/${id}` : null, options), /** - * @description 获取比赛事件数据,需要Monitor权限 + * @description 获取比赛的详细信息 * * @tags Game - * @name GameEvents - * @summary 获取比赛事件 - * @request GET:/api/game/{id}/events + * @name GameGames + * @summary 获取比赛详细信息 + * @request GET:/api/game/{id} */ - mutateGameEvents: ( + mutateGameGames: ( id: number, - query?: { - /** - * 隐藏容器 - * @default false - */ - hideContainer?: boolean - /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 - */ - skip?: number - }, - data?: GameEvent[] | Promise, + data?: DetailedGameInfoModel | Promise, options?: MutatorOptions - ) => mutate([`/api/game/${id}/events`, query], data, options), + ) => mutate(`/api/game/${id}`, data, options), /** - * @description 获取比赛提交数据,需要Monitor权限 + * @description 获取最近十个比赛 * * @tags Game - * @name GameSubmissions - * @summary 获取比赛提交 - * @request GET:/api/game/{id}/submissions + * @name GameGamesAll + * @summary 获取最新的比赛 + * @request GET:/api/game */ - gameSubmissions: ( - id: number, - query?: { - /** 提交类型 */ - type?: AnswerResult | null - /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 - */ - skip?: number - }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/game/${id}/submissions`, + gameGamesAll: (params: RequestParams = {}) => + this.request({ + path: `/api/game`, method: 'GET', - query: query, format: 'json', ...params, }), /** - * @description 获取比赛提交数据,需要Monitor权限 + * @description 获取最近十个比赛 * * @tags Game - * @name GameSubmissions - * @summary 获取比赛提交 - * @request GET:/api/game/{id}/submissions + * @name GameGamesAll + * @summary 获取最新的比赛 + * @request GET:/api/game */ - useGameSubmissions: ( + useGameGamesAll: (options?: SWRConfiguration, doFetch: boolean = true) => + useSWR(doFetch ? `/api/game` : null, options), + + /** + * @description 获取最近十个比赛 + * + * @tags Game + * @name GameGamesAll + * @summary 获取最新的比赛 + * @request GET:/api/game + */ + mutateGameGamesAll: ( + data?: BasicGameInfoModel[] | Promise, + options?: MutatorOptions + ) => mutate(`/api/game`, data, options), + + /** + * @description 获取比赛题目信息,需要User权限,需要当前激活队伍已经报名 + * + * @tags Game + * @name GameGetChallenge + * @summary 获取比赛题目信息 + * @request GET:/api/game/{id}/challenges/{challengeId} + */ + gameGetChallenge: (id: number, challengeId: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}/challenges/${challengeId}`, + method: 'GET', + format: 'json', + ...params, + }), + /** + * @description 获取比赛题目信息,需要User权限,需要当前激活队伍已经报名 + * + * @tags Game + * @name GameGetChallenge + * @summary 获取比赛题目信息 + * @request GET:/api/game/{id}/challenges/{challengeId} + */ + useGameGetChallenge: ( id: number, - query?: { - /** 提交类型 */ - type?: AnswerResult | null - /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 - */ - skip?: number - }, + challengeId: number, options?: SWRConfiguration, doFetch: boolean = true ) => - useSWR( - doFetch ? [`/api/game/${id}/submissions`, query] : null, + useSWR( + doFetch ? `/api/game/${id}/challenges/${challengeId}` : null, options ), /** - * @description 获取比赛提交数据,需要Monitor权限 + * @description 获取比赛题目信息,需要User权限,需要当前激活队伍已经报名 * * @tags Game - * @name GameSubmissions - * @summary 获取比赛提交 - * @request GET:/api/game/{id}/submissions + * @name GameGetChallenge + * @summary 获取比赛题目信息 + * @request GET:/api/game/{id}/challenges/{challengeId} */ - mutateGameSubmissions: ( + mutateGameGetChallenge: ( id: number, - query?: { - /** 提交类型 */ - type?: AnswerResult | null - /** - * @format int32 - * @default 100 - */ - count?: number - /** - * @format int32 - * @default 0 - */ - skip?: number - }, - data?: Submission[] | Promise, + challengeId: number, + data?: ChallengeDetailModel | Promise, options?: MutatorOptions - ) => mutate([`/api/game/${id}/submissions`, query], data, options), + ) => mutate(`/api/game/${id}/challenges/${challengeId}`, data, options), /** - * @description 获取比赛作弊数据,需要Monitor权限 + * @description 获取赛后题解提交情况,需要User权限 * * @tags Game - * @name GameCheatInfo - * @summary 获取比赛作弊信息 - * @request GET:/api/game/{id}/cheatinfo + * @name GameGetWriteup + * @summary 获取 Writeup 信息 + * @request GET:/api/game/{id}/writeup */ - gameCheatInfo: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}/cheatinfo`, + gameGetWriteup: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}/writeup`, method: 'GET', format: 'json', ...params, }), /** - * @description 获取比赛作弊数据,需要Monitor权限 + * @description 获取赛后题解提交情况,需要User权限 * * @tags Game - * @name GameCheatInfo - * @summary 获取比赛作弊信息 - * @request GET:/api/game/{id}/cheatinfo + * @name GameGetWriteup + * @summary 获取 Writeup 信息 + * @request GET:/api/game/{id}/writeup */ - useGameCheatInfo: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR( - doFetch ? `/api/game/${id}/cheatinfo` : null, + useGameGetWriteup: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR( + doFetch ? `/api/game/${id}/writeup` : null, options ), /** - * @description 获取比赛作弊数据,需要Monitor权限 + * @description 获取赛后题解提交情况,需要User权限 * * @tags Game - * @name GameCheatInfo - * @summary 获取比赛作弊信息 - * @request GET:/api/game/{id}/cheatinfo + * @name GameGetWriteup + * @summary 获取 Writeup 信息 + * @request GET:/api/game/{id}/writeup */ - mutateGameCheatInfo: ( + mutateGameGetWriteup: ( id: number, - data?: CheatInfoModel[] | Promise, + data?: BasicWriteupInfoModel | Promise, options?: MutatorOptions - ) => mutate(`/api/game/${id}/cheatinfo`, data, options), + ) => mutate(`/api/game/${id}/writeup`, data, options), /** - * @description 获取比赛的全部题目,需要User权限,需要当前激活队伍已经报名 + * @description 加入一场比赛,需要User权限 * * @tags Game - * @name GameChallengesWithTeamInfo - * @summary 获取全部比赛题目信息及当前队伍信息 - * @request GET:/api/game/{id}/details + * @name GameJoinGame + * @summary 加入一个比赛 + * @request POST:/api/game/{id} */ - gameChallengesWithTeamInfo: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}/details`, + gameJoinGame: (id: number, data: GameJoinModel, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}`, + method: 'POST', + body: data, + type: ContentType.Json, + ...params, + }), + + /** + * @description 退出一场比赛,需要User权限 + * + * @tags Game + * @name GameLeaveGame + * @summary 退出一个比赛 + * @request DELETE:/api/game/{id} + */ + gameLeaveGame: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}`, + method: 'DELETE', + ...params, + }), + + /** + * @description 获取比赛通知数据 + * + * @tags Game + * @name GameNotices + * @summary 获取比赛通知 + * @request GET:/api/game/{id}/notices + */ + gameNotices: ( + id: number, + query?: { + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/game/${id}/notices`, method: 'GET', + query: query, format: 'json', ...params, }), /** - * @description 获取比赛的全部题目,需要User权限,需要当前激活队伍已经报名 + * @description 获取比赛通知数据 * * @tags Game - * @name GameChallengesWithTeamInfo - * @summary 获取全部比赛题目信息及当前队伍信息 - * @request GET:/api/game/{id}/details + * @name GameNotices + * @summary 获取比赛通知 + * @request GET:/api/game/{id}/notices */ - useGameChallengesWithTeamInfo: ( + useGameNotices: ( id: number, + query?: { + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, options?: SWRConfiguration, doFetch: boolean = true ) => - useSWR(doFetch ? `/api/game/${id}/details` : null, options), + useSWR( + doFetch ? [`/api/game/${id}/notices`, query] : null, + options + ), /** - * @description 获取比赛的全部题目,需要User权限,需要当前激活队伍已经报名 + * @description 获取比赛通知数据 * * @tags Game - * @name GameChallengesWithTeamInfo - * @summary 获取全部比赛题目信息及当前队伍信息 - * @request GET:/api/game/{id}/details + * @name GameNotices + * @summary 获取比赛通知 + * @request GET:/api/game/{id}/notices */ - mutateGameChallengesWithTeamInfo: ( + mutateGameNotices: ( id: number, - data?: GameDetailModel | Promise, + query?: { + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, + data?: GameNotice[] | Promise, options?: MutatorOptions - ) => mutate(`/api/game/${id}/details`, data, options), + ) => mutate([`/api/game/${id}/notices`, query], data, options), /** * @description 获取比赛的全部题目参与信息,需要Admin权限 @@ -4013,253 +4006,313 @@ export class Api extends HttpClient mutate(`/api/game/${id}/participations`, data, options), /** - * @description 下载比赛积分榜,需要Monitor权限 + * @description 延长容器时间,需要User权限,且只能在到期前十分钟延期两小时 * * @tags Game - * @name GameScoreboardSheet - * @summary 下载比赛积分榜 - * @request GET:/api/game/{id}/scoreboardsheet + * @name GameProlongContainer + * @summary 延长容器时间 + * @request POST:/api/game/{id}/container/{challengeId}/prolong */ - gameScoreboardSheet: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}/scoreboardsheet`, + gameProlongContainer: (id: number, challengeId: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}/container/${challengeId}/prolong`, + method: 'POST', + format: 'json', + ...params, + }), + + /** + * @description 获取积分榜数据 + * + * @tags Game + * @name GameScoreboard + * @summary 获取积分榜 + * @request GET:/api/game/{id}/scoreboard + */ + gameScoreboard: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}/scoreboard`, method: 'GET', + format: 'json', ...params, }), /** - * @description 下载比赛积分榜,需要Monitor权限 + * @description 获取积分榜数据 * * @tags Game - * @name GameScoreboardSheet - * @summary 下载比赛积分榜 - * @request GET:/api/game/{id}/scoreboardsheet + * @name GameScoreboard + * @summary 获取积分榜 + * @request GET:/api/game/{id}/scoreboard */ - useGameScoreboardSheet: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR(doFetch ? `/api/game/${id}/scoreboardsheet` : null, options), + useGameScoreboard: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR( + doFetch ? `/api/game/${id}/scoreboard` : null, + options + ), /** - * @description 下载比赛积分榜,需要Monitor权限 + * @description 获取积分榜数据 * * @tags Game - * @name GameScoreboardSheet - * @summary 下载比赛积分榜 - * @request GET:/api/game/{id}/scoreboardsheet + * @name GameScoreboard + * @summary 获取积分榜 + * @request GET:/api/game/{id}/scoreboard */ - mutateGameScoreboardSheet: ( + mutateGameScoreboard: ( id: number, - data?: void | Promise, + data?: ScoreboardModel | Promise, options?: MutatorOptions - ) => mutate(`/api/game/${id}/scoreboardsheet`, data, options), + ) => mutate(`/api/game/${id}/scoreboard`, data, options), /** - * @description 下载比赛全部提交,需要Monitor权限 + * @description 下载比赛积分榜,需要Monitor权限 * * @tags Game - * @name GameSubmissionSheet - * @summary 下载比赛全部提交 - * @request GET:/api/game/{id}/submissionsheet + * @name GameScoreboardSheet + * @summary 下载比赛积分榜 + * @request GET:/api/game/{id}/scoreboardsheet */ - gameSubmissionSheet: (id: number, params: RequestParams = {}) => + gameScoreboardSheet: (id: number, params: RequestParams = {}) => this.request({ - path: `/api/game/${id}/submissionsheet`, + path: `/api/game/${id}/scoreboardsheet`, method: 'GET', ...params, }), /** - * @description 下载比赛全部提交,需要Monitor权限 + * @description 下载比赛积分榜,需要Monitor权限 * * @tags Game - * @name GameSubmissionSheet - * @summary 下载比赛全部提交 - * @request GET:/api/game/{id}/submissionsheet + * @name GameScoreboardSheet + * @summary 下载比赛积分榜 + * @request GET:/api/game/{id}/scoreboardsheet */ - useGameSubmissionSheet: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR(doFetch ? `/api/game/${id}/submissionsheet` : null, options), + useGameScoreboardSheet: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR(doFetch ? `/api/game/${id}/scoreboardsheet` : null, options), /** - * @description 下载比赛全部提交,需要Monitor权限 + * @description 下载比赛积分榜,需要Monitor权限 * * @tags Game - * @name GameSubmissionSheet - * @summary 下载比赛全部提交 - * @request GET:/api/game/{id}/submissionsheet + * @name GameScoreboardSheet + * @summary 下载比赛积分榜 + * @request GET:/api/game/{id}/scoreboardsheet */ - mutateGameSubmissionSheet: ( + mutateGameScoreboardSheet: ( id: number, data?: void | Promise, options?: MutatorOptions - ) => mutate(`/api/game/${id}/submissionsheet`, data, options), + ) => mutate(`/api/game/${id}/scoreboardsheet`, data, options), /** - * @description 获取比赛题目信息,需要User权限,需要当前激活队伍已经报名 + * @description 查询 flag 状态,需要User权限 * * @tags Game - * @name GameGetChallenge - * @summary 获取比赛题目信息 - * @request GET:/api/game/{id}/challenges/{challengeId} + * @name GameStatus + * @summary 查询 flag 状态 + * @request GET:/api/game/{id}/challenges/{challengeId}/status/{submitId} */ - gameGetChallenge: (id: number, challengeId: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}/challenges/${challengeId}`, + gameStatus: (id: number, challengeId: number, submitId: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}/challenges/${challengeId}/status/${submitId}`, method: 'GET', format: 'json', ...params, }), /** - * @description 获取比赛题目信息,需要User权限,需要当前激活队伍已经报名 + * @description 查询 flag 状态,需要User权限 * * @tags Game - * @name GameGetChallenge - * @summary 获取比赛题目信息 - * @request GET:/api/game/{id}/challenges/{challengeId} + * @name GameStatus + * @summary 查询 flag 状态 + * @request GET:/api/game/{id}/challenges/{challengeId}/status/{submitId} */ - useGameGetChallenge: ( + useGameStatus: ( id: number, challengeId: number, + submitId: number, options?: SWRConfiguration, doFetch: boolean = true ) => - useSWR( - doFetch ? `/api/game/${id}/challenges/${challengeId}` : null, + useSWR( + doFetch ? `/api/game/${id}/challenges/${challengeId}/status/${submitId}` : null, options ), /** - * @description 获取比赛题目信息,需要User权限,需要当前激活队伍已经报名 + * @description 查询 flag 状态,需要User权限 * * @tags Game - * @name GameGetChallenge - * @summary 获取比赛题目信息 - * @request GET:/api/game/{id}/challenges/{challengeId} + * @name GameStatus + * @summary 查询 flag 状态 + * @request GET:/api/game/{id}/challenges/{challengeId}/status/{submitId} */ - mutateGameGetChallenge: ( + mutateGameStatus: ( id: number, challengeId: number, - data?: ChallengeDetailModel | Promise, + submitId: number, + data?: AnswerResult | Promise, options?: MutatorOptions - ) => mutate(`/api/game/${id}/challenges/${challengeId}`, data, options), - - /** - * @description 提交 flag,需要User权限,需要当前激活队伍已经报名 - * - * @tags Game - * @name GameSubmit - * @summary 提交 flag - * @request POST:/api/game/{id}/challenges/{challengeId} - */ - gameSubmit: ( - id: number, - challengeId: number, - data: FlagSubmitModel, - params: RequestParams = {} ) => - this.request({ - path: `/api/game/${id}/challenges/${challengeId}`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params, - }), + mutate( + `/api/game/${id}/challenges/${challengeId}/status/${submitId}`, + data, + options + ), /** - * @description 查询 flag 状态,需要User权限 + * @description 获取比赛提交数据,需要Monitor权限 * * @tags Game - * @name GameStatus - * @summary 查询 flag 状态 - * @request GET:/api/game/{id}/challenges/{challengeId}/status/{submitId} + * @name GameSubmissions + * @summary 获取比赛提交 + * @request GET:/api/game/{id}/submissions */ - gameStatus: (id: number, challengeId: number, submitId: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}/challenges/${challengeId}/status/${submitId}`, + gameSubmissions: ( + id: number, + query?: { + /** 提交类型 */ + type?: AnswerResult | null + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/game/${id}/submissions`, method: 'GET', + query: query, format: 'json', ...params, }), /** - * @description 查询 flag 状态,需要User权限 + * @description 获取比赛提交数据,需要Monitor权限 * * @tags Game - * @name GameStatus - * @summary 查询 flag 状态 - * @request GET:/api/game/{id}/challenges/{challengeId}/status/{submitId} + * @name GameSubmissions + * @summary 获取比赛提交 + * @request GET:/api/game/{id}/submissions */ - useGameStatus: ( + useGameSubmissions: ( id: number, - challengeId: number, - submitId: number, + query?: { + /** 提交类型 */ + type?: AnswerResult | null + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, options?: SWRConfiguration, doFetch: boolean = true ) => - useSWR( - doFetch ? `/api/game/${id}/challenges/${challengeId}/status/${submitId}` : null, + useSWR( + doFetch ? [`/api/game/${id}/submissions`, query] : null, options ), /** - * @description 查询 flag 状态,需要User权限 + * @description 获取比赛提交数据,需要Monitor权限 * * @tags Game - * @name GameStatus - * @summary 查询 flag 状态 - * @request GET:/api/game/{id}/challenges/{challengeId}/status/{submitId} + * @name GameSubmissions + * @summary 获取比赛提交 + * @request GET:/api/game/{id}/submissions */ - mutateGameStatus: ( + mutateGameSubmissions: ( id: number, - challengeId: number, - submitId: number, - data?: AnswerResult | Promise, + query?: { + /** 提交类型 */ + type?: AnswerResult | null + /** + * @format int32 + * @default 100 + */ + count?: number + /** + * @format int32 + * @default 0 + */ + skip?: number + }, + data?: Submission[] | Promise, options?: MutatorOptions - ) => - mutate( - `/api/game/${id}/challenges/${challengeId}/status/${submitId}`, - data, - options - ), + ) => mutate([`/api/game/${id}/submissions`, query], data, options), /** - * @description 获取赛后题解提交情况,需要User权限 + * @description 下载比赛全部提交,需要Monitor权限 * * @tags Game - * @name GameGetWriteup - * @summary 获取 Writeup 信息 - * @request GET:/api/game/{id}/writeup + * @name GameSubmissionSheet + * @summary 下载比赛全部提交 + * @request GET:/api/game/{id}/submissionsheet */ - gameGetWriteup: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}/writeup`, + gameSubmissionSheet: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/game/${id}/submissionsheet`, method: 'GET', - format: 'json', ...params, }), /** - * @description 获取赛后题解提交情况,需要User权限 + * @description 下载比赛全部提交,需要Monitor权限 * * @tags Game - * @name GameGetWriteup - * @summary 获取 Writeup 信息 - * @request GET:/api/game/{id}/writeup + * @name GameSubmissionSheet + * @summary 下载比赛全部提交 + * @request GET:/api/game/{id}/submissionsheet */ - useGameGetWriteup: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR( - doFetch ? `/api/game/${id}/writeup` : null, - options - ), + useGameSubmissionSheet: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR(doFetch ? `/api/game/${id}/submissionsheet` : null, options), /** - * @description 获取赛后题解提交情况,需要User权限 + * @description 下载比赛全部提交,需要Monitor权限 * * @tags Game - * @name GameGetWriteup - * @summary 获取 Writeup 信息 - * @request GET:/api/game/{id}/writeup + * @name GameSubmissionSheet + * @summary 下载比赛全部提交 + * @request GET:/api/game/{id}/submissionsheet */ - mutateGameGetWriteup: ( + mutateGameSubmissionSheet: ( id: number, - data?: BasicWriteupInfoModel | Promise, + data?: void | Promise, options?: MutatorOptions - ) => mutate(`/api/game/${id}/writeup`, data, options), + ) => mutate(`/api/game/${id}/submissionsheet`, data, options), + + /** + * @description 提交 flag,需要User权限,需要当前激活队伍已经报名 + * + * @tags Game + * @name GameSubmit + * @summary 提交 flag + * @request POST:/api/game/{id}/challenges/{challengeId} + */ + gameSubmit: ( + id: number, + challengeId: number, + data: FlagSubmitModel, + params: RequestParams = {} + ) => + this.request({ + path: `/api/game/${id}/challenges/${challengeId}`, + method: 'POST', + body: data, + type: ContentType.Json, + format: 'json', + ...params, + }), /** * @description 提交赛后题解,需要User权限 @@ -4284,55 +4337,47 @@ export class Api extends HttpClient - this.request({ - path: `/api/game/${id}/container/${challengeId}`, - method: 'POST', + infoGetGlobalConfig: (params: RequestParams = {}) => + this.request({ + path: `/api/config`, + method: 'GET', format: 'json', ...params, }), - /** - * @description 删除,需要User权限 + * @description 获取全局设置 * - * @tags Game - * @name GameDeleteContainer - * @summary 删除容器 - * @request DELETE:/api/game/{id}/container/{challengeId} + * @tags Info + * @name InfoGetGlobalConfig + * @summary 获取全局设置 + * @request GET:/api/config */ - gameDeleteContainer: (id: number, challengeId: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}/container/${challengeId}`, - method: 'DELETE', - ...params, - }), + useInfoGetGlobalConfig: (options?: SWRConfiguration, doFetch: boolean = true) => + useSWR(doFetch ? `/api/config` : null, options), /** - * @description 延长容器时间,需要User权限,且只能在到期前十分钟延期两小时 + * @description 获取全局设置 * - * @tags Game - * @name GameProlongContainer - * @summary 延长容器时间 - * @request POST:/api/game/{id}/container/{challengeId}/prolong + * @tags Info + * @name InfoGetGlobalConfig + * @summary 获取全局设置 + * @request GET:/api/config */ - gameProlongContainer: (id: number, challengeId: number, params: RequestParams = {}) => - this.request({ - path: `/api/game/${id}/container/${challengeId}/prolong`, - method: 'POST', - format: 'json', - ...params, - }), - } - info = { + mutateInfoGetGlobalConfig: ( + data?: GlobalConfig | Promise, + options?: MutatorOptions + ) => mutate(`/api/config`, data, options), + /** * @description 获取最新文章 * @@ -4372,45 +4417,6 @@ export class Api extends HttpClient mutate(`/api/posts/latest`, data, options), - /** - * @description 获取全部文章 - * - * @tags Info - * @name InfoGetPosts - * @summary 获取全部文章 - * @request GET:/api/posts - */ - infoGetPosts: (params: RequestParams = {}) => - this.request({ - path: `/api/posts`, - method: 'GET', - format: 'json', - ...params, - }), - /** - * @description 获取全部文章 - * - * @tags Info - * @name InfoGetPosts - * @summary 获取全部文章 - * @request GET:/api/posts - */ - useInfoGetPosts: (options?: SWRConfiguration, doFetch: boolean = true) => - useSWR(doFetch ? `/api/posts` : null, options), - - /** - * @description 获取全部文章 - * - * @tags Info - * @name InfoGetPosts - * @summary 获取全部文章 - * @request GET:/api/posts - */ - mutateInfoGetPosts: ( - data?: PostInfoModel[] | Promise, - options?: MutatorOptions - ) => mutate(`/api/posts`, data, options), - /** * @description 获取文章详情 * @@ -4452,43 +4458,43 @@ export class Api extends HttpClient mutate(`/api/posts/${id}`, data, options), /** - * @description 获取全局设置 + * @description 获取全部文章 * * @tags Info - * @name InfoGetGlobalConfig - * @summary 获取全局设置 - * @request GET:/api/config + * @name InfoGetPosts + * @summary 获取全部文章 + * @request GET:/api/posts */ - infoGetGlobalConfig: (params: RequestParams = {}) => - this.request({ - path: `/api/config`, + infoGetPosts: (params: RequestParams = {}) => + this.request({ + path: `/api/posts`, method: 'GET', format: 'json', ...params, }), /** - * @description 获取全局设置 + * @description 获取全部文章 * * @tags Info - * @name InfoGetGlobalConfig - * @summary 获取全局设置 - * @request GET:/api/config + * @name InfoGetPosts + * @summary 获取全部文章 + * @request GET:/api/posts */ - useInfoGetGlobalConfig: (options?: SWRConfiguration, doFetch: boolean = true) => - useSWR(doFetch ? `/api/config` : null, options), + useInfoGetPosts: (options?: SWRConfiguration, doFetch: boolean = true) => + useSWR(doFetch ? `/api/posts` : null, options), /** - * @description 获取全局设置 + * @description 获取全部文章 * * @tags Info - * @name InfoGetGlobalConfig - * @summary 获取全局设置 - * @request GET:/api/config + * @name InfoGetPosts + * @summary 获取全部文章 + * @request GET:/api/posts */ - mutateInfoGetGlobalConfig: ( - data?: GlobalConfig | Promise, + mutateInfoGetPosts: ( + data?: PostInfoModel[] | Promise, options?: MutatorOptions - ) => mutate(`/api/config`, data, options), + ) => mutate(`/api/posts`, data, options), /** * @description 获取 Recaptcha SiteKey @@ -4529,57 +4535,59 @@ export class Api extends HttpClient - this.request({ - path: `/api/team/${id}`, - method: 'GET', - format: 'json', + teamAccept: (data: string, params: RequestParams = {}) => + this.request({ + path: `/api/team/accept`, + method: 'POST', + body: data, + type: ContentType.Json, ...params, }), - /** - * @description 根据 id 获取一个队伍的基本信息 - * - * @tags Team - * @name TeamGetBasicInfo - * @summary 获取队伍信息 - * @request GET:/api/team/{id} - */ - useTeamGetBasicInfo: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => - useSWR(doFetch ? `/api/team/${id}` : null, options), /** - * @description 根据 id 获取一个队伍的基本信息 + * @description 使用此接口更新队伍头像,需要User权限,且为队伍成员 * * @tags Team - * @name TeamGetBasicInfo - * @summary 获取队伍信息 - * @request GET:/api/team/{id} + * @name TeamAvatar + * @summary 更新队伍头像接口 + * @request PUT:/api/team/{id}/avatar */ - mutateTeamGetBasicInfo: ( + teamAvatar: ( id: number, - data?: TeamInfoModel | Promise, - options?: MutatorOptions - ) => mutate(`/api/team/${id}`, data, options), + data: { + /** @format binary */ + file?: File + }, + params: RequestParams = {} + ) => + this.request({ + path: `/api/team/${id}/avatar`, + method: 'PUT', + body: data, + type: ContentType.FormData, + format: 'json', + ...params, + }), /** - * @description 队伍信息更改接口,需要为队伍创建者 + * @description 用户创建队伍接口,每个用户只能创建一个队伍 * * @tags Team - * @name TeamUpdateTeam - * @summary 更改队伍信息 - * @request PUT:/api/team/{id} + * @name TeamCreateTeam + * @summary 创建队伍 + * @request POST:/api/team */ - teamUpdateTeam: (id: number, data: TeamUpdateModel, params: RequestParams = {}) => + teamCreateTeam: (data: TeamUpdateModel, params: RequestParams = {}) => this.request({ - path: `/api/team/${id}`, - method: 'PUT', + path: `/api/team`, + method: 'POST', body: data, type: ContentType.Json, format: 'json', @@ -4602,6 +4610,46 @@ export class Api extends HttpClient + this.request({ + path: `/api/team/${id}`, + method: 'GET', + format: 'json', + ...params, + }), + /** + * @description 根据 id 获取一个队伍的基本信息 + * + * @tags Team + * @name TeamGetBasicInfo + * @summary 获取队伍信息 + * @request GET:/api/team/{id} + */ + useTeamGetBasicInfo: (id: number, options?: SWRConfiguration, doFetch: boolean = true) => + useSWR(doFetch ? `/api/team/${id}` : null, options), + + /** + * @description 根据 id 获取一个队伍的基本信息 + * + * @tags Team + * @name TeamGetBasicInfo + * @summary 获取队伍信息 + * @request GET:/api/team/{id} + */ + mutateTeamGetBasicInfo: ( + id: number, + data?: TeamInfoModel | Promise, + options?: MutatorOptions + ) => mutate(`/api/team/${id}`, data, options), + /** * @description 根据用户获取一个队伍的基本信息 * @@ -4641,42 +4689,6 @@ export class Api extends HttpClient mutate(`/api/team`, data, options), - /** - * @description 用户创建队伍接口,每个用户只能创建一个队伍 - * - * @tags Team - * @name TeamCreateTeam - * @summary 创建队伍 - * @request POST:/api/team - */ - teamCreateTeam: (data: TeamUpdateModel, params: RequestParams = {}) => - this.request({ - path: `/api/team`, - method: 'POST', - body: data, - type: ContentType.Json, - format: 'json', - ...params, - }), - - /** - * @description 移交队伍所有权接口,需要为队伍创建者 - * - * @tags Team - * @name TeamTransfer - * @summary 移交队伍所有权 - * @request PUT:/api/team/{id}/transfer - */ - teamTransfer: (id: number, data: TeamTransferModel, params: RequestParams = {}) => - this.request({ - path: `/api/team/${id}/transfer`, - method: 'PUT', - body: data, - type: ContentType.Json, - format: 'json', - ...params, - }), - /** * @description 获取队伍邀请信息,需要为队伍创建者 * @@ -4714,22 +4726,6 @@ export class Api extends HttpClient, options?: MutatorOptions) => mutate(`/api/team/${id}/invite`, data, options), - /** - * @description 更新邀请 Token 的接口,需要为队伍创建者 - * - * @tags Team - * @name TeamUpdateInviteToken - * @summary 更新邀请 Token - * @request PUT:/api/team/{id}/invite - */ - teamUpdateInviteToken: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/team/${id}/invite`, - method: 'PUT', - format: 'json', - ...params, - }), - /** * @description 踢除用户接口,踢出对应id的用户,需要队伍创建者权限 * @@ -4747,58 +4743,68 @@ export class Api extends HttpClient + teamLeave: (id: number, params: RequestParams = {}) => this.request({ - path: `/api/team/accept`, + path: `/api/team/${id}/leave`, method: 'POST', + ...params, + }), + + /** + * @description 移交队伍所有权接口,需要为队伍创建者 + * + * @tags Team + * @name TeamTransfer + * @summary 移交队伍所有权 + * @request PUT:/api/team/{id}/transfer + */ + teamTransfer: (id: number, data: TeamTransferModel, params: RequestParams = {}) => + this.request({ + path: `/api/team/${id}/transfer`, + method: 'PUT', body: data, type: ContentType.Json, + format: 'json', ...params, }), /** - * @description 离开队伍的接口,需要User权限,且在队伍中 + * @description 更新邀请 Token 的接口,需要为队伍创建者 * * @tags Team - * @name TeamLeave - * @summary 离开队伍 - * @request POST:/api/team/{id}/leave + * @name TeamUpdateInviteToken + * @summary 更新邀请 Token + * @request PUT:/api/team/{id}/invite */ - teamLeave: (id: number, params: RequestParams = {}) => - this.request({ - path: `/api/team/${id}/leave`, - method: 'POST', + teamUpdateInviteToken: (id: number, params: RequestParams = {}) => + this.request({ + path: `/api/team/${id}/invite`, + method: 'PUT', + format: 'json', ...params, }), /** - * @description 使用此接口更新队伍头像,需要User权限,且为队伍成员 + * @description 队伍信息更改接口,需要为队伍创建者 * * @tags Team - * @name TeamAvatar - * @summary 更新队伍头像接口 - * @request PUT:/api/team/{id}/avatar + * @name TeamUpdateTeam + * @summary 更改队伍信息 + * @request PUT:/api/team/{id} */ - teamAvatar: ( - id: number, - data: { - /** @format binary */ - file?: File - }, - params: RequestParams = {} - ) => - this.request({ - path: `/api/team/${id}/avatar`, + teamUpdateTeam: (id: number, data: TeamUpdateModel, params: RequestParams = {}) => + this.request({ + path: `/api/team/${id}`, method: 'PUT', body: data, - type: ContentType.FormData, + type: ContentType.Json, format: 'json', ...params, }), diff --git a/src/GZCTF/ClientApp/template/http-client.eta b/src/GZCTF/ClientApp/template/http-client.eta index bcb518f3d..d0acff015 100644 --- a/src/GZCTF/ClientApp/template/http-client.eta +++ b/src/GZCTF/ClientApp/template/http-client.eta @@ -2,7 +2,8 @@ const { apiConfig, generateResponses, config } = it; %> -import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, ResponseType } from "axios"; +import type { AxiosInstance, AxiosRequestConfig, HeadersDefaults, ResponseType, AxiosResponse } from "axios"; +import axios from "axios"; export type QueryParamsType = Record; @@ -33,6 +34,7 @@ export enum ContentType { Json = "application/json", FormData = "multipart/form-data", UrlEncoded = "application/x-www-form-urlencoded", + Text = "text/plain", } export class HttpClient { @@ -53,40 +55,44 @@ export class HttpClient { this.securityData = data } - private mergeRequestParams(params1: AxiosRequestConfig, params2?: AxiosRequestConfig): AxiosRequestConfig { - return { - ...this.instance.defaults, - ...params1, - ...(params2 || {}), - headers: Object.assign({}, this.instance.defaults.headers, (params1 || {}).headers, (params2 || {}).headers) - }; + protected mergeRequestParams(params1: AxiosRequestConfig, params2?: AxiosRequestConfig): AxiosRequestConfig { + const method = params1.method || (params2 && params2.method) + + return { + ...this.instance.defaults, + ...params1, + ...(params2 || {}), + headers: { + ...((method && this.instance.defaults.headers[method.toLowerCase() as keyof HeadersDefaults]) || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + protected stringifyFormItem(formItem: unknown) { + if (typeof formItem === "object" && formItem !== null) { + return JSON.stringify(formItem); + } else { + return `${formItem}`; + } } - private createFormData(input: Record): FormData { + protected createFormData(input: Record): FormData { return Object.keys(input || {}).reduce((formData, key) => { const property = input[key]; - if (Array.isArray(property)) { - property.forEach((blob) => { - formData.append(key, - blob instanceof Blob - ? blob - : typeof blob === 'object' && blob !== null - ? JSON.stringify(blob) - : `${blob}` - ) - }) - } else { - formData.append( - key, - property instanceof Blob - ? property - : typeof property === 'object' && property !== null - ? JSON.stringify(property) - : `${property}` - ) - } - return formData; - }, new FormData()) + const propertyContent: any[] = (property instanceof Array) ? property : [property] + + for (const formItem of propertyContent) { + const isFileType = formItem instanceof Blob || formItem instanceof File; + formData.append( + key, + isFileType ? formItem : this.stringifyFormItem(formItem) + ); + } + + return formData; + }, new FormData()); } public request = async ({ @@ -104,22 +110,22 @@ export class HttpClient { <% } %> const secureParams = ((typeof secure === 'boolean' ? secure : this.secure) && this.securityWorker && (await this.securityWorker(this.securityData))) || {}; const requestParams = this.mergeRequestParams(params, secureParams); - const responseFormat = (format && this.format) || void 0; + const responseFormat = (format || this.format) || undefined; if (type === ContentType.FormData && body && body !== null && typeof body === "object") { - if (!requestParams.headers) - requestParams.headers = { Accept: '*/*' } - body = this.createFormData(body as Record); } + if (type === ContentType.Text && body && body !== null && typeof body !== "string") { + body = JSON.stringify(body); + } + return this.instance.request({ ...requestParams, - headers: Object.assign( - {}, - requestParams.headers, - type && type !== ContentType.FormData ? { 'Content-Type': type } : {} - ), + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, params: query, responseType: responseFormat, data: body,