2022-07-01 20:53:38 +00:00
|
|
|
import { Controller } from '@nestjs/common';
|
|
|
|
import { MessagePattern, Payload } from '@nestjs/microservices';
|
|
|
|
import { PostCommentsService } from './post-comments.service';
|
2022-07-01 22:27:19 +00:00
|
|
|
import { Comment, CommentDocument } from '../schemas/post-comment.schema';
|
|
|
|
|
2022-07-01 20:53:38 +00:00
|
|
|
@Controller()
|
|
|
|
export class PostCommentsController {
|
|
|
|
constructor(private readonly postCommentsService: PostCommentsService) {}
|
|
|
|
|
2022-07-01 22:27:19 +00:00
|
|
|
@MessagePattern({ cmd: 'createComment' })
|
|
|
|
create(@Payload() comment: CommentDocument) {
|
|
|
|
return this.postCommentsService.create(comment);
|
2022-07-01 20:53:38 +00:00
|
|
|
}
|
|
|
|
|
2022-07-01 22:27:19 +00:00
|
|
|
@MessagePattern({ cmd: 'findAllComments' })
|
2022-07-01 20:53:38 +00:00
|
|
|
findAll() {
|
|
|
|
return this.postCommentsService.findAll();
|
|
|
|
}
|
|
|
|
|
2022-07-25 04:38:48 +00:00
|
|
|
@MessagePattern({ cmd: 'findOneComment' })
|
2022-07-01 22:27:19 +00:00
|
|
|
findOne(@Payload() id: string) {
|
|
|
|
let _id = id['id'];
|
|
|
|
return this.postCommentsService.findOne(_id);
|
2022-07-01 20:53:38 +00:00
|
|
|
}
|
|
|
|
|
2022-07-01 22:27:19 +00:00
|
|
|
@MessagePattern({ cmd: 'updateComment' })
|
|
|
|
update(@Payload() comment: CommentDocument) {
|
|
|
|
return this.postCommentsService.update(comment.id, comment);
|
2022-07-01 20:53:38 +00:00
|
|
|
}
|
|
|
|
|
2022-07-01 22:27:19 +00:00
|
|
|
@MessagePattern({ cmd: 'removeComment' })
|
|
|
|
remove(@Payload() id: string) {
|
|
|
|
let _id = id['id'];
|
|
|
|
return this.postCommentsService.remove(_id);
|
2022-07-01 20:53:38 +00:00
|
|
|
}
|
|
|
|
}
|