|
@@ -4,9 +4,15 @@ import com.keao.edu.auth.api.entity.SysUser;
|
|
|
import com.keao.edu.common.dal.BaseDAO;
|
|
|
import com.keao.edu.common.exception.BizException;
|
|
|
import com.keao.edu.common.service.impl.BaseServiceImpl;
|
|
|
+import com.keao.edu.im.api.client.ImFeignService;
|
|
|
+import com.keao.edu.im.api.entity.ImResult;
|
|
|
+import com.keao.edu.im.api.entity.ImUserModel;
|
|
|
import com.keao.edu.user.dao.StudentDao;
|
|
|
import com.keao.edu.user.dao.SysUserDao;
|
|
|
-import com.keao.edu.user.entity.Student;
|
|
|
+import com.keao.edu.user.api.entity.Student;
|
|
|
+import com.keao.edu.user.entity.Organization;
|
|
|
+import com.keao.edu.user.enums.YesOrNoEnum;
|
|
|
+import com.keao.edu.user.service.OrganizationService;
|
|
|
import com.keao.edu.user.service.StudentService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -24,6 +30,10 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
private StudentDao studentDao;
|
|
|
@Autowired
|
|
|
private SysUserDao sysUserDao;
|
|
|
+ @Autowired
|
|
|
+ private OrganizationService organizationService;
|
|
|
+ @Autowired
|
|
|
+ private ImFeignService imFeignService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, Student> getDAO() {
|
|
@@ -37,19 +47,30 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
if (sysUser == null || StringUtils.isEmpty(sysUser.getPhone())) {
|
|
|
throw new BizException("参数校验失败");
|
|
|
}
|
|
|
- SysUser sysUser1 = sysUserDao.queryByPhone(sysUser.getPhone());
|
|
|
- if (sysUser1 != null) {
|
|
|
- if (sysUser1.getUserType().contains("STUDENT")) {
|
|
|
- throw new BizException("手机号已被占用");
|
|
|
- } else {
|
|
|
- sysUser.setId(sysUser1.getId());
|
|
|
- sysUser.setUserType(sysUser1.getUserType() + ",STUDENT");
|
|
|
+ SysUser user = sysUserDao.queryByPhone(sysUser.getPhone());
|
|
|
+ if (user != null && user.getId() != null) {
|
|
|
+ Student stu = studentDao.get(user.getId());
|
|
|
+ if(stu == null){
|
|
|
+ student.setUserId(user.getId());
|
|
|
+ student.setTenantId(user.getTenantId());
|
|
|
+ studentDao.insert(student);
|
|
|
+ sysUser.setId(user.getId());
|
|
|
+ sysUser.setUserType(user.getUserType() + ",STUDENT");
|
|
|
sysUserDao.update(sysUser);
|
|
|
return;
|
|
|
+ }else{
|
|
|
+ throw new BizException("用户已存在");
|
|
|
}
|
|
|
}
|
|
|
+ Organization organization = organizationService.get(student.getOrganId());
|
|
|
+ student.setTenantId(organization.getTenantId());
|
|
|
+ sysUser.setTenantId(organization.getTenantId());
|
|
|
sysUser.setUserType("STUDENT");
|
|
|
sysUserDao.insert(sysUser);
|
|
|
+ ImResult imResult = imFeignService.register(new ImUserModel(sysUser.getId().toString(), sysUser.getRealName(),null));
|
|
|
+ sysUser.setImToken(imResult.getToken());
|
|
|
+ sysUserDao.update(sysUser);
|
|
|
+ student.setUserId(sysUser.getId());
|
|
|
studentDao.insert(student);
|
|
|
}
|
|
|
|