|
@@ -336,22 +336,34 @@ class TrainplanService extends CrudService {
|
|
|
return respath;
|
|
|
}
|
|
|
|
|
|
- async updateclass({ trainplanid, classid, rightHeader }) {
|
|
|
- assert(trainplanid && classid && rightHeader, '缺少参数项');
|
|
|
+ async updateclass({ trainplanid, termid, batchid, classid, rightHeader }) {
|
|
|
+ assert(trainplanid && termid && batchid && classid && rightHeader, '缺少参数项');
|
|
|
// 根据全年计划表id查出对应的全年计划详细信息
|
|
|
const trainplan = await this.model.findById(trainplanid);
|
|
|
if (!trainplan) {
|
|
|
throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '全年计划信息不存在');
|
|
|
}
|
|
|
- for (const term of trainplan.termnum) {
|
|
|
- for (const batch of term.batchnum) {
|
|
|
- const class_ = await batch.class.id(classid);
|
|
|
- if (class_) {
|
|
|
- class_.headteacherid = rightHeader;
|
|
|
- }
|
|
|
+ const term = trainplan.termnum.id(termid);
|
|
|
+ if (!term) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '期信息不存在');
|
|
|
+ }
|
|
|
+ const batch = term.batchnum.id(batchid);
|
|
|
+ if (!batch) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '批次信息不存在');
|
|
|
+ }
|
|
|
+ const class_ = await batch.class.id(classid);
|
|
|
+ if (class_) {
|
|
|
+ class_.headteacherid = rightHeader;
|
|
|
+ }
|
|
|
+ const res = await trainplan.save();
|
|
|
+ if (res) {
|
|
|
+ const cla_ = await this.clamodel.findOne({ termid, batchid, name: class_.name });
|
|
|
+ if (cla_) {
|
|
|
+ cla_.headteacherid = rightHeader;
|
|
|
+ await cla_.save();
|
|
|
}
|
|
|
}
|
|
|
- return await trainplan.save();
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
async updatereteacher({ trainplanid, termid, reteacher }) {
|