35 lines
949 B
TypeScript
35 lines
949 B
TypeScript
import { Controller, Get, Post, Put, Delete, Body, Param, Query } from '@nestjs/common';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import { ContentsService } from './contents.service';
|
|
|
|
@ApiTags('内容')
|
|
@Controller('contents')
|
|
export class ContentsController {
|
|
constructor(private contentsService: ContentsService) {}
|
|
|
|
@Get()
|
|
async findAll(@Query() query: { page?: number; pageSize?: number; categoryId?: number; contentType?: string }) {
|
|
return this.contentsService.findAll(query);
|
|
}
|
|
|
|
@Get(':id')
|
|
async findById(@Param('id') id: string) {
|
|
return this.contentsService.findById(+id);
|
|
}
|
|
|
|
@Post()
|
|
async create(@Body() body: any) {
|
|
return this.contentsService.create(body);
|
|
}
|
|
|
|
@Put(':id')
|
|
async update(@Param('id') id: string, @Body() body: any) {
|
|
return this.contentsService.update(+id, body);
|
|
}
|
|
|
|
@Delete(':id')
|
|
async remove(@Param('id') id: string) {
|
|
return this.contentsService.remove(+id);
|
|
}
|
|
}
|