- 迁移25个模块,包含95个控制器和160个服务 - 新增验证码管理、登录配置、云编译等模块 - 完善认证授权、会员管理、支付系统等核心功能 - 实现完整的队列系统、配置管理、监控体系 - 确保100%功能对齐和命名一致性 - 支持生产环境部署
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Body,
|
|
Query,
|
|
UseGuards,
|
|
Req,
|
|
} from '@nestjs/common';
|
|
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
|
|
import type { Request } from 'express';
|
|
import { JwtAuthGuard } from '../../../auth/guards/JwtAuthGuard';
|
|
import { ApiConfigService } from '../../services/api/ApiConfigService';
|
|
|
|
interface AuthenticatedRequest extends Request {
|
|
user?: {
|
|
uid: number;
|
|
username: string;
|
|
siteId: number;
|
|
userType: string;
|
|
};
|
|
}
|
|
|
|
@ApiTags('API配置')
|
|
@Controller('api/sys/config')
|
|
@UseGuards(JwtAuthGuard)
|
|
export class ApiConfigController {
|
|
constructor(private readonly apiConfigService: ApiConfigService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: '获取配置' })
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
async getConfig(@Query('key') key: string, @Req() req: AuthenticatedRequest) {
|
|
const siteId = req.user?.siteId || 0;
|
|
const result = await this.apiConfigService.getConfig(siteId, key);
|
|
return { code: 200, message: '获取成功', data: result };
|
|
}
|
|
|
|
@Post('batch')
|
|
@ApiOperation({ summary: '批量获取配置' })
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
async getConfigs(
|
|
@Body() body: { keys: string[] },
|
|
@Req() req: AuthenticatedRequest,
|
|
) {
|
|
const siteId = req.user?.siteId || 0;
|
|
const result = await this.apiConfigService.getConfigs(siteId, body.keys);
|
|
return { code: 200, message: '获取成功', data: result };
|
|
}
|
|
}
|