|
@@ -135,6 +135,45 @@ class LessonService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 根据计划id、教师id查询所有班级信息
|
|
|
+ async classbyteaid({ planid, 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 });
|
|
|
+ const batchs = await term.batchnum;
|
|
|
+ for (const elm of lessons) {
|
|
|
+ const newdata = {};
|
|
|
+ const batch = await batchs.id(elm.batchid);
|
|
|
+ newdata.planid = planid;
|
|
|
+ newdata.title = plan.title;
|
|
|
+ newdata.termid = elm.termid;
|
|
|
+ newdata.term = term.term;
|
|
|
+ newdata.batchid = elm.batchid;
|
|
|
+ newdata.batch = batch.batch;
|
|
|
+ newdata.classid = elm.classid;
|
|
|
+ if (elm.classid) {
|
|
|
+ const cla = await this.clamodel.findById(elm.classid);
|
|
|
+ if (cla) {
|
|
|
+ newdata.classname = cla.name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const _lessons = elm.lessons.filter(item => item.teaid === teaid);
|
|
|
+ newdata.lessons = _lessons;
|
|
|
+ data.push(newdata);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
module.exports = LessonService;
|