|
@@ -1,6 +1,7 @@
|
|
package com.qmth.themis.exam.api;
|
|
package com.qmth.themis.exam.api;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.qmth.themis.business.constant.SpringContextHolder;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
import com.qmth.themis.business.entity.TBSession;
|
|
import com.qmth.themis.business.entity.TBSession;
|
|
@@ -29,6 +30,7 @@ import com.qmth.themis.exam.util.ServletUtil;
|
|
import com.qmth.themis.mq.service.MqDtoService;
|
|
import com.qmth.themis.mq.service.MqDtoService;
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
@@ -74,6 +76,9 @@ public class TEStudentController {
|
|
@Resource
|
|
@Resource
|
|
TOeExamRecordService tOeExamRecordService;
|
|
TOeExamRecordService tOeExamRecordService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ RedisTemplate redisTemplate;
|
|
|
|
+
|
|
@ApiOperation(value = "学生登录接口")
|
|
@ApiOperation(value = "学生登录接口")
|
|
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
|
@ApiResponses({@ApiResponse(code = 200, message = "学生信息", response = TEStudent.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "学生信息", response = TEStudent.class)})
|
|
@@ -121,7 +126,7 @@ public class TEStudentController {
|
|
Platform platform = Platform.valueOf(ServletUtil.getRequestPlatform());
|
|
Platform platform = Platform.valueOf(ServletUtil.getRequestPlatform());
|
|
String deviceId = ServletUtil.getRequestDeviceId();
|
|
String deviceId = ServletUtil.getRequestDeviceId();
|
|
//添加用户鉴权缓存
|
|
//添加用户鉴权缓存
|
|
- AuthDto authDto = ehcacheService.addStudentCache(teStudent);
|
|
|
|
|
|
+ AuthDto authDto = ehcacheService.addStudentCache(teStudent.getId());
|
|
//生成token
|
|
//生成token
|
|
String token = RandomStringUtils.randomAlphanumeric(32);
|
|
String token = RandomStringUtils.randomAlphanumeric(32);
|
|
//添加用户缓存
|
|
//添加用户缓存
|
|
@@ -145,7 +150,7 @@ public class TEStudentController {
|
|
List<Map> list = teExamService.getWaitingExam(teStudent.getId());
|
|
List<Map> list = teExamService.getWaitingExam(teStudent.getId());
|
|
map.put("waiting", list);
|
|
map.put("waiting", list);
|
|
} else {
|
|
} else {
|
|
- unFinishExam.put("activity",unFinishExam);
|
|
|
|
|
|
+ unFinishExam.put("activity", unFinishExam);
|
|
map.put("unFinished", unFinishExam);
|
|
map.put("unFinished", unFinishExam);
|
|
}
|
|
}
|
|
//获取全局考试配置
|
|
//获取全局考试配置
|
|
@@ -164,10 +169,11 @@ public class TEStudentController {
|
|
public Result logout() throws NoSuchAlgorithmException {
|
|
public Result logout() throws NoSuchAlgorithmException {
|
|
TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
|
|
TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
|
|
TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
|
|
TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
|
|
- AuthDto authDto = (AuthDto) EhcacheUtil.get(SystemConstant.STUDENT_CACHE, teStudent.getId());
|
|
|
|
if (Objects.isNull(tbSession)) {
|
|
if (Objects.isNull(tbSession)) {
|
|
throw new BusinessException(ExceptionResultEnum.LOGIN_NO);
|
|
throw new BusinessException(ExceptionResultEnum.LOGIN_NO);
|
|
}
|
|
}
|
|
|
|
+ AuthDto authDto = (AuthDto) redisTemplate.opsForValue().get("student:oauth:cache::" + teStudent.getId());
|
|
|
|
+// AuthDto authDto = (AuthDto) EhcacheUtil.get(SystemConstant.STUDENT_CACHE, teStudent.getId());
|
|
redisUtil.deleteUserSession(tbSession.getId());
|
|
redisUtil.deleteUserSession(tbSession.getId());
|
|
//循环检查该用户下其他平台是否存在session,不存在则删除用户缓存和鉴权缓存
|
|
//循环检查该用户下其他平台是否存在session,不存在则删除用户缓存和鉴权缓存
|
|
boolean delete = true;
|
|
boolean delete = true;
|