|
@@ -13,6 +13,25 @@ class CommentService extends CrudService {
|
|
|
this.model = this.ctx.model.Comment;
|
|
|
}
|
|
|
|
|
|
+ async query({ skip, limit, ...info }) {
|
|
|
+ const total = await (await this.model.find(info)).length;
|
|
|
+ const comments = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
|
|
|
+ for (const comment of comments) {
|
|
|
+ const url = "http://127.0.0.1:9999/api/auth/user/" + comment.uid;
|
|
|
+ const user = await this.ctx.curl(url, {
|
|
|
+ method: 'get',
|
|
|
+ headers: {
|
|
|
+ 'content-type': 'application/json',
|
|
|
+ },
|
|
|
+ dataType: 'json',
|
|
|
+ });
|
|
|
+ if (user.data.errcode === 0) {
|
|
|
+ comment.uname = user.data.data.name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return { data: comments, total };
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
module.exports = CommentService;
|