|
@@ -14,8 +14,10 @@ import com.keao.edu.user.dao.TeacherDao;
|
|
|
import com.keao.edu.user.entity.Teacher;
|
|
|
import com.keao.edu.user.enums.YesOrNoEnum;
|
|
|
import com.keao.edu.user.service.TeacherService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
@@ -27,8 +29,6 @@ public class TeacherServiceImpl extends BaseServiceImpl<Integer, Teacher> implem
|
|
|
@Autowired
|
|
|
private SysUserDao sysUserDao;
|
|
|
@Autowired
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
- @Autowired
|
|
|
private ImFeignService imFeignService;
|
|
|
|
|
|
@Override
|
|
@@ -37,9 +37,10 @@ public class TeacherServiceImpl extends BaseServiceImpl<Integer, Teacher> implem
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public int add(Teacher teacher) {
|
|
|
SysUser sysUser = teacher.getSysUser();
|
|
|
- SysUser user = sysUserFeignService.queryUserByMobile(sysUser.getPhone());
|
|
|
+ SysUser user = sysUserDao.queryByPhone(sysUser.getPhone());
|
|
|
Date date = new Date();
|
|
|
if(user != null && user.getId() != null){
|
|
|
if(user.getUserType().contains("TEACHER")){
|
|
@@ -72,4 +73,24 @@ public class TeacherServiceImpl extends BaseServiceImpl<Integer, Teacher> implem
|
|
|
}
|
|
|
return userId;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void updateTeacher(Teacher teacher) {
|
|
|
+ SysUser sysUser = teacher.getSysUser();
|
|
|
+ if(null == teacherDao.get(sysUser.getId())){
|
|
|
+ throw new BizException("教师信息不存在");
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(sysUser.getPhone())){
|
|
|
+ SysUser queryUserByMobile = sysUserDao.queryByPhone(sysUser.getPhone());
|
|
|
+ if(queryUserByMobile != null && !sysUser.getId().equals(queryUserByMobile.getId())){
|
|
|
+ throw new BizException("手机号已存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+ teacher.setUpdateTime(date);
|
|
|
+ teacherDao.update(teacher);
|
|
|
+ sysUserDao.update(sysUser);
|
|
|
+ imFeignService.update(new ImUserModel(sysUser.getId().toString(),sysUser.getRealName(),sysUser.getAvatar()));
|
|
|
+ }
|
|
|
}
|