Skip to content

Commit

Permalink
fix: wrong API type declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Aug 19, 2023
1 parent 9bb7d35 commit 1dc0489
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
32 changes: 28 additions & 4 deletions src/GZCTF/ClientApp/src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,30 @@ export interface ParticipationModel {
organization?: string | null
}

export interface ChallengeTrafficModel {
/**
* 题目Id
* @format int32
*/
id?: number
/**
* 题目名称
* @minLength 1
*/
title: string
/** 题目标签 */
tag?: ChallengeTag
/** 题目类型 */
type?: ChallengeType
/** 是否启用题目 */
isEnabled?: boolean
/**
* 题目所捕获到的队伍流量数量
* @format int32
*/
count?: number
}

/** 队伍流量获取信息 */
export interface TeamTrafficModel {
/**
Expand Down Expand Up @@ -3787,7 +3811,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
* @request GET:/api/game/games/{id}/captures
*/
gameGetChallengesWithTrafficCapturing: (id: number, params: RequestParams = {}) =>
this.request<ChallengeInfoModel[], RequestResponse>({
this.request<ChallengeTrafficModel[], RequestResponse>({
path: `/api/game/games/${id}/captures`,
method: 'GET',
format: 'json',
Expand All @@ -3806,7 +3830,7 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
options?: SWRConfiguration,
doFetch: boolean = true
) =>
useSWR<ChallengeInfoModel[], RequestResponse>(
useSWR<ChallengeTrafficModel[], RequestResponse>(
doFetch ? `/api/game/games/${id}/captures` : null,
options
),
Expand All @@ -3821,9 +3845,9 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
*/
mutateGameGetChallengesWithTrafficCapturing: (
id: number,
data?: ChallengeInfoModel[] | Promise<ChallengeInfoModel[]>,
data?: ChallengeTrafficModel[] | Promise<ChallengeTrafficModel[]>,
options?: MutatorOptions
) => mutate<ChallengeInfoModel[]>(`/api/game/games/${id}/captures`, data, options),
) => mutate<ChallengeTrafficModel[]>(`/api/game/games/${id}/captures`, data, options),

/**
* @description 获取比赛题目中捕获到到队伍信息,需要Monitor权限
Expand Down
4 changes: 2 additions & 2 deletions src/GZCTF/Controllers/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,11 @@ public async Task<IActionResult> CheatInfo([FromRoute] int id, CancellationToken
/// </remarks>
/// <param name="id">比赛Id</param>
/// <param name="token"></param>
/// <response code="200">成功获取文件列表</response>
/// <response code="200">成功获取题目列表</response>
/// <response code="404">未找到相关捕获信息</response>
[RequireMonitor]
[HttpGet("Games/{id}/Captures")]
[ProducesResponseType(typeof(ChallengeInfoModel[]), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ChallengeTrafficModel[]), StatusCodes.Status200OK)]
public async Task<IActionResult> GetChallengesWithTrafficCapturing([FromRoute] int id, CancellationToken token)
=> Ok((await _challengeRepository.GetChallengesWithTrafficCapturing(id, token))
.Select(ChallengeTrafficModel.FromChallenge));
Expand Down

0 comments on commit 1dc0489

Please sign in to comment.