|
@@ -1,8 +1,8 @@
|
|
|
package com.schoolinout.system.service.impl;
|
|
|
|
|
|
+import com.schoolinout.common.constant.DictConstants;
|
|
|
import com.schoolinout.common.exception.ServiceException;
|
|
|
import com.schoolinout.common.utils.DateUtils;
|
|
|
-import com.schoolinout.common.utils.bean.BeanUtils;
|
|
|
import com.schoolinout.system.domain.Clazz;
|
|
|
import com.schoolinout.system.domain.Teacher;
|
|
|
import com.schoolinout.system.domain.TeacherClassRelation;
|
|
@@ -133,12 +133,28 @@ public class TeacherClassRelationServiceImpl implements ITeacherClassRelationSer
|
|
|
if (clazz == null) {
|
|
|
throw new ServiceException("当前学校不存在该班级");
|
|
|
}
|
|
|
- // step2:检测当前教师是否已经绑定了其他班的班主任
|
|
|
- TeacherClassRelation relation = new TeacherClassRelation();
|
|
|
- BeanUtils.copyBeanProp(relation, form);
|
|
|
- TeacherClassRelation isTeacherMain = teacherClassRelationMapper.selectRelationTeacherMain(relation);
|
|
|
|
|
|
- // step3:满足上面的条件则更新关系
|
|
|
- return null;
|
|
|
+ // step2:判断是否是要绑定
|
|
|
+ String teacherMain = form.getTeacherMain();
|
|
|
+ String ans = "";
|
|
|
+ if (DictConstants.SYS_DICT_YES.equals(teacherMain)) {
|
|
|
+ // step3:校验当前要绑定的教师是否已经绑定了其他班级的班主任
|
|
|
+ TeacherClassRelation teacherMainRelation = teacherMapper.selectTeacherMain(form.getSchoolId(), form.getTeacherId(), null);
|
|
|
+ if (teacherMainRelation != null) {
|
|
|
+ throw new ServiceException("当前教师已经绑定有其他班的班主任,无法再次绑定");
|
|
|
+ }
|
|
|
+ // step3:解绑和更新绑定的操作
|
|
|
+ // 解绑
|
|
|
+ teacherClassRelationMapper.updateTeacherMainBindRelation(form.getSchoolId(), form.getClassId(), null, form.getTeacherMain(), DictConstants.SYS_DICT_NO);
|
|
|
+ // 更新绑定
|
|
|
+ teacherClassRelationMapper.updateTeacherMainBindRelation(form.getSchoolId(), form.getClassId(), form.getTeacherId(), null, DictConstants.SYS_DICT_YES);
|
|
|
+ ans = "绑定成功!";
|
|
|
+ } else if (DictConstants.SYS_DICT_NO.equals(teacherMain)) { // step3:解绑操作
|
|
|
+ // 解绑
|
|
|
+ teacherClassRelationMapper.updateTeacherMainBindRelation(form.getSchoolId(), form.getClassId(), form.getTeacherId(), null, DictConstants.SYS_DICT_NO);
|
|
|
+ ans = "解绑成功";
|
|
|
+ }
|
|
|
+
|
|
|
+ return ans;
|
|
|
}
|
|
|
}
|