import { Controller, Get, Query, Param } from '@nestjs/common'; @Controller('goods') export class GoodsController { constructor() { console.log('goods controller') } // 示例1:基本查询参数 @Get('hello') getHello(@Query('name') name?: string) { return { message: 'Hello World!', name: name || 'Guest' }; } // 示例2:路径参数 @Get('detail/:id') getDetail(@Param('id') id: string) { return { id: id, detail: `Detail for product ${id}` }; } // 示例3:多个查询参数 @Get('search') searchProducts( @Query('keyword') keyword: string, @Query('page') page: number = 1, @Query('limit') limit: number = 10 ) { return { keyword, page, limit, results: [] }; } }