|
@@ -76,6 +76,38 @@ class Achieve_applyService extends CrudService {
|
|
|
res.research.remove(research_id);
|
|
|
await res.save();
|
|
|
}
|
|
|
+
|
|
|
+ async menuRemind({ user_id }) {
|
|
|
+ let res = await this.model.aggregate([
|
|
|
+ { $match: { user_id: ObjectId(user_id) } },
|
|
|
+ { $group: {
|
|
|
+ _id: '$status',
|
|
|
+ count: { $sum: 1 },
|
|
|
+ } },
|
|
|
+ ]);
|
|
|
+ res = JSON.parse(JSON.stringify(res));
|
|
|
+ res = res.map(i => ({ status: i._id, count: 1 }));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const computed = list => {
|
|
|
+ return res.reduce((p, n) => {
|
|
|
+ let num = 0;
|
|
|
+ if (list.includes(n.status)) num = n.count;
|
|
|
+ return p + num;
|
|
|
+ }, 0);
|
|
|
+ };
|
|
|
+ const obj = {
|
|
|
+ cs: computed([ '0', '-1' ]),
|
|
|
+ pf: computed([ '1', '-2' ]),
|
|
|
+ hs: computed([ '3', '4' ]),
|
|
|
+ zs: computed([ '5', '6' ]),
|
|
|
+ };
|
|
|
+ return obj;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = Achieve_applyService;
|