On this page
视频评论列表
控制器:app/controller/video.js
js
// 评论列表
async comment() {
const { app, ctx } = this;
ctx.validate({
id: {
type: "int",
required: true,
desc: "视频ID"
},
});
let { id } = ctx.params;
let rows = await app.model.Comment.findAll({
where: {
video_id: id,
reply_id: 0
},
include: [{
model: app.model.User,
as: "reply_user",
attributes: ['id', 'username', 'nickname', 'avatar'],
}, {
model: app.model.User,
as: "send_user",
attributes: ['id', 'username', 'nickname', 'avatar']
}, {
model: app.model.Comment,
include: [{
model: app.model.User,
as: "reply_user",
attributes: ['id', 'username', 'nickname', 'avatar'],
}, {
model: app.model.User,
as: "send_user",
attributes: ['id', 'username', 'nickname', 'avatar']
}]
}],
});
return ctx.apiSuccess(rows);
}
路由:app/router.js
js
// 视频评论列表
router.get("/video_comment/:id", controller.video.comment);