|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.blockchain.server.yyyf.controller; |
|
|
|
package com.blockchain.server.yyyf.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.blockchain.common.base.constant.YyyfConstant; |
|
|
|
import com.blockchain.common.base.constant.YyyfConstant; |
|
|
|
import com.blockchain.common.base.dto.ResultDTO; |
|
|
|
import com.blockchain.common.base.dto.ResultDTO; |
|
|
|
import com.blockchain.common.base.dto.TokenDTO; |
|
|
|
import com.blockchain.common.base.dto.TokenDTO; |
|
|
@ -85,7 +86,9 @@ public class LoginController { |
|
|
|
yyyfUserDto.setUserName(userName); |
|
|
|
yyyfUserDto.setUserName(userName); |
|
|
|
yyyfUserDto.setUserId(userId); |
|
|
|
yyyfUserDto.setUserId(userId); |
|
|
|
yyyfUserDto.setUserType(yyyfLoginRequestVo.getUserType()); |
|
|
|
yyyfUserDto.setUserType(yyyfLoginRequestVo.getUserType()); |
|
|
|
|
|
|
|
boolean needInit = false; |
|
|
|
|
|
|
|
AssessUser assessUser = null; |
|
|
|
|
|
|
|
List<TrainCaseTargetDto> trainCaseTargeList = null; |
|
|
|
//做考试和练习
|
|
|
|
//做考试和练习
|
|
|
|
if (0 == reqType || 1 == reqType) { |
|
|
|
if (0 == reqType || 1 == reqType) { |
|
|
|
if (0 == reqType) { |
|
|
|
if (0 == reqType) { |
|
|
@ -96,17 +99,17 @@ public class LoginController { |
|
|
|
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); |
|
|
|
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
AssessUser assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId); |
|
|
|
assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, examId); |
|
|
|
if (assessUser == null) { |
|
|
|
if (assessUser == null) { |
|
|
|
Date now = new Date(); |
|
|
|
Date now = new Date(); |
|
|
|
String tel=new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(userId)); |
|
|
|
String tel = new SimpleDateFormat("yyMMddHHmmss").format(now).concat(String.valueOf(userId)); |
|
|
|
|
|
|
|
|
|
|
|
//第一次进入进行注册
|
|
|
|
//第一次进入进行注册
|
|
|
|
String code=String.format("%06d",new Random().nextInt(1000000)); |
|
|
|
String code = String.format("%06d", new Random().nextInt(1000000)); |
|
|
|
redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel),code,YyyfConstant.TIME_OUT, TimeUnit.MINUTES); |
|
|
|
redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel), code, YyyfConstant.TIME_OUT, TimeUnit.MINUTES); |
|
|
|
yyyfLoginDto.setCode(code); |
|
|
|
yyyfLoginDto.setCode(code); |
|
|
|
|
|
|
|
|
|
|
|
String password=String.format("%08d",new Random().nextInt(10000000)); |
|
|
|
String password = String.format("%08d", new Random().nextInt(10000000)); |
|
|
|
String assessUserId = IdGenerator.uuid(); |
|
|
|
String assessUserId = IdGenerator.uuid(); |
|
|
|
assessUser = new AssessUser(); |
|
|
|
assessUser = new AssessUser(); |
|
|
|
assessUser.setId(assessUserId); |
|
|
|
assessUser.setId(assessUserId); |
|
|
@ -126,16 +129,15 @@ public class LoginController { |
|
|
|
//获取案例信息
|
|
|
|
//获取案例信息
|
|
|
|
HashOperations<String, String, ExamPaperDto> examPaperOpsForHash = redisTemplate.opsForHash(); |
|
|
|
HashOperations<String, String, ExamPaperDto> examPaperOpsForHash = redisTemplate.opsForHash(); |
|
|
|
ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, examPaperId); |
|
|
|
ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, examPaperId); |
|
|
|
List<TrainCaseTargetDto> trainCaseTargeList = examPaperDto.getTrainCaseTargetList(); |
|
|
|
trainCaseTargeList = examPaperDto.getTrainCaseTargetList(); |
|
|
|
assessUser.setWechatInitMoney(examPaperDto.getWechatInitMoney()); |
|
|
|
assessUser.setWechatInitMoney(examPaperDto.getWechatInitMoney()); |
|
|
|
assessUser.setAlipayInitMoney(examPaperDto.getAlipayInitMoney()); |
|
|
|
assessUser.setAlipayInitMoney(examPaperDto.getAlipayInitMoney()); |
|
|
|
assessUser.setBankcardInitMoney(examPaperDto.getBankcardInitMoney()); |
|
|
|
assessUser.setBankcardInitMoney(examPaperDto.getBankcardInitMoney()); |
|
|
|
assessUser.setDigitwalletInitMoney(examPaperDto.getDigitwalletInitMoney()); |
|
|
|
assessUser.setDigitwalletInitMoney(examPaperDto.getDigitwalletInitMoney()); |
|
|
|
this.assessUserService.initAssessUser(assessUser, trainCaseTargeList); |
|
|
|
needInit = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yyyfUserDto.setAssessUserId(assessUser.getId()); |
|
|
|
yyyfUserDto.setAssessUserId(assessUser.getId()); |
|
|
|
yyyfLoginDto.setTel(assessUser.getTel()); |
|
|
|
yyyfLoginDto.setTel(assessUser.getTel()); |
|
|
|
yyyfLoginDto.setPassword(assessUser.getPassword()); |
|
|
|
yyyfLoginDto.setPassword(assessUser.getPassword()); |
|
|
@ -163,7 +165,7 @@ public class LoginController { |
|
|
|
examDto.setExamPaperId(examPaperId); |
|
|
|
examDto.setExamPaperId(examPaperId); |
|
|
|
examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto); |
|
|
|
examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto); |
|
|
|
} |
|
|
|
} |
|
|
|
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000); |
|
|
|
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime()) / 1000); |
|
|
|
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId); |
|
|
|
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId); |
|
|
|
if (joinStuIds == null) { |
|
|
|
if (joinStuIds == null) { |
|
|
|
joinStuIds = new ArrayList<Integer>(); |
|
|
|
joinStuIds = new ArrayList<Integer>(); |
|
|
@ -187,19 +189,27 @@ public class LoginController { |
|
|
|
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); |
|
|
|
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
String jioinExamId=null; |
|
|
|
String jioinExamId = null; |
|
|
|
if (redisTemplate.hasKey(caseKey)) { |
|
|
|
if (redisTemplate.hasKey(caseKey)) { |
|
|
|
Map<String, String> examMsgMap = (Map<String, String>) redisTemplate.opsForValue().get(caseKey); |
|
|
|
Map<String, String> examMsgMap = (Map<String, String>) redisTemplate.opsForValue().get(caseKey); |
|
|
|
jioinExamId= examMsgMap.get("examId"); |
|
|
|
jioinExamId = examMsgMap.get("examId"); |
|
|
|
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY,jioinExamId); |
|
|
|
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, jioinExamId); |
|
|
|
} |
|
|
|
} |
|
|
|
//缓存是考试,要进入练习,则不让进入
|
|
|
|
//缓存是考试,要进入练习,则不让进入
|
|
|
|
if (joinStuIds != null && joinStuIds.stream() |
|
|
|
if (joinStuIds != null && joinStuIds.stream() |
|
|
|
.filter(stuIds -> (stuIds.equals(userId))).count() != 0) { |
|
|
|
.filter(stuIds -> (stuIds.equals(userId))).count() != 0) { |
|
|
|
yyyfLoginDto.setStatus(3); |
|
|
|
yyyfLoginDto.setStatus(3); |
|
|
|
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE); |
|
|
|
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE); |
|
|
|
ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId); |
|
|
|
ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, jioinExamId); |
|
|
|
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000); |
|
|
|
LOG.info("examId is " + examId + "examDto is " + JSONObject.toJSON(examDto) + "jioinExamId is " + jioinExamId); |
|
|
|
|
|
|
|
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime()) / 1000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assessUser = this.assessUserService.selectAssessUserByUserIdAndissueIdForNotEnd(userId, jioinExamId); |
|
|
|
|
|
|
|
yyyfUserDto.setAssessUserId(assessUser.getId()); |
|
|
|
|
|
|
|
yyyfLoginDto.setTel(assessUser.getTel()); |
|
|
|
|
|
|
|
yyyfLoginDto.setPassword(assessUser.getPassword()); |
|
|
|
|
|
|
|
yyyfLoginDto.setNickName(userName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> map = new HashMap<String, String>(); |
|
|
|
Map<String, String> map = new HashMap<String, String>(); |
|
|
|
map.put("examPaperId", examDto.getExamPaperId()); |
|
|
|
map.put("examPaperId", examDto.getExamPaperId()); |
|
|
@ -218,7 +228,9 @@ public class LoginController { |
|
|
|
yyyfLoginDto.setStatus(1); |
|
|
|
yyyfLoginDto.setStatus(1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (needInit && assessUser != null && trainCaseTargeList != null) { |
|
|
|
|
|
|
|
this.assessUserService.initAssessUser(assessUser, trainCaseTargeList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); |
|
|
|
return handleAfterLogin(yyyfLoginDto, yyyfUserDto); |
|
|
|
} |
|
|
|
} |
|
|
|