|
@@ -21,10 +21,15 @@ class StudentService extends CrudService {
|
|
|
// 查询
|
|
|
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 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 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);
|
|
@@ -48,8 +53,14 @@ class StudentService extends CrudService {
|
|
|
|
|
|
// 查询
|
|
|
async seek({ termid, skip, limit }) {
|
|
|
- const total = await this.model.count({ termid, $or: [{ classid: null }, { classid: '' }] });
|
|
|
- const data = await this.model.find({ termid, $or: [{ classid: null }, { classid: '' }] }).skip(Number(skip)).limit(Number(limit));
|
|
|
+ const total = await this.model.count({
|
|
|
+ termid,
|
|
|
+ $or: [{ classid: null }, { classid: '' }],
|
|
|
+ });
|
|
|
+ const data = await this.model
|
|
|
+ .find({ termid, $or: [{ classid: null }, { classid: '' }] })
|
|
|
+ .skip(Number(skip))
|
|
|
+ .limit(Number(limit));
|
|
|
const result = { total, data };
|
|
|
return result;
|
|
|
}
|
|
@@ -114,7 +125,14 @@ class StudentService extends CrudService {
|
|
|
const detail = '你已被班主任设置为' + job + ',请及时登录查看';
|
|
|
const remark = '感谢您的使用';
|
|
|
if (openid) {
|
|
|
- this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
|
|
|
+ this.ctx.service.weixin.sendTemplateMsg(
|
|
|
+ this.ctx.app.config.REVIEW_TEMPLATE_ID,
|
|
|
+ openid,
|
|
|
+ '您有一个新的通知',
|
|
|
+ detail,
|
|
|
+ date,
|
|
|
+ remark
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
return await student.save();
|
|
@@ -135,12 +153,17 @@ class StudentService extends CrudService {
|
|
|
async findscore({ skip, limit, ...info }) {
|
|
|
const { classid } = info;
|
|
|
const total = await this.model.count(info);
|
|
|
- const students = await this.model.find(info).skip(Number(skip)).limit(Number(limit));
|
|
|
+ const students = await this.model
|
|
|
+ .find(info)
|
|
|
+ .skip(Number(skip))
|
|
|
+ .limit(Number(limit));
|
|
|
const data = [];
|
|
|
const groups = await this.gmodel.find({ classid });
|
|
|
for (const student of students) {
|
|
|
const _student = JSON.parse(JSON.stringify(student));
|
|
|
- const group = groups.find(item => item.students.find(stuinfo => stuinfo.stuid === _student.id));
|
|
|
+ const group = groups.find(item =>
|
|
|
+ item.students.find(stuinfo => stuinfo.stuid === _student.id)
|
|
|
+ );
|
|
|
console.log(group);
|
|
|
if (group) {
|
|
|
_student.groupscore = group.score;
|
|
@@ -152,6 +175,15 @@ class StudentService extends CrudService {
|
|
|
|
|
|
return { total, data };
|
|
|
}
|
|
|
+
|
|
|
+ async findbystuids({ data }) {
|
|
|
+ const res = [];
|
|
|
+ for (const stuid of data) {
|
|
|
+ const stu = await this.model.findById(stuid);
|
|
|
+ if (stu)res.push(stu);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = StudentService;
|