|
@@ -12,6 +12,29 @@ class StudentService extends CrudService {
|
|
|
super(ctx, 'student');
|
|
|
this.model = this.ctx.model.Student;
|
|
|
this.umodel = this.ctx.model.User;
|
|
|
+ this.tmodel = this.ctx.model.Trainplan;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询
|
|
|
+ async query({ skip, limit, ...info }) {
|
|
|
+ const total = await this.model.count(info);
|
|
|
+ const res = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
|
|
|
+ const data = [];
|
|
|
+ for (const elm of res) {
|
|
|
+ const plan = await this.tmodel.findOne({ 'termnum._id': ObjectId(elm.termid) });
|
|
|
+ const newdata = { ...JSON.parse(JSON.stringify(elm)) };
|
|
|
+ if (plan) {
|
|
|
+ const term = await plan.termnum.id(elm.termid);
|
|
|
+ newdata.termname = term.term;
|
|
|
+ if (elm.batchid) {
|
|
|
+ const _batch = await term.batchnum.id(elm.batchid);
|
|
|
+ newdata.batchname = _batch.batch;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.push(newdata);
|
|
|
+ }
|
|
|
+ const result = { total, data };
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
// 查询
|