25 lines
825 B
TypeScript
25 lines
825 B
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Query } from '@nestjs/common';
|
|
import { CommentService, type CommentEntityType } from './comment.service';
|
|
import { CreateCommentDto } from './dto/create-comment.dto';
|
|
import { DeleteCommentDto } from './dto/delete-comment.dto';
|
|
|
|
@Controller('comments')
|
|
export class CommentController {
|
|
constructor(private readonly commentService: CommentService) {}
|
|
|
|
@Get()
|
|
list(@Query('entityType') entityType: CommentEntityType, @Query('entityId') entityId: string) {
|
|
return this.commentService.list(entityType, entityId);
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() dto: CreateCommentDto) {
|
|
return this.commentService.create(dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@Param('id') id: string, @Body() dto: DeleteCommentDto) {
|
|
return this.commentService.remove(id, dto.actorId);
|
|
}
|
|
}
|