|
@@ -254,29 +254,16 @@ class LessonService extends CrudService {
|
|
|
}
|
|
|
|
|
|
// 根据计划id、教师id查询所有班级信息
|
|
|
- async teaclass({ planid, teaid }) {
|
|
|
+ async teaclass({ termid, teaid }) {
|
|
|
+ console.log(termid, teaid);
|
|
|
// 取得传入的计划id与教师id
|
|
|
// 根据计划id取得所有期
|
|
|
- const plan = await this.tmodel.findById(planid);
|
|
|
- if (!plan) {
|
|
|
- throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '全年计划信息不存在');
|
|
|
- }
|
|
|
- const terms = await plan.termnum;
|
|
|
- // 循环取得所有期信息
|
|
|
- const data = [];
|
|
|
- for (const term of terms) {
|
|
|
- // 根据期id与教师id查出课程班级信息
|
|
|
- const lessons = await this.model.find({
|
|
|
- termid: term.id,
|
|
|
- 'lessons.teaid': teaid,
|
|
|
- });
|
|
|
- for (const elm of lessons) {
|
|
|
- if (elm.classid) {
|
|
|
- const cla = await this.ctx.service.class.fetch({ id: elm.classid });
|
|
|
- data.push(cla);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ const lessons = await this.model.find({
|
|
|
+ termid,
|
|
|
+ 'lessons.teaid': teaid,
|
|
|
+ });
|
|
|
+ const classids = lessons.map(i => ObjectId(i.classid));
|
|
|
+ const data = await this.ctx.model.Class.find({ _id: { $in: classids } });
|
|
|
return data;
|
|
|
}
|
|
|
|