32 lines
967 B
TypeScript
32 lines
967 B
TypeScript
|
|
import { Controller, Get, Query } from "@nestjs/common";
|
|||
|
|
import { ApiTags, ApiOperation, ApiResponse } from "@nestjs/swagger";
|
|||
|
|
|
|||
|
|
@ApiTags("验证码管理")
|
|||
|
|
@Controller("adminapi")
|
|||
|
|
export class CaptchaController {
|
|||
|
|
@Get("captcha/create")
|
|||
|
|
@ApiOperation({ summary: "生成验证码" })
|
|||
|
|
@ApiResponse({ status: 200, description: "生成成功" })
|
|||
|
|
async create() {
|
|||
|
|
return {
|
|||
|
|
code: 0,
|
|||
|
|
data: {
|
|||
|
|
captcha_id: "mock-captcha-" + Date.now(),
|
|||
|
|
captcha_image: "data:image/png;base64,mock-base64-image"
|
|||
|
|
},
|
|||
|
|
message: "success"
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@Get("captcha/check")
|
|||
|
|
@ApiOperation({ summary: "校验验证码" })
|
|||
|
|
@ApiResponse({ status: 200, description: "校验成功" })
|
|||
|
|
async check(@Query("captcha_id") captchaId: string, @Query("captcha_code") captchaCode: string) {
|
|||
|
|
console.log("校验验证码:", { captchaId, captchaCode });
|
|||
|
|
return {
|
|||
|
|
code: 0,
|
|||
|
|
data: { is_valid: true },
|
|||
|
|
message: "success"
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
}
|