|
@@ -23,6 +23,7 @@ import cn.com.qmth.examcloud.commons.web.security.bean.Role;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.core.basic.base.constants.PropKeys;
|
|
|
import cn.com.qmth.examcloud.core.basic.base.enums.AccountType;
|
|
|
+import cn.com.qmth.examcloud.core.basic.base.enums.UserType;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.RoleRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.StudentRepo;
|
|
@@ -118,7 +119,8 @@ public class AuthServiceImpl implements AuthService {
|
|
|
throw new StatusException("B-001003", "密码错误");
|
|
|
}
|
|
|
user.setUserId(userEntity.getId());
|
|
|
- user.setDisplayName(userEntity.getLoginName()+" ("+userEntity.getName()+")");
|
|
|
+ user.setUserType(UserType.COMMON.getCode());
|
|
|
+ user.setDisplayName(userEntity.getLoginName() + " (" + userEntity.getName() + ")");
|
|
|
user.setRootOrgId(userEntity.getRootOrgId());
|
|
|
user.setRootOrgName(rootOrg.getName());
|
|
|
user.setOrgId(userEntity.getOrgId());
|
|
@@ -150,6 +152,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
|
|
|
user.setStudentId(student.getId());
|
|
|
user.setUserId(student.getUserId());
|
|
|
+ user.setUserType(UserType.STUDENT.getCode());
|
|
|
user.setStudentCode(student.getStudentCode());
|
|
|
user.setIdentityNumber(student.getIdentityNumber());
|
|
|
user.setRootOrgId(student.getRootOrgId());
|
|
@@ -177,14 +180,18 @@ public class AuthServiceImpl implements AuthService {
|
|
|
* 构建key
|
|
|
*
|
|
|
* @author WANGWEI
|
|
|
- * @param userType
|
|
|
- * @param rootOrgId
|
|
|
- * @param userId
|
|
|
+ * @param user
|
|
|
* @return
|
|
|
*/
|
|
|
- private String buildUserKey(String userType, Long rootOrgId, Long userId) {
|
|
|
- String key = StringUtils.join("U_", userType, "_", String.valueOf(rootOrgId), "_",
|
|
|
- String.valueOf(userId));
|
|
|
+ private String buildUserKey(User user) {
|
|
|
+ Long rootOrgId = user.getRootOrgId();
|
|
|
+ String userType = user.getUserType();
|
|
|
+ String key = null;
|
|
|
+ if (UserType.COMMON.getCode().equals(userType)) {
|
|
|
+ key = StringUtils.join("U_", userType, "_", rootOrgId, "_", user.getUserId());
|
|
|
+ } else if (UserType.STUDENT.getCode().equals(userType)) {
|
|
|
+ key = StringUtils.join("U_", userType, "_", rootOrgId, "_", user.getStudentId());
|
|
|
+ }
|
|
|
return key;
|
|
|
}
|
|
|
|
|
@@ -193,7 +200,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
if (StringUtils.isNotBlank(user.getKey())) {
|
|
|
redisClient.delete(user.getKey());
|
|
|
} else {
|
|
|
- String key = buildUserKey(user.getUserType(), user.getRootOrgId(), user.getUserId());
|
|
|
+ String key = buildUserKey(user);
|
|
|
redisClient.delete(key);
|
|
|
}
|
|
|
}
|
|
@@ -284,8 +291,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
private void setSession(User user) {
|
|
|
user.setTokenCreationTime(new Date());
|
|
|
user.setToken(UUID.randomUUID());
|
|
|
-
|
|
|
- String key = buildUserKey(user.getUserType(), user.getRootOrgId(), user.getUserId());
|
|
|
+ String key = buildUserKey(user);
|
|
|
user.setKey(key);
|
|
|
user.setUserToken(key + ":" + user.getToken());
|
|
|
|