|
@@ -51,6 +51,7 @@ import cn.com.qmth.examcloud.core.basic.service.bean.LoginInfo;
|
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.OrgCacheBean;
|
|
|
import cn.com.qmth.examcloud.support.cache.bean.RootOrgCacheBean;
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.StudentCacheBean;
|
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
@@ -722,4 +723,42 @@ public class AuthServiceImpl implements AuthService {
|
|
|
return login(loginInfo);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public User login(UserType userType, Long userId) {
|
|
|
+
|
|
|
+ User user = new User();
|
|
|
+
|
|
|
+ Long rootOrgId = null;
|
|
|
+
|
|
|
+ if (userType.equals(UserType.STUDENT)) {
|
|
|
+
|
|
|
+ StudentCacheBean student = CacheHelper.getStudent(userId);
|
|
|
+
|
|
|
+ user.setUserId(student.getId());
|
|
|
+ user.setUserType(UserType.STUDENT);
|
|
|
+ user.setDisplayName(student.getName());
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ UserEntity userEntity = GlobalHelper.getEntity(userRepo, userId, UserEntity.class);
|
|
|
+ rootOrgId = userEntity.getRootOrgId();
|
|
|
+
|
|
|
+ user.setUserId(userEntity.getId());
|
|
|
+ user.setUserType(UserType.COMMON);
|
|
|
+ user.setDisplayName(userEntity.getLoginName() + " (" + userEntity.getName() + ")");
|
|
|
+
|
|
|
+ List<Role> roleList = getUserRoles(userEntity.getId());
|
|
|
+ user.setRoleList(roleList);
|
|
|
+ }
|
|
|
+
|
|
|
+ user.setRootOrgId(rootOrgId);
|
|
|
+ OrgCacheBean orgCacheBean = CacheHelper.getOrg(rootOrgId);
|
|
|
+ user.setRootOrgName(orgCacheBean.getName());
|
|
|
+ user.setRootOrgDomain(orgCacheBean.getDomainName());
|
|
|
+
|
|
|
+ setSession(user);
|
|
|
+
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
}
|