|
@@ -2,11 +2,17 @@ package com.schoolinout.system.service.impl;
|
|
|
|
|
|
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;
|
|
|
import com.schoolinout.system.domain.dto.AddTeacherClassRelationDto;
|
|
|
+import com.schoolinout.system.domain.dto.BindClassTeacherMain;
|
|
|
import com.schoolinout.system.domain.dto.InsertTeacherClassRelationDto;
|
|
|
import com.schoolinout.system.domain.vo.TeacherClassInfoVo;
|
|
|
+import com.schoolinout.system.mapper.ClazzMapper;
|
|
|
import com.schoolinout.system.mapper.TeacherClassRelationMapper;
|
|
|
+import com.schoolinout.system.mapper.TeacherMapper;
|
|
|
import com.schoolinout.system.service.ITeacherClassRelationService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -25,6 +31,10 @@ import java.util.stream.Collectors;
|
|
|
public class TeacherClassRelationServiceImpl implements ITeacherClassRelationService {
|
|
|
@Autowired
|
|
|
private TeacherClassRelationMapper teacherClassRelationMapper;
|
|
|
+ @Autowired
|
|
|
+ private TeacherMapper teacherMapper;
|
|
|
+ @Autowired
|
|
|
+ private ClazzMapper clazzMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询老师-班级关系
|
|
@@ -111,4 +121,24 @@ public class TeacherClassRelationServiceImpl implements ITeacherClassRelationSer
|
|
|
public List<TeacherClassInfoVo> queryTeacherBindClassList(Long schoolId, Long teacherId) {
|
|
|
return teacherClassRelationMapper.selectTeacherClass(schoolId, teacherId, null);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String bindClassTeacherMain(BindClassTeacherMain form) {
|
|
|
+ // step1:检测该学校下面是否存在对应的班级和教师
|
|
|
+ Teacher teacher = teacherMapper.selectTeacherByIdAndSchoolId(form.getTeacherId(), form.getSchoolId());
|
|
|
+ if (teacher == null) {
|
|
|
+ throw new ServiceException("当前学校不存在该教师");
|
|
|
+ }
|
|
|
+ Clazz clazz = clazzMapper.selectClazzByIdAndSchoolId(form.getClassId(), form.getSchoolId());
|
|
|
+ if (clazz == null) {
|
|
|
+ throw new ServiceException("当前学校不存在该班级");
|
|
|
+ }
|
|
|
+ // step2:检测当前教师是否已经绑定了其他班的班主任
|
|
|
+ TeacherClassRelation relation = new TeacherClassRelation();
|
|
|
+ BeanUtils.copyBeanProp(relation, form);
|
|
|
+ TeacherClassRelation isTeacherMain = teacherClassRelationMapper.selectRelationTeacherMain(relation);
|
|
|
+
|
|
|
+ // step3:满足上面的条件则更新关系
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|