|
@@ -9,10 +9,6 @@ import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
|
|
|
-import cn.com.qmth.examcloud.service.core.entity.*;
|
|
|
-import cn.com.qmth.examcloud.service.core.repo.*;
|
|
|
-import org.apache.commons.lang.ArrayUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Example;
|
|
@@ -26,10 +22,17 @@ import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
|
|
|
import cn.com.qmth.examcloud.common.uac.enums.RoleMeta;
|
|
|
import cn.com.qmth.examcloud.common.util.RedisUtil;
|
|
|
import cn.com.qmth.examcloud.service.core.dto.UserInfo;
|
|
|
+import cn.com.qmth.examcloud.service.core.entity.Org;
|
|
|
+import cn.com.qmth.examcloud.service.core.entity.Student;
|
|
|
+import cn.com.qmth.examcloud.service.core.entity.User;
|
|
|
+import cn.com.qmth.examcloud.service.core.entity.UserLogin;
|
|
|
+import cn.com.qmth.examcloud.service.core.entity.UserRole;
|
|
|
+import cn.com.qmth.examcloud.service.core.enums.UserScope;
|
|
|
import cn.com.qmth.examcloud.service.core.enums.UserType;
|
|
|
import cn.com.qmth.examcloud.service.core.params.UserParam;
|
|
|
import cn.com.qmth.examcloud.service.core.repo.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.service.core.repo.StudentRepo;
|
|
|
+import cn.com.qmth.examcloud.service.core.repo.UserLoginRepo;
|
|
|
import cn.com.qmth.examcloud.service.core.repo.UserRepo;
|
|
|
import cn.com.qmth.examcloud.service.core.repo.UserRoleRepo;
|
|
|
|
|
@@ -240,10 +243,26 @@ public class UserService {
|
|
|
}
|
|
|
|
|
|
public User save(User user) throws Exception{
|
|
|
- User old = userRepo.findByRootOrgIdAndLoginName(user.getRootOrgId(), user.getLoginName());
|
|
|
+ user.setScope(UserScope.ORG);
|
|
|
+ user.setType(UserType.NOT_STUDENT);
|
|
|
+ user.setCreateTime(new Date());
|
|
|
+ checkLoginName(user.getRootOrgId(), user.getLoginName());
|
|
|
+ return userRepo.save(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkLoginName(Long rootOrgId,String loginName) {
|
|
|
+ User old = userRepo.findByRootOrgIdAndLoginName(rootOrgId,loginName);
|
|
|
if(old!=null){
|
|
|
throw new RuntimeException("用户名已存在");
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ public User update(Long id, User user) {
|
|
|
+ User old = userRepo.findOne(id);
|
|
|
+ if(!old.getLoginName().equals(user.getLoginName())){
|
|
|
+ checkLoginName(user.getRootOrgId(), user.getLoginName());
|
|
|
+ }
|
|
|
+ user.setUpdateTime(new Date());
|
|
|
return userRepo.save(user);
|
|
|
}
|
|
|
|