|
@@ -16,6 +16,7 @@ class CommentService extends CrudService {
|
|
async query({ skip, limit, ...info }) {
|
|
async query({ skip, limit, ...info }) {
|
|
const total = await (await this.model.find(info)).length;
|
|
const total = await (await this.model.find(info)).length;
|
|
const comments = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
|
|
const comments = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
|
|
|
|
+ const newdatas = [];
|
|
for (const comment of comments) {
|
|
for (const comment of comments) {
|
|
const url = 'http://127.0.0.1:9999/api/auth/user/' + comment.uid;
|
|
const url = 'http://127.0.0.1:9999/api/auth/user/' + comment.uid;
|
|
const user = await this.ctx.curl(url, {
|
|
const user = await this.ctx.curl(url, {
|
|
@@ -25,11 +26,13 @@ class CommentService extends CrudService {
|
|
},
|
|
},
|
|
dataType: 'json',
|
|
dataType: 'json',
|
|
});
|
|
});
|
|
|
|
+ const newdata = { ...JSON.parse(JSON.stringify(comment)) };
|
|
if (user.data.errcode === 0) {
|
|
if (user.data.errcode === 0) {
|
|
- comment.uname = user.data.data.name;
|
|
|
|
|
|
+ newdata.uname = user.data.data.name;
|
|
}
|
|
}
|
|
|
|
+ newdatas.push(newdata);
|
|
}
|
|
}
|
|
- return { data: comments, total };
|
|
|
|
|
|
+ return { data: newdatas, total };
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|