|
@@ -173,9 +173,10 @@ class ClassService extends CrudService {
|
|
|
let termid = '';
|
|
|
let batchid = '';
|
|
|
let classname = '';
|
|
|
+ let class_ = {};
|
|
|
for (const term of trainplan.termnum) {
|
|
|
for (const batch of term.batchnum) {
|
|
|
- const class_ = await batch.class.id(id);
|
|
|
+ class_ = await batch.class.id(id);
|
|
|
if (class_) {
|
|
|
termid = term.id;
|
|
|
batchid = batch.id;
|
|
@@ -184,11 +185,27 @@ class ClassService extends CrudService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (!class_) {
|
|
|
+ throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '班级信息不存在');
|
|
|
+ }
|
|
|
let classid_ = '';
|
|
|
if (classname) {
|
|
|
const cla_ = await this.model.findOne({ termid, batchid, name: classname });
|
|
|
if (cla_) {
|
|
|
classid_ = cla_.id;
|
|
|
+ } else {
|
|
|
+ const newdata = {
|
|
|
+ name: class_.name,
|
|
|
+ number: class_.number,
|
|
|
+ batchid,
|
|
|
+ termid,
|
|
|
+ planid: trainplan.id,
|
|
|
+ type: class_.type,
|
|
|
+ };
|
|
|
+ const rescla = await this.model.create(newdata);
|
|
|
+ if (rescla) {
|
|
|
+ classid_ = rescla.id;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (classid_) {
|