| 1 | const service = require('../service/comment.service.js'); |
| 2 | |
| 3 | class CommentController { |
| 4 | async create(ctx, next) { |
| 5 | const { momentId, content } = ctx.request.body; |
| 6 | const { id } = ctx.user; |
| 7 | const result = await service.create(momentId, content, id); |
| 8 | ctx.body = result; |
| 9 | } |
| 10 | |
| 11 | async reply(ctx, next) { |
| 12 | const { momentId, content } = ctx.request.body; |
| 13 | const { commentId } = ctx.params; |
| 14 | const { id } = ctx.user; |
| 15 | const result = await service.reply(momentId, content, id, commentId); |
| 16 | ctx.body = result; |
| 17 | } |
| 18 | |
| 19 | async update(ctx, next) { |
| 20 | const { commentId } = ctx.params; |
| 21 | const { content } = ctx.request.body; |
| 22 | const result = await service.update(commentId, content); |
| 23 | ctx.body = result; |
| 24 | } |
| 25 | |
| 26 | async remove(ctx, next) { |
| 27 | const { commentId } = ctx.params; |
| 28 | const result = await service.remove(commentId); |
| 29 | ctx.body = result; |
| 30 | } |
| 31 | |
| 32 | async list(ctx, next) { |
| 33 | const { momentId } = ctx.query; |
| 34 | const result = await service.getCommentsByMomentId(momentId); |
| 35 | ctx.body = result; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | module.exports = new CommentController(); |
nothing calls this directly
no outgoing calls
no test coverage detected