lrf402788946 4 gadi atpakaļ
vecāks
revīzija
fe3caa4987
1 mainītis faili ar 8 papildinājumiem un 1 dzēšanām
  1. 8 1
      app/service/users/product.js

+ 8 - 1
app/service/users/product.js

@@ -1,6 +1,6 @@
 'use strict';
 'use strict';
 const { CrudService } = require('naf-framework-mongoose/lib/service');
 const { CrudService } = require('naf-framework-mongoose/lib/service');
-
+const { ObjectId } = require('mongoose').Types;
 // 产品
 // 产品
 class ProductService extends CrudService {
 class ProductService extends CrudService {
   constructor(ctx) {
   constructor(ctx) {
@@ -60,6 +60,13 @@ class ProductService extends CrudService {
     const patent = await this.getSample('patent');
     const patent = await this.getSample('patent');
     // 专家:expert:limit=>8
     // 专家:expert:limit=>8
     const expert = await this.getSample('expert', 8);
     const expert = await this.getSample('expert', 8);
+    // 专家需要姓名
+    const ids = expert.map(i => i.user_id);
+    const personal = await this.personal.find({ _id: ids }, 'name');
+    for (const exp of expert) {
+      const r = await personal.find(f => ObjectId(f._id).equals(exp.user_id));
+      if (r) exp.name = r.name;
+    }
     // 路演:roadShow:limit=>5
     // 路演:roadShow:limit=>5
     const roadShow = await this.getSample('roadShow', 5);
     const roadShow = await this.getSample('roadShow', 5);
     return { require, achieve, serve, patent, expert, roadShow };
     return { require, achieve, serve, patent, expert, roadShow };