|
@@ -8,6 +8,7 @@ import com.qmth.boot.tools.uuid.FastUUID;
|
|
|
import com.qmth.exam.reserve.bean.login.LoginReq;
|
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
|
import com.qmth.exam.reserve.bean.login.WechatLoginReq;
|
|
|
+import com.qmth.exam.reserve.cache.CacheConstants;
|
|
|
import com.qmth.exam.reserve.cache.LoginSessionManager;
|
|
|
import com.qmth.exam.reserve.entity.StudentEntity;
|
|
|
import com.qmth.exam.reserve.entity.UserEntity;
|
|
@@ -28,6 +29,9 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
|
|
|
|
private final static Logger log = LoggerFactory.getLogger(AuthServiceImpl.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LoginSessionManager loginSessionManager;
|
|
|
+
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
@@ -44,7 +48,7 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
|
throw new StatusException("登录密码不能为空");
|
|
|
}
|
|
|
|
|
|
- log.info("[USER_LOGIN] account:{}", req.getAccount());
|
|
|
+ log.debug("[USER_LOGIN] account:{}", req.getAccount());
|
|
|
UserEntity user = userService.findUserByLoginName(req.getOrgId(), req.getAccount());
|
|
|
if (user == null) {
|
|
|
throw new StatusException("登录用户不存在");
|
|
@@ -58,15 +62,16 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
|
LoginUser loginUser = new LoginUser();
|
|
|
loginUser.setId(user.getId());
|
|
|
loginUser.setOrgId(user.getOrgId());
|
|
|
+ loginUser.setCategoryId(user.getCategoryId());
|
|
|
loginUser.setAccount(user.getLoginName());
|
|
|
loginUser.setName(user.getName());
|
|
|
loginUser.setRole(user.getRole());
|
|
|
|
|
|
- loginUser.setSessionId("U_" + user.getId());
|
|
|
+ loginUser.setSessionId(CacheConstants.CACHE_USER_LOGIN + user.getId());
|
|
|
loginUser.setToken(FastUUID.get());
|
|
|
- LoginSessionManager.addLoginSession(loginUser);
|
|
|
+ loginSessionManager.addLoginSession(loginUser);
|
|
|
|
|
|
- log.info("[USER_LOGIN] account:{} {} {}", loginUser.getAccount(), loginUser.getName(), loginUser.getRole());
|
|
|
+ log.info("[USER_LOGIN_OK] account:{} {} {}", loginUser.getAccount(), loginUser.getName(), loginUser.getRole());
|
|
|
return loginUser;
|
|
|
}
|
|
|
|
|
@@ -80,7 +85,7 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
|
throw new StatusException("登录密码不能为空");
|
|
|
}
|
|
|
|
|
|
- log.info("[STUDENT_LOGIN] account:{}", req.getAccount());
|
|
|
+ log.debug("[STUDENT_LOGIN] account:{}", req.getAccount());
|
|
|
StudentEntity student = studentService.findStudentByStudentCode(req.getOrgId(), req.getAccount());
|
|
|
if (student == null) {
|
|
|
throw new StatusException("登录用户不存在");
|
|
@@ -94,15 +99,16 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
|
LoginUser loginUser = new LoginUser();
|
|
|
loginUser.setId(student.getId());
|
|
|
loginUser.setOrgId(student.getOrgId());
|
|
|
+ loginUser.setCategoryId(student.getCategoryId());
|
|
|
loginUser.setAccount(student.getStudentCode());
|
|
|
loginUser.setName(student.getName());
|
|
|
loginUser.setRole(Role.STUDENT);
|
|
|
|
|
|
- loginUser.setSessionId("S_" + student.getId());
|
|
|
+ loginUser.setSessionId(CacheConstants.CACHE_STUDENT_LOGIN + student.getId());
|
|
|
loginUser.setToken(FastUUID.get());
|
|
|
- LoginSessionManager.addLoginSession(loginUser);
|
|
|
+ loginSessionManager.addLoginSession(loginUser);
|
|
|
|
|
|
- log.info("[STUDENT_LOGIN] account:{} {}", loginUser.getAccount(), loginUser.getName());
|
|
|
+ log.info("[STUDENT_LOGIN_OK] account:{} {}", loginUser.getAccount(), loginUser.getName());
|
|
|
return loginUser;
|
|
|
}
|
|
|
|
|
@@ -113,13 +119,13 @@ public class AuthServiceImpl implements AuthorizationService<LoginUser>, AuthSer
|
|
|
|
|
|
@Override
|
|
|
public void logout(LoginUser loginUser) {
|
|
|
- LoginSessionManager.removeLoginSession(loginUser.getSessionId());
|
|
|
+ loginSessionManager.removeLoginSession(loginUser.getSessionId());
|
|
|
log.warn("用户退出登录!account:{},{}", loginUser.getAccount(), loginUser.getName());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public LoginUser findByIdentity(String identity, SignatureType type, String path) {
|
|
|
- return LoginSessionManager.getLoginSession(identity);
|
|
|
+ return loginSessionManager.getLoginSession(identity);
|
|
|
}
|
|
|
|
|
|
}
|