|
@@ -1,7 +1,6 @@
|
|
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;
|
|
@@ -11,7 +10,6 @@ import com.qmth.themis.business.enums.MqEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.enums.SystemOperationEnum;
|
|
import com.qmth.themis.business.enums.SystemOperationEnum;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.service.*;
|
|
-import com.qmth.themis.business.util.EhcacheUtil;
|
|
|
|
import com.qmth.themis.business.util.JacksonUtil;
|
|
import com.qmth.themis.business.util.JacksonUtil;
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
import com.qmth.themis.business.util.SessionUtil;
|
|
import com.qmth.themis.business.util.SessionUtil;
|
|
@@ -30,7 +28,6 @@ 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;
|
|
@@ -56,7 +53,7 @@ public class TEStudentController {
|
|
TEStudentService teStudentService;
|
|
TEStudentService teStudentService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- EhcacheService ehcacheService;
|
|
|
|
|
|
+ CacheService cacheService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
DictionaryConfig dictionaryConfig;
|
|
DictionaryConfig dictionaryConfig;
|
|
@@ -76,9 +73,6 @@ 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)})
|
|
@@ -126,7 +120,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.getId());
|
|
|
|
|
|
+ AuthDto authDto = cacheService.addStudentCache(teStudent.getId());
|
|
//生成token
|
|
//生成token
|
|
String token = RandomStringUtils.randomAlphanumeric(32);
|
|
String token = RandomStringUtils.randomAlphanumeric(32);
|
|
//添加用户缓存
|
|
//添加用户缓存
|
|
@@ -172,8 +166,7 @@ public class TEStudentController {
|
|
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());
|
|
|
|
|
|
+ AuthDto authDto = (AuthDto) redisUtil.get(dictionaryConfig.cacheConfigDomain().getStudentOauth() + "::" + teStudent.getId());
|
|
redisUtil.deleteUserSession(tbSession.getId());
|
|
redisUtil.deleteUserSession(tbSession.getId());
|
|
//循环检查该用户下其他平台是否存在session,不存在则删除用户缓存和鉴权缓存
|
|
//循环检查该用户下其他平台是否存在session,不存在则删除用户缓存和鉴权缓存
|
|
boolean delete = true;
|
|
boolean delete = true;
|
|
@@ -186,7 +179,7 @@ public class TEStudentController {
|
|
}
|
|
}
|
|
if (delete) {
|
|
if (delete) {
|
|
redisUtil.deleteStudent(teStudent.getId());
|
|
redisUtil.deleteStudent(teStudent.getId());
|
|
- ehcacheService.removeStudentCache(teStudent.getId());
|
|
|
|
|
|
+ cacheService.removeStudentCache(teStudent.getId());
|
|
}
|
|
}
|
|
//mq发送消息start
|
|
//mq发送消息start
|
|
mqDtoService.assembleSendOneWayMsg(dictionaryConfig.mqConfigDomain().getUserLogTopic(), authDto.getRoleCodes().toString().contains(RoleEnum.STUDENT.name()) ? dictionaryConfig.mqConfigDomain().getUserLogTopicStudentTag() : dictionaryConfig.mqConfigDomain().getUserLogTopicUserTag(), SystemOperationEnum.LOGOUT, MqEnum.EXAM_STUDENT_LOG.name(), teStudent.getId(), teStudent.getIdentity());
|
|
mqDtoService.assembleSendOneWayMsg(dictionaryConfig.mqConfigDomain().getUserLogTopic(), authDto.getRoleCodes().toString().contains(RoleEnum.STUDENT.name()) ? dictionaryConfig.mqConfigDomain().getUserLogTopicStudentTag() : dictionaryConfig.mqConfigDomain().getUserLogTopicUserTag(), SystemOperationEnum.LOGOUT, MqEnum.EXAM_STUDENT_LOG.name(), teStudent.getId(), teStudent.getIdentity());
|