perf: 支持分享提交答案的接口
This commit is contained in:
@@ -11,13 +11,13 @@ import {
|
||||
CreateShareResponseDto,
|
||||
CreatedShareListResponseDto,
|
||||
JoinShareResponseDto,
|
||||
SubmitShareChallengeResponseDto,
|
||||
} from './dto/share-response.dto';
|
||||
import { ApiResponseDto } from '../../common/dto/api-response.dto';
|
||||
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
|
||||
import type { JwtPayload } from '../../common/guards/jwt-auth.guard';
|
||||
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
||||
import { ReportLevelProgressDto } from './dto/report-level-progress.dto';
|
||||
import { ReportLevelProgressResponseDto } from './dto/share-level-progress-response.dto';
|
||||
import { SubmitShareChallengeDto } from './dto/submit-share-challenge.dto';
|
||||
|
||||
@ApiTags('分享挑战')
|
||||
@Controller('v1/share')
|
||||
@@ -73,20 +73,22 @@ export class ShareController {
|
||||
return ApiResponseDto.success(data);
|
||||
}
|
||||
|
||||
@Post('progress')
|
||||
@Post(':code/submit')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({
|
||||
summary: '上报单关进度',
|
||||
description: '用户在分享挑战中通关后上报进度,仅首次通关(passed=true)有效',
|
||||
summary: '提交分享挑战结果',
|
||||
description:
|
||||
'客户端一次性提交分享挑战中每一关的耗时和答案,服务端校验后返回排名、答对题数、参与人数和完整关卡答案',
|
||||
})
|
||||
@ApiResponse({ status: 200, description: '成功' })
|
||||
@ApiResponse({ status: 404, description: '分享或关卡不存在' })
|
||||
async reportLevelProgress(
|
||||
async submitChallenge(
|
||||
@CurrentUser() user: JwtPayload,
|
||||
@Body() dto: ReportLevelProgressDto,
|
||||
): Promise<ApiResponseDto<ReportLevelProgressResponseDto>> {
|
||||
const data = await this.shareService.reportLevelProgress(user.sub, dto);
|
||||
@Param('code') code: string,
|
||||
@Body() dto: SubmitShareChallengeDto,
|
||||
): Promise<ApiResponseDto<SubmitShareChallengeResponseDto>> {
|
||||
const data = await this.shareService.submitChallenge(user.sub, code, dto);
|
||||
return ApiResponseDto.success(data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user