|
@@ -13,6 +13,24 @@ class NewsService extends CrudService {
|
|
this.model = this.ctx.model.News;
|
|
this.model = this.ctx.model.News;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async fetch({ id }) {
|
|
|
|
+ const news = await this.model.findById(id);
|
|
|
|
+ if (news) {
|
|
|
|
+ const url = 'http://127.0.0.1:9999/api/auth/user/' + news.uid;
|
|
|
|
+ const user = await this.ctx.curl(url, {
|
|
|
|
+ method: 'get',
|
|
|
|
+ headers: {
|
|
|
|
+ 'content-type': 'application/json',
|
|
|
|
+ },
|
|
|
|
+ dataType: 'json',
|
|
|
|
+ });
|
|
|
|
+ if (user.data.data.name) {
|
|
|
|
+ news.uname = user.data.data.name;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return news;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
module.exports = NewsService;
|
|
module.exports = NewsService;
|