38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
|
|
import { Controller, Get, Post, Body, Query, UseGuards } from '@nestjs/common';
|
||
|
|
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
|
||
|
|
import { JwtAuthGuard } from '../../guards/JwtAuthGuard';
|
||
|
|
import { RolesGuard } from '../../guards/RolesGuard';
|
||
|
|
import { Roles } from '../../decorators/RolesDecorator';
|
||
|
|
import { CaptchaService } from '../../services/admin/CaptchaService';
|
||
|
|
import { CaptchaCreateDto, CaptchaCheckDto, CaptchaVerificationDto } from '../../dto/admin/CaptchaDto';
|
||
|
|
|
||
|
|
@ApiTags('验证码管理')
|
||
|
|
@Controller('adminapi/auth/captcha')
|
||
|
|
export class CaptchaController {
|
||
|
|
constructor(private readonly captchaService: CaptchaService) {}
|
||
|
|
|
||
|
|
@Get('create')
|
||
|
|
@ApiOperation({ summary: '创建验证码' })
|
||
|
|
@ApiResponse({ status: 200, description: '创建成功' })
|
||
|
|
async create(@Query() query: CaptchaCreateDto) {
|
||
|
|
const data = await this.captchaService.create(query);
|
||
|
|
return { code: 200, message: '创建成功', data };
|
||
|
|
}
|
||
|
|
|
||
|
|
@Post('check')
|
||
|
|
@ApiOperation({ summary: '一次校验验证码' })
|
||
|
|
@ApiResponse({ status: 200, description: '校验成功' })
|
||
|
|
async check(@Body() body: CaptchaCheckDto) {
|
||
|
|
const data = await this.captchaService.check(body);
|
||
|
|
return { code: 200, message: '校验成功', data };
|
||
|
|
}
|
||
|
|
|
||
|
|
@Post('verification')
|
||
|
|
@ApiOperation({ summary: '二次校验验证码' })
|
||
|
|
@ApiResponse({ status: 200, description: '校验成功' })
|
||
|
|
async verification(@Body() body: CaptchaVerificationDto) {
|
||
|
|
const data = await this.captchaService.verification(body);
|
||
|
|
return { code: 200, message: '校验成功', data };
|
||
|
|
}
|
||
|
|
}
|