|
@@ -16,6 +16,8 @@ class ClassService extends CrudService {
|
|
|
this.umodel = this.ctx.model.User;
|
|
|
this.tmodel = this.ctx.model.Trainplan;
|
|
|
this.gmodel = this.ctx.model.Group;
|
|
|
+ this.heamodel = this.ctx.model.Headteacher;
|
|
|
+ this.teamodel = this.ctx.model.Teacher;
|
|
|
}
|
|
|
|
|
|
async divide(data) {
|
|
@@ -172,6 +174,43 @@ class ClassService extends CrudService {
|
|
|
await this.model.findByIdAndUpdate(_data.id, _data);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async classinfo({ id: classid }) {
|
|
|
+ const _classes = await this.model.findById(classid);
|
|
|
+ // 班级信息
|
|
|
+ const classes = _.cloneDeep(JSON.parse(JSON.stringify(_classes)));
|
|
|
+ // 学生信息
|
|
|
+ const students = await this.stumodel.find({ classid });
|
|
|
+ if (students) {
|
|
|
+ classes.students = students;
|
|
|
+ }
|
|
|
+ // 班主任信息
|
|
|
+ if (classes.headteacherid) {
|
|
|
+ const headteacher = await this.heamodel.findById(classes.headteacherid);
|
|
|
+ classes.headteacher = headteacher;
|
|
|
+ }
|
|
|
+ // 礼仪课老师信息
|
|
|
+ if (classes.lyteacherid) {
|
|
|
+ let lyteacher = await this.heamodel.findById(classes.lyteacherid);
|
|
|
+ if (!lyteacher) {
|
|
|
+ lyteacher = await this.teamodel.findById(classes.lyteacherid);
|
|
|
+ }
|
|
|
+ classes.lyteacher = lyteacher;
|
|
|
+ }
|
|
|
+ // 教课老师信息
|
|
|
+ const teachers = [];
|
|
|
+ const lessones = await this.lessmodel.findOne({ classid });
|
|
|
+ if (lessones) {
|
|
|
+ for (const lesson of lessones.lessons) {
|
|
|
+ if (lesson.teaid) {
|
|
|
+ const teacher = await this.teamodel.findById(lesson.teaid);
|
|
|
+ teachers.push(teacher);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ classes.teachers = teachers;
|
|
|
+ return classes;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = ClassService;
|