import { Controller, Get, Post, Body, Param, Query, UseGuards } from '@nestjs/common'; import { ApiTags, ApiBearerAuth } from '@nestjs/swagger'; import { AuthGuard } from '@nestjs/passport'; import { ToolsService } from './tools.service'; @ApiTags('AI工具') @Controller('tools') export class ToolsController { constructor(private toolsService: ToolsService) {} @Get() async findAll(@Query() query: { page?: number; pageSize?: number; categoryId?: number; isFeatured?: boolean; tag?: string }) { return this.toolsService.findAll(query); } @Get(':slug') async findBySlug(@Param('slug') slug: string) { return this.toolsService.findBySlug(slug); } @Post() @UseGuards(AuthGuard('jwt')) @ApiBearerAuth() async create(@Body() body: { name: string; slug: string; description?: string; url: string; icon?: string; affiliateLink?: string; categoryId?: number; tags?: string; metaTitle?: string; metaDesc?: string; content?: string }) { return this.toolsService.create(body); } }