All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 1m0s
- AI: 新三层架构 Provider→Gateway→Workflow(15文件,DeepSeek+MiniMax) - Auth: 全局JwtAuthGuard + @Public()装饰器白名单路由 - DB: 12个Repository从Map/Array迁到Prisma - Schema: 新增AiUsageLog、WaitlistEntry模型 - API: /api-docs-json加Basic Auth保护 - 清理: 删除infrastructure/ai、docs/旧文档 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
|
|
import { Controller, Post, Body, HttpCode, HttpStatus, Req } from '@nestjs/common';
|
|
import { AuthService } from './auth.service';
|
|
import { AppleLoginDto, DevLoginDto, RefreshDto } from './dto';
|
|
import { Public } from '../../common/decorators/public.decorator';
|
|
import type { Request } from 'express';
|
|
|
|
@ApiTags('auth')
|
|
@Controller('auth')
|
|
export class AuthController {
|
|
constructor(private readonly authService: AuthService) {}
|
|
|
|
@Public()
|
|
@Post('dev-login')
|
|
@HttpCode(HttpStatus.OK)
|
|
@ApiOperation({ summary: '开发登录(仅非生产环境)' })
|
|
@ApiResponse({ status: 200, description: '登录成功' })
|
|
@ApiResponse({ status: 403, description: '生产环境禁用' })
|
|
async devLogin(@Body() dto: DevLoginDto) {
|
|
return this.authService.devLogin(dto);
|
|
}
|
|
|
|
@Public()
|
|
@Post('apple')
|
|
@HttpCode(HttpStatus.OK)
|
|
@ApiOperation({ summary: 'Apple 登录' })
|
|
@ApiResponse({ status: 200, description: '登录成功' })
|
|
@ApiResponse({ status: 401, description: '身份验证失败' })
|
|
async appleLogin(@Body() dto: AppleLoginDto) {
|
|
return this.authService.appleLogin(dto);
|
|
}
|
|
|
|
@Public()
|
|
@Post('refresh')
|
|
@HttpCode(HttpStatus.OK)
|
|
@ApiOperation({ summary: '刷新令牌' })
|
|
@ApiResponse({ status: 200, description: '刷新成功' })
|
|
@ApiResponse({ status: 401, description: '刷新令牌无效' })
|
|
async refresh(@Body() dto: RefreshDto) {
|
|
return this.authService.refresh(dto.refreshToken);
|
|
}
|
|
|
|
@Post('logout')
|
|
@HttpCode(HttpStatus.OK)
|
|
@ApiOperation({ summary: '退出登录' })
|
|
@ApiResponse({ status: 200, description: '退出成功' })
|
|
@ApiResponse({ status: 401, description: '未登录' })
|
|
async logout(@Req() req: Request, @Body() dto: RefreshDto) {
|
|
const user = (req as any).user;
|
|
await this.authService.logout(user.id, dto.refreshToken);
|
|
return { success: true, message: '已退出登录' };
|
|
}
|
|
}
|