|
@@ -14,6 +14,7 @@ import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
|
|
|
import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
|
+import com.qmth.themis.business.dto.ExpireTimeDTO;
|
|
|
import com.qmth.themis.business.dto.MqDto;
|
|
|
import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
|
|
|
import com.qmth.themis.business.dto.response.TEExamActivityDto;
|
|
@@ -34,8 +35,6 @@ import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.themis.common.enums.Platform;
|
|
|
import com.qmth.themis.common.enums.Source;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
-import com.qmth.themis.common.signature.SignatureInfo;
|
|
|
-import com.qmth.themis.common.signature.SignatureType;
|
|
|
import com.qmth.themis.common.util.AesUtil;
|
|
|
import com.qmth.themis.common.util.Result;
|
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
@@ -103,13 +102,13 @@ public class TEStudentController {
|
|
|
|
|
|
@ApiOperation(value = "学生登录接口")
|
|
|
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "学生信息", response = TEExamResultDto.class)})
|
|
|
- public Result login(@ApiJsonObject(name = "loginStudent", value = {
|
|
|
- @ApiJsonProperty(key = "identity", description = "证件号"),
|
|
|
- @ApiJsonProperty(key = "password", description = "密码"),
|
|
|
- @ApiJsonProperty(key = "orgId", type = "long", example = "1", description = "机构id"),
|
|
|
- @ApiJsonProperty(key = "examId", type = "long", example = "1", description = "批次id")
|
|
|
- }) @ApiParam(value = "学生信息", required = true) @RequestBody Map<String, Object> mapParameter) throws NoSuchAlgorithmException {
|
|
|
+ @ApiResponses({ @ApiResponse(code = 200, message = "学生信息", response = TEExamResultDto.class) })
|
|
|
+ public Result login(
|
|
|
+ @ApiJsonObject(name = "loginStudent", value = { @ApiJsonProperty(key = "identity", description = "证件号"),
|
|
|
+ @ApiJsonProperty(key = "password", description = "密码"),
|
|
|
+ @ApiJsonProperty(key = "orgId", type = "long", example = "1", description = "机构id"),
|
|
|
+ @ApiJsonProperty(key = "examId", type = "long", example = "1", description = "批次id") }) @ApiParam(value = "学生信息", required = true) @RequestBody Map<String, Object> mapParameter)
|
|
|
+ throws NoSuchAlgorithmException {
|
|
|
if (Objects.isNull(mapParameter)) {
|
|
|
throw new BusinessException(ExceptionResultEnum.STUDENT_IS_NULL);
|
|
|
}
|
|
@@ -128,13 +127,17 @@ public class TEStudentController {
|
|
|
if (Objects.nonNull(mapParameter.get("examId"))) {
|
|
|
examId = Long.parseLong(String.valueOf(mapParameter.get("examId")));
|
|
|
ExamCacheBean ec = teExamService.getExamCacheBean(examId);
|
|
|
- tbOrg = Objects.isNull(redisUtil.getOrg(ec.getOrgId())) ? tbOrgService.getById(ec.getOrgId()) : (TBOrg) redisUtil.getOrg(ec.getOrgId());
|
|
|
+ tbOrg = Objects.isNull(redisUtil.getOrg(ec.getOrgId())) ?
|
|
|
+ tbOrgService.getById(ec.getOrgId()) :
|
|
|
+ (TBOrg) redisUtil.getOrg(ec.getOrgId());
|
|
|
}
|
|
|
if (Objects.isNull(orgId) && Objects.isNull(examId)) {
|
|
|
throw new BusinessException(ExceptionResultEnum.ORG_ID_OR_EXAM_ID_NOT_CHOOSE);
|
|
|
}
|
|
|
if (Objects.nonNull(orgId)) {
|
|
|
- tbOrg = Objects.isNull(redisUtil.getOrg(orgId)) ? tbOrgService.getById(orgId) : (TBOrg) redisUtil.getOrg(orgId);
|
|
|
+ tbOrg = Objects.isNull(redisUtil.getOrg(orgId)) ?
|
|
|
+ tbOrgService.getById(orgId) :
|
|
|
+ (TBOrg) redisUtil.getOrg(orgId);
|
|
|
}
|
|
|
if (Objects.isNull(tbOrg)) {
|
|
|
throw new BusinessException(ExceptionResultEnum.ORG_NO);
|
|
@@ -153,7 +156,8 @@ public class TEStudentController {
|
|
|
throw new BusinessException(ExceptionResultEnum.STUDENT_NO);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(user.getBasePhotoPath())) {
|
|
|
- user.setBasePhotoPath(ossUtil.getAliYunOssPublicDomain().getPublicUrl() + File.separator + user.getBasePhotoPath());
|
|
|
+ user.setBasePhotoPath(
|
|
|
+ ossUtil.getAliYunOssPublicDomain().getPublicUrl() + File.separator + user.getBasePhotoPath());
|
|
|
}
|
|
|
String loginPassword = AesUtil.decryptCs7(password, Constants.AES_RULE);
|
|
|
|
|
@@ -166,7 +170,8 @@ public class TEStudentController {
|
|
|
if (unFinishedRecordId != null) {
|
|
|
WebsocketStatusEnum sta = ExamRecordCacheUtil.getClientWebsocketStatus(unFinishedRecordId);
|
|
|
ExamRecordStatusEnum status = ExamRecordCacheUtil.getStatus(unFinishedRecordId);
|
|
|
- if (WebsocketStatusEnum.ON_LINE.equals(sta) && (Objects.nonNull(status) && !Objects.equals(status, ExamRecordStatusEnum.FIRST_PREPARE))) {
|
|
|
+ if (WebsocketStatusEnum.ON_LINE.equals(sta) && (Objects.nonNull(status) && !Objects
|
|
|
+ .equals(status, ExamRecordStatusEnum.FIRST_PREPARE))) {
|
|
|
throw new BusinessException(ExceptionResultEnum.STUDENT_NOT_ALLOW_LOGIN);
|
|
|
}
|
|
|
}
|
|
@@ -200,30 +205,33 @@ public class TEStudentController {
|
|
|
}
|
|
|
|
|
|
redisUtil.setStudent(teStudent.getId(), teStudentCacheDto);
|
|
|
- String source = null;
|
|
|
- if (Objects.equals(platform.name(), Platform.WIN.name()) || Objects.equals(platform.name(), Platform.MAC.name())) {
|
|
|
- source = platform.getSource().split(",")[1];
|
|
|
- } else if (Objects.equals(platform.name(), Platform.WXAPP.name()) || Objects.equals(platform.name(), Platform.WEB.name())) {
|
|
|
- source = platform.getSource();
|
|
|
- } else if (Objects.equals(platform.name(), Platform.IOS.name()) || Objects.equals(platform.name(), Platform.ANDROID.name())) {
|
|
|
- source = platform.getSource().split(",")[2];
|
|
|
+
|
|
|
+ Source source = null;
|
|
|
+ if (Platform.WIN == platform || Platform.MAC == platform) {
|
|
|
+ source = Source.OE_CLIENT;
|
|
|
+ } else {
|
|
|
+ throw new BusinessException(ExceptionResultEnum.PLATFORM_INVALID);
|
|
|
}
|
|
|
|
|
|
- String sessionId = SessionUtil.digest(teStudent.getIdentity(), Math.abs(authDto.getRoleCodes().toString().hashCode()), source);
|
|
|
+ String sessionId = SessionUtil
|
|
|
+ .digest(teStudent.getIdentity(), Math.abs(authDto.getRoleCodes().toString().hashCode()), source);
|
|
|
|
|
|
- Map<String, Object> expireMap = SystemConstant.getExpireTime(platform);
|
|
|
- Date expire = (Date) expireMap.get("date");
|
|
|
- Long redisExpire = Long.parseLong(String.valueOf(expireMap.get("redisExpire")));
|
|
|
- TBSession tbSession = new TBSession(sessionId, String.valueOf(teStudent.getId()), authDto.getRoleCodes().toString(), source, platform.name(), deviceId, ServletUtil.getRequest().getLocalAddr(), token, expire.getTime());
|
|
|
- redisUtil.setUserSession(sessionId, tbSession, redisExpire);
|
|
|
+ ExpireTimeDTO expireTime = SystemConstant.getExpireTime(source, platform);
|
|
|
+ TBSession tbSession = new TBSession(sessionId, String.valueOf(teStudent.getId()),
|
|
|
+ authDto.getRoleCodes().toString(), source.name(), platform.name(), deviceId,
|
|
|
+ ServletUtil.getRequest().getLocalAddr(), token, expireTime.getDate().getTime());
|
|
|
+ redisUtil.setUserSession(sessionId, tbSession, expireTime.getExpireSeconds());
|
|
|
|
|
|
- MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), platform.name(), tbSession, MqTagEnum.valueOf(platform.name()), tbSession.getId(), teStudent.getIdentity());
|
|
|
+ MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), platform.name(), tbSession,
|
|
|
+ MqTagEnum.valueOf(platform.name()), tbSession.getId(), teStudent.getIdentity());
|
|
|
mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
- MqDto mqDtoLog = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.STUDENT.name(), SystemOperationEnum.LOGIN, MqTagEnum.STUDENT, String.valueOf(teStudent.getId()), teStudent.getIdentity());
|
|
|
+ MqDto mqDtoLog = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.STUDENT.name(),
|
|
|
+ SystemOperationEnum.LOGIN, MqTagEnum.STUDENT, String.valueOf(teStudent.getId()),
|
|
|
+ teStudent.getIdentity());
|
|
|
mqDtoService.assembleSendOneWayMsg(mqDtoLog);
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
if (Objects.isNull(ExamingDataCacheUtil.getUnFinishedRecordId(teStudent.getId()))) {
|
|
@@ -243,10 +251,13 @@ public class TEStudentController {
|
|
|
Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
|
|
|
ExamCacheBean ec = teExamService.getExamCacheBean(ecExamId);
|
|
|
- ExamActivityCacheBean examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(examActivityId);
|
|
|
+ ExamActivityCacheBean examActivityCacheBean = teExamActivityService
|
|
|
+ .getExamActivityCacheBean(examActivityId);
|
|
|
ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
|
|
|
- if (Objects.equals(status, ExamRecordStatusEnum.ANSWERING) || Objects.equals(status, ExamRecordStatusEnum.BREAK_OFF) || Objects.equals(status, ExamRecordStatusEnum.RESUME_PREPARE)) {
|
|
|
+ if (Objects.equals(status, ExamRecordStatusEnum.ANSWERING) || Objects
|
|
|
+ .equals(status, ExamRecordStatusEnum.BREAK_OFF) || Objects
|
|
|
+ .equals(status, ExamRecordStatusEnum.RESUME_PREPARE)) {
|
|
|
|
|
|
if (Objects.equals(status, ExamRecordStatusEnum.ANSWERING)) {
|
|
|
|
|
@@ -257,7 +268,8 @@ public class TEStudentController {
|
|
|
if (finished) {
|
|
|
map = this.getWaitList(teStudent.getId(), examId, orgId, map);
|
|
|
} else {
|
|
|
- ExamUnFinishBean examUnFinishBean = this.unFinishCommon(recordId, ec, examStudentCacheBean, examActivityCacheBean, examStudentId);
|
|
|
+ ExamUnFinishBean examUnFinishBean = this
|
|
|
+ .unFinishCommon(recordId, ec, examStudentCacheBean, examActivityCacheBean, examStudentId);
|
|
|
map.put("unFinished", examUnFinishBean);
|
|
|
}
|
|
|
} else {
|
|
@@ -268,7 +280,7 @@ public class TEStudentController {
|
|
|
TEConfig teConfig = teConfigService.getGlobalConfig();
|
|
|
map.put(SystemConstant.ACCESS_TOKEN, token);
|
|
|
map.put(SystemConstant.GLOBAL, teConfig);
|
|
|
-
|
|
|
+
|
|
|
map.put(SystemConstant.STUDENT_ACCOUNT, teStudent);
|
|
|
map.put(SystemConstant.SESSION_ID, sessionId);
|
|
|
return ResultUtil.ok(map);
|
|
@@ -276,7 +288,7 @@ public class TEStudentController {
|
|
|
|
|
|
@ApiOperation(value = "登出接口")
|
|
|
@RequestMapping(value = "/logout", method = RequestMethod.POST)
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
|
+ @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
|
|
|
public Result logout() throws NoSuchAlgorithmException {
|
|
|
TEStudentCacheDto teStudent = (TEStudentCacheDto) ServletUtil.getRequestStudentAccount();
|
|
|
TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
|
|
@@ -288,7 +300,8 @@ public class TEStudentController {
|
|
|
|
|
|
boolean delete = true;
|
|
|
for (Source s : Source.values()) {
|
|
|
- String sessionId = SessionUtil.digest(teStudent.getIdentity(), Math.abs(authDto.getRoleCodes().toString().hashCode()), s.name());
|
|
|
+ String sessionId = SessionUtil
|
|
|
+ .digest(teStudent.getIdentity(), Math.abs(authDto.getRoleCodes().toString().hashCode()), s.name());
|
|
|
if (Objects.nonNull(redisUtil.getUserSession(sessionId))) {
|
|
|
delete = false;
|
|
|
break;
|
|
@@ -299,7 +312,9 @@ public class TEStudentController {
|
|
|
cacheService.removeStudentCache(teStudent.getId());
|
|
|
}
|
|
|
|
|
|
- MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.STUDENT.name(), SystemOperationEnum.LOGOUT, MqTagEnum.STUDENT, String.valueOf(teStudent.getId()), teStudent.getIdentity());
|
|
|
+ MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.STUDENT.name(),
|
|
|
+ SystemOperationEnum.LOGOUT, MqTagEnum.STUDENT, String.valueOf(teStudent.getId()),
|
|
|
+ teStudent.getIdentity());
|
|
|
mqDtoService.assembleSendOneWayMsg(mqDto);
|
|
|
|
|
|
return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
|
|
@@ -315,19 +330,21 @@ public class TEStudentController {
|
|
|
* @param examStudentId
|
|
|
* @return
|
|
|
*/
|
|
|
- private ExamUnFinishBean unFinishCommon(Long recordId, ExamCacheBean ec, ExamStudentCacheBean examStudentCacheBean, ExamActivityCacheBean examActivityCacheBean, Long examStudentId) {
|
|
|
- ExamCourseCacheBean examCourseCacheBean = teExamCourseService.getExamCourseCacheBean(ec.getId(), examStudentCacheBean.getCourseCode());
|
|
|
- TEExamActivityDto teExamActivityDto = new TEExamActivityDto(ec, examActivityCacheBean, examStudentCacheBean, examStudentId, examCourseCacheBean
|
|
|
- , ExamRecordCacheUtil.getStartTime(recordId)
|
|
|
- , ExamRecordCacheUtil.getEndTime(recordId)
|
|
|
- , ExamRecordCacheUtil.getOpeningSeconds(recordId)
|
|
|
- , ExamRecordCacheUtil.getMinDurationSeconds(recordId)
|
|
|
- , ExamRecordCacheUtil.getMaxDurationSeconds(recordId)
|
|
|
- , ExamRecordCacheUtil.getForceFinish(recordId));
|
|
|
+ private ExamUnFinishBean unFinishCommon(Long recordId, ExamCacheBean ec, ExamStudentCacheBean examStudentCacheBean,
|
|
|
+ ExamActivityCacheBean examActivityCacheBean, Long examStudentId) {
|
|
|
+ ExamCourseCacheBean examCourseCacheBean = teExamCourseService
|
|
|
+ .getExamCourseCacheBean(ec.getId(), examStudentCacheBean.getCourseCode());
|
|
|
+ TEExamActivityDto teExamActivityDto = new TEExamActivityDto(ec, examActivityCacheBean, examStudentCacheBean,
|
|
|
+ examStudentId, examCourseCacheBean, ExamRecordCacheUtil.getStartTime(recordId),
|
|
|
+ ExamRecordCacheUtil.getEndTime(recordId), ExamRecordCacheUtil.getOpeningSeconds(recordId),
|
|
|
+ ExamRecordCacheUtil.getMinDurationSeconds(recordId),
|
|
|
+ ExamRecordCacheUtil.getMaxDurationSeconds(recordId), ExamRecordCacheUtil.getForceFinish(recordId));
|
|
|
Gson gson = new Gson();
|
|
|
- ExamActivityUnFinishBean examActivityUnFinishBean = gson.fromJson(gson.toJson(teExamActivityDto), ExamActivityUnFinishBean.class);
|
|
|
+ ExamActivityUnFinishBean examActivityUnFinishBean = gson
|
|
|
+ .fromJson(gson.toJson(teExamActivityDto), ExamActivityUnFinishBean.class);
|
|
|
examActivityUnFinishBean.setRecordId(recordId);
|
|
|
- return new ExamUnFinishBean(ec.getId(), ec.getName(), ec.getPreNotice(), ec.getPreNoticeStaySeconds(), ec.getPostNotice(), examActivityUnFinishBean);
|
|
|
+ return new ExamUnFinishBean(ec.getId(), ec.getName(), ec.getPreNotice(), ec.getPreNoticeStaySeconds(),
|
|
|
+ ec.getPostNotice(), examActivityUnFinishBean);
|
|
|
}
|
|
|
|
|
|
|