|
@@ -6,6 +6,8 @@ class ProductService extends CrudService {
|
|
|
constructor(ctx) {
|
|
|
super(ctx, 'product');
|
|
|
this.model = this.ctx.model.Product;
|
|
|
+ this.patent = this.ctx.model.Patent;
|
|
|
+ this.roadShow = this.ctx.model.RoadShow;
|
|
|
this.personal = this.ctx.model.Personal;
|
|
|
this.expert = this.ctx.model.Expert;
|
|
|
this.organization = this.ctx.model.Organization;
|
|
@@ -45,6 +47,31 @@ class ProductService extends CrudService {
|
|
|
}
|
|
|
return { data: res, total };
|
|
|
}
|
|
|
+
|
|
|
+ async indexQuery() {
|
|
|
+ // product,limit=>6;status=>2;type=>0/1/2
|
|
|
+ // 科技需求
|
|
|
+ const require = await this.getSample('model', 6, { type: '0', status: '2' });
|
|
|
+ // 技术成果
|
|
|
+ const achieve = await this.getSample('model', 6, { type: '1', status: '2' });
|
|
|
+ // 商务服务
|
|
|
+ const serve = await this.getSample('model', 6, { type: '2', status: '2' });
|
|
|
+ // 专利:patent limit=>6
|
|
|
+ const patent = await this.getSample('patent');
|
|
|
+ // 专家:expert:limit=>8
|
|
|
+ const expert = await this.getSample('expert', 8);
|
|
|
+ // 路演:roadShow:limit=>5
|
|
|
+ const roadShow = await this.getSample('roadShow', 5);
|
|
|
+ return { require, achieve, serve, patent, expert, roadShow };
|
|
|
+ }
|
|
|
+
|
|
|
+ async getSample(model, limit = 6, match = {}) {
|
|
|
+ const res = await this[model].aggregate([
|
|
|
+ { $match: match },
|
|
|
+ { $sample: { size: parseInt(limit) } },
|
|
|
+ ]);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = ProductService;
|