学生答题

pull/1/head
unclekh 5 years ago
parent 7b1a99cbf0
commit 0a84e930b2
  1. 1
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/constant/BaseConstant.java
  2. 6
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/constant/YyyfConstant.java
  3. 1
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/SessionUserDTO.java
  4. 59
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java
  5. 44
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/entity/YyyfUser.java
  6. 16
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/mapper/YyyfUserMapper.java
  7. 26
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/YyyfUserService.java
  8. 63
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/service/impl/YyyfUserServiceImpl.java
  9. 6
      blockchain-server/blockchain-server-user/src/main/resources/mapper/YyyfUserMapper.xml
  10. 42
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/train/dto/ExamPaperDto.java
  11. 39
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/train/dto/TrainCaseTargetDto.java
  12. 46
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java
  13. 93
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/StudentAnswerController.java
  14. 18
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/StudentAnswerApi.java
  15. 32
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamPaperDto.java
  16. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/StudentAnswerDto.java
  17. 19
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/StudentTrainCaseTargetDto.java
  18. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginDto.java
  19. 4
      pom.xml

@ -16,5 +16,6 @@ public class BaseConstant {
public static final int REQUEST_SUCCESS = 200;// 成功标识
public static final String YYYF_TOKEN_HEADER = "X-Requested-YyyfToken";//yyyfToken
}

@ -19,8 +19,8 @@ public class YyyfConstant {
//Submitted
public static final String SUBMITTED="您的考试已提交,不允许再次进入";
public static final String EXAM_PAPER_KEY="examPaperKey";
/**案例缓存Key*/
public static final String EXAM_PAPER_KEY="zhiXinLianExamPaperKey";
/**参加考试的人员id key*/
public static final String JOIN_EXAM_STU_IDS_KEY="joinExamStuIds";
@ -31,4 +31,6 @@ public class YyyfConstant {
/**以渔有方与智信链用户绑定的cookies*/
public static final String YYYF_ZHIXINLIAN_USER_KEY="yyyfZhixinlianUserKey";
}

@ -12,4 +12,5 @@ public class SessionUserDTO extends BaseDTO{
private String id;//用户id
private String tel;//手机号
private Long timestamp;//时间戳
private Integer yyyfUserId;
}

@ -5,6 +5,7 @@ import com.blockchain.common.base.constant.TokenTypeEnums;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.SessionUserDTO;
import com.blockchain.common.base.dto.TokenDTO;
import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.common.base.util.HttpRequestUtil;
import com.blockchain.common.base.util.RSACoderUtils;
import com.blockchain.common.base.util.SSOHelper;
@ -18,14 +19,10 @@ import com.blockchain.server.user.common.utils.SmsCodeUtils;
import com.blockchain.server.user.controller.api.LoginApi;
import com.blockchain.server.user.dto.UserBaseDTO;
import com.blockchain.server.user.entity.UserMain;
import com.blockchain.server.user.service.PushUserService;
import com.blockchain.server.user.service.SmsCountService;
import com.blockchain.server.user.service.UserLoginService;
import com.blockchain.server.user.service.UserMainService;
import com.blockchain.server.user.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -34,7 +31,6 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
/**
* @author huangxl
@ -63,6 +59,9 @@ public class LoginController {
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private YyyfUserService yyyfUserService;
@PostMapping("/password")
@ApiOperation(value = LoginApi.PassWorldLogin.METHOD_NAME,
notes = LoginApi.PassWorldLogin.METHOD_NOTE)
@ -71,7 +70,7 @@ public class LoginController {
@ApiParam(LoginApi.PassWorldLogin.METHOD_API_CLIENT_ID) @RequestParam(name = "clientId", required = false) String clientId,
HttpServletRequest request) {
UserMain userMain = userLoginService.handleLoginByPassword(tel, password);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request));
return handleAppAfterLogin(userMain, clientId, getUserLocale(request), request);
}
@PostMapping("/loginByCode")
@ -85,7 +84,7 @@ public class LoginController {
UserMain userMain = userLoginService.handleLoginByPhoneCode(tel);
// userMainService.selectByMobilePhone(tel);
smsCodeUtils.removeKey(tel, SmsCountEnum.SMS_COUNT_LOGIN);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request));
return handleAppAfterLogin(userMain, clientId, getUserLocale(request), request);
}
@PostMapping("/register")
@ -103,7 +102,7 @@ public class LoginController {
smsCodeUtils.validateVerifyCode(code, tel, SmsCountEnum.SMS_COUNT_REGISTER);
UserMain userMain = userMainService.handleRegister(tel, invitationCode, internationalCode, password, nickName);
smsCodeUtils.removeKey(tel, SmsCountEnum.SMS_COUNT_REGISTER);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request));
return handleAppAfterLogin(userMain, clientId, getUserLocale(request), request);
}
@PostMapping("/sendLoginCode")
@ -168,21 +167,21 @@ public class LoginController {
@ApiOperation(value = LoginApi.PassWorldLoginPC.METHOD_NAME,
notes = LoginApi.PassWorldLoginPC.METHOD_NOTE)
public ResultDTO loginByPasswordPC(@ApiParam(LoginApi.PassWorldLoginPC.METHOD_API_TEL) @RequestParam(name = "tel") String tel,
@ApiParam(LoginApi.PassWorldLoginPC.METHOD_API_PASS) @RequestParam(name = "password") String password) {
@ApiParam(LoginApi.PassWorldLoginPC.METHOD_API_PASS) @RequestParam(name = "password") String password, HttpServletRequest request) {
UserMain userMain = userLoginService.handleLoginByPassword(tel, password);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue());
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue(), request);
}
@PostMapping("/loginByCode2")
@ApiOperation(value = LoginApi.SmsCodeLoginPC.METHOD_NAME,
notes = LoginApi.SmsCodeLoginPC.METHOD_NOTE)
public ResultDTO loginBysmsCodePC(@ApiParam(LoginApi.SmsCodeLoginPC.METHOD_API_TEL) @RequestParam(name = "tel") String tel,
@ApiParam(LoginApi.SmsCodeLoginPC.METHOD_API_CODE) @RequestParam(name = "code") String code) {
@ApiParam(LoginApi.SmsCodeLoginPC.METHOD_API_CODE) @RequestParam(name = "code") String code, HttpServletRequest request) {
smsCodeUtils.validateVerifyCode(code, tel, SmsCountEnum.SMS_COUNT_LOGIN);
UserMain userMain = userLoginService.handleLoginByPhoneCode(tel);
// userMainService.selectByMobilePhone(tel);
smsCodeUtils.removeKey(tel, SmsCountEnum.SMS_COUNT_LOGIN);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue());
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue(), request);
}
@PostMapping("/register2")
@ -193,12 +192,12 @@ public class LoginController {
@ApiParam(LoginApi.RegisterPC.METHOD_API_INVITATION_CODE) @RequestParam(value = "invitationCode", required = false) String invitationCode,
@ApiParam(LoginApi.RegisterPC.METHOD_API_PASSWORD) @RequestParam(value = "password", required = false) String password,
@ApiParam(LoginApi.RegisterPC.METHOD_API_INTERNATIONAL_CODE) @RequestParam(value = "internationalCode", required = false, defaultValue = InternationalConstant.DEFAULT_CODE) String internationalCode,
@ApiParam(LoginApi.RegisterPC.METHOD_API_NICK_NAME) @RequestParam(value = "nickName", required = false) String nickName
@ApiParam(LoginApi.RegisterPC.METHOD_API_NICK_NAME) @RequestParam(value = "nickName", required = false) String nickName, HttpServletRequest request
) {
smsCodeUtils.validateVerifyCode(code, tel, SmsCountEnum.SMS_COUNT_REGISTER);
UserMain userMain = userMainService.handleRegister(tel, invitationCode, internationalCode, password, nickName);
smsCodeUtils.removeKey(tel, SmsCountEnum.SMS_COUNT_REGISTER);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue());
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue(), request);
}
@PostMapping("/loginout2")
@ -216,11 +215,12 @@ public class LoginController {
* @param tel 手机号
* @param timestamp 时间撮
*/
private void setUserToRedis(String id, String tel, long timestamp, String tokenType) {
private void setUserToRedis(String id, String tel, long timestamp, String tokenType, Integer yyyfUserId) {
SessionUserDTO userDTO = new SessionUserDTO();
userDTO.setId(id);
userDTO.setTel(tel);
userDTO.setTimestamp(timestamp);
userDTO.setYyyfUserId(yyyfUserId);
SSOHelper.setUser(userDTO, redisTemplate, tokenType);
}
@ -242,10 +242,10 @@ public class LoginController {
/**
* App登录成功之后的处理
*/
private ResultDTO handleAppAfterLogin(UserMain userMain, String clientId, String userLocale) {
private ResultDTO handleAppAfterLogin(UserMain userMain, String clientId, String userLocale, HttpServletRequest request) {
//保存用户客户端信息,用于消息通知
handleAfterLoginToSavePushUser(userMain.getId(), clientId, userLocale);
return handleAfterLogin(userMain, TokenTypeEnums.APP.getValue());
return handleAfterLogin(userMain, TokenTypeEnums.APP.getValue(), request);
}
/***
@ -269,12 +269,31 @@ public class LoginController {
/**
* 登录成功之后的处理
*/
private ResultDTO handleAfterLogin(UserMain userMain, String tokenType) {
private ResultDTO handleAfterLogin(UserMain userMain, String tokenType, HttpServletRequest request) {
Integer yyyfUserId = null;
String yyyfTtoken = request.getHeader(BaseConstant.YYYF_TOKEN_HEADER);
//如果有token,拿到用户信息,与以渔有方进行绑定
if (redisTemplate.hasKey(yyyfTtoken)) {
YyyfUserDto yyyfUserDto = (YyyfUserDto) redisTemplate.opsForValue().get(yyyfTtoken);
yyyfUserId = yyyfUserDto.getId();
String userId =userMain.getId();
int count = this.yyyfUserService.selectCountByYyyfUserIdAndUserId(yyyfUserId, userId);
if (count == 0) {
this.yyyfUserService.saveUser(yyyfUserId, userId, yyyfUserDto.getName());
this.redisTemplate.delete(yyyfTtoken);
}
}
long timestamp = System.currentTimeMillis();
setUserToRedis(userMain.getId(), userMain.getMobilePhone(), timestamp, tokenType);
setUserToRedis(userMain.getId(), userMain.getMobilePhone(), timestamp, tokenType, yyyfUserId);
String token = generateToken(userMain.getMobilePhone(), timestamp, tokenType);
UserBaseDTO userBaseDTO = userMainService.selectUserInfoById(userMain.getId());
userBaseDTO.setToken(token);
return ResultDTO.requstSuccess(userBaseDTO);
}

@ -0,0 +1,44 @@
package com.blockchain.server.user.entity;
import com.blockchain.common.base.entity.BaseModel;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* YyyfUser 以渔有方与区块链用户关联
* @date 2019-02-21 13:37:18
* @version 1.0
*/
@Table(name = "yyyf_user")
@Data
public class YyyfUser extends BaseModel {
/**
* 以渔有方用户id
*/
@Column(name = "yyyf_user_id")
private Integer yyyfUserId;
/**
* 区块链用户id
*/
@Column(name = "user_id")
private String userId;
/**
* 以渔有方用户姓名
*/
@Column(name = "yyyf_user_name")
private String yyyfUserName;
/**
* 创建时间
*/
@Column(name = "create_time")
private java.util.Date createTime;
}

@ -0,0 +1,16 @@
package com.blockchain.server.user.mapper;
import com.blockchain.server.user.entity.UserInfo;
import com.blockchain.server.user.entity.YyyfUser;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
/**
* AppUUserInfoMapper 数据访问类
* @date 2019-02-21 13:37:18
* @version 1.0
*/
@Repository
public interface YyyfUserMapper extends Mapper<YyyfUser> {
}

@ -0,0 +1,26 @@
package com.blockchain.server.user.service;
/**
* @author huangxl
* @create 2019-02-23 18:21
*/
public interface YyyfUserService {
/**
* 保存用户信息
* @param userId 用户id
* @param email
* @param hasRelation 是否有关系链信息
*/
void saveUser(Integer yyyfUserId,String userId, String yyyfName);
/**
* @description
* @author Mr.Xu
* @date 2020/5/4 13:42
* @param [yyyfUserId, userId]
* @return com.blockchain.server.user.entity.YyyfUser
**/
int selectCountByYyyfUserIdAndUserId(Integer yyyfUserId,String userId);
}

@ -0,0 +1,63 @@
package com.blockchain.server.user.service.impl;
import com.blockchain.common.base.enums.BaseResultEnums;
import com.blockchain.common.base.exception.BaseException;
import com.blockchain.common.base.util.ExceptionPreconditionUtils;
import com.blockchain.server.user.common.constants.other.RedisConstant;
import com.blockchain.server.user.common.constants.other.StringFormatConstant;
import com.blockchain.server.user.common.constants.sql.UserOptConstant;
import com.blockchain.server.user.common.enums.SmsCountEnum;
import com.blockchain.server.user.common.enums.UserEnums;
import com.blockchain.server.user.common.exceprion.UserException;
import com.blockchain.server.user.common.utils.CheckUtils;
import com.blockchain.server.user.common.utils.FileUploadHelper;
import com.blockchain.server.user.common.utils.GoogleAuthenticatorUtils;
import com.blockchain.server.user.entity.UserInfo;
import com.blockchain.server.user.entity.YyyfUser;
import com.blockchain.server.user.mapper.UserInfoMapper;
import com.blockchain.server.user.mapper.YyyfUserMapper;
import com.blockchain.server.user.service.UserOptLogService;
import com.blockchain.server.user.service.YyyfUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.UUID;
/**
* @author huangxl
* @create 2019-02-23 18:23
*/
@Service
public class YyyfUserServiceImpl implements YyyfUserService {
@Autowired
private YyyfUserMapper yyyfUserMapper;
@Transactional
@Override
public void saveUser(Integer yyyfUserId, String userId, String yyyfName) {
YyyfUser yyyfUser=new YyyfUser();
yyyfUser.setYyyfUserId(yyyfUserId);
yyyfUser.setUserId(userId);
yyyfUser.setYyyfUserName(yyyfName);
yyyfUser.setCreateTime(new Date());
this.yyyfUserMapper.insert(yyyfUser);
}
@Override
public int selectCountByYyyfUserIdAndUserId(Integer yyyfUserId, String userId) {
Example example=new Example(YyyfUser.class);
Example.Criteria criteria=example.createCriteria();
criteria.andCondition("yyyf_user_id = " ,yyyfUserId)
.andCondition("user_id = ",userId);
return this.yyyfUserMapper.selectCountByExample(example);
}
}

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.blockchain.server.user.mapper.YyyfUserMapper">
</mapper>

@ -0,0 +1,42 @@
package com.blockchain.server.train.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class ExamPaperDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private String id;
/**
* 指标名称
*/
private String name;
/**
* 任务目标运算符1大于2小于
*/
private Integer taskOperate;
/**
* 任务目标比率
*/
private Double taskRate;
/**
* 任务分数
*/
private Double taskScore;
/**
* 指标代码
*/
private String code;
/**
* 指标id
*/
private String targeId;
}

@ -0,0 +1,39 @@
package com.blockchain.server.train.dto;
import lombok.Data;
import java.io.Serializable;
/**
* Desc: 案例指标 dto
*
* @author qianqian.zhang
* @date 2020-04-21 17:43
**/
@Data
public class TrainCaseTargetDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 指标id
*/
private String id;
/**
* 指标名称
*/
private String name;
/**
* 任务目标运算符1大于2小于
*/
private Integer taskOperate;
/**
* 任务目标比率
*/
private Double taskRate;
/**
* 任务分数
*/
private Double taskScore;
}

@ -5,6 +5,7 @@ import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.common.base.dto.TokenDTO;
import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.common.base.util.RSACoderUtils;
import com.blockchain.server.train.dto.ExamPaperDto;
import com.blockchain.server.yyyf.controller.api.LoginApi;
import com.blockchain.server.yyyf.dto.*;
import com.blockchain.server.yyyf.service.AssessUserService;
@ -51,12 +52,11 @@ public class LoginController {
public ResultDTO<YyyfLoginDto> loginyyyf(@ApiParam(LoginApi.YyyfLogin.METHOD_API_YYYFLOGINREQUESTVO) @Valid YyyfLoginRequestVo yyyfLoginRequestVo) {
//存到redis中用于以渔有方用户与智信链用户进行绑定
YyyfUserDto yyyfUserDto=new YyyfUserDto();
YyyfUserDto yyyfUserDto = new YyyfUserDto();
//登录返回的Data
YyyfLoginDto yyyfLoginDto = new YyyfLoginDto();
yyyfLoginDto.setStatus(0);
String userName =null;
String userName = null;
try {
userName = new String(new BASE64Decoder().decodeBuffer(yyyfLoginRequestVo.getUserName().replaceAll(" ", "+")), "UTF-8");
//根据案例id,考核id封装相关信息。
@ -64,7 +64,7 @@ public class LoginController {
//0 考试 1 练习 2 不计分 3 教师、管理员的案例管理
int reqType = yyyfLoginRequestVo.getReqType().intValue();
int userType = yyyfLoginRequestVo.getUserType().intValue();
Integer classId =yyyfLoginRequestVo.getClassId();
Integer classId = yyyfLoginRequestVo.getClassId();
Integer userId = yyyfLoginRequestVo.getUserId();
Integer schoolId = yyyfLoginRequestVo.getSchoolId();
@ -85,7 +85,7 @@ public class LoginController {
//将参加考试的人员缓存
HashOperations<String, String, List<Integer>> studentOpsForHash = redisTemplate.opsForHash();
//参加考试的人员id
List<Integer> joinStuIds =null;
List<Integer> joinStuIds = null;
//考试id和案列id缓存
String caseKey = YyyfConstant.CASE_KEY + userId;
@ -96,7 +96,7 @@ public class LoginController {
if (this.assessUserService.selectScore(examId, userId) != null) {
yyyfLoginDto.setStatus(2);
yyyfLoginDto.setMsg(YyyfConstant.SUBMITTED);
return handleAfterLogin(yyyfLoginDto,yyyfUserDto);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId);
@ -110,7 +110,7 @@ public class LoginController {
examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto);
}
joinStuIds=studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId);
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId);
if (joinStuIds == null) {
joinStuIds = new ArrayList<Integer>();
}
@ -122,20 +122,20 @@ public class LoginController {
} else {
yyyfLoginDto.setStatus(1);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
return handleAfterLogin(yyyfLoginDto,yyyfUserDto);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
}else {
} else {
if (redisTemplate.hasKey(caseKey)) {
Map<String, String> examMsgMap = (Map<String, String>) redisTemplate.opsForValue().get(caseKey);
joinStuIds=studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examMsgMap.get("examId"));
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examMsgMap.get("examId"));
}
//缓存是考试,要进入练习,则不让进入
if (joinStuIds != null && joinStuIds.stream()
.filter(stuIds -> (stuIds.equals(userId))).count() != 0) {
yyyfLoginDto.setStatus(1);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
return handleAfterLogin(yyyfLoginDto,yyyfUserDto);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
ValueOperations<String, Object> studentAnsweValueOperations = redisTemplate.opsForValue();
@ -143,8 +143,8 @@ public class LoginController {
StudentAnswerDto studentAnswerDto = (StudentAnswerDto) studentAnsweValueOperations.get(studentAnswerDtoKey);
if (studentAnswerDto != null) {
//答题结果、且未提交
Map<String, Integer> result = studentAnswerDto.getResult();
if (result != null && result.size() > 0 && result.get("isSubmit")==null ) {
Map<String, Double> result = studentAnswerDto.getResult();
if (result != null && result.size() > 0 && result.get("isSubmit") == null) {
yyyfLoginDto.setStatus(3);
yyyfLoginDto.setMsg(YyyfConstant.INCOMPLETE_PRACTICE);
PractiseTipDto practiseTipDto = new PractiseTipDto();
@ -161,7 +161,7 @@ public class LoginController {
redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS);
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
return handleAfterLogin(yyyfLoginDto,yyyfUserDto);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
}
}
@ -188,21 +188,14 @@ public class LoginController {
map.put("examPaperId", examPaperId);
map.put("examId", examId);
HashOperations<String, String, ExamPaperDto> examPaperOpsForHash = redisTemplate.opsForHash();
ExamPaperDto examPaperDto = examPaperOpsForHash.get(YyyfConstant.EXAM_PAPER_KEY, examPaperId);
if (examPaperDto == null) {
// examPaperDto = this.projectManageService.getExamPaperDtoById(examPaperId);
examPaperOpsForHash.put(YyyfConstant.EXAM_PAPER_KEY, examPaperId, examPaperDto);
}
redisTemplate.opsForValue().set(caseKey, map);
redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS);
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
}
} catch (IOException e) {
LOG.error(e.getMessage(),e);
LOG.error(e.getMessage(), e);
}
return handleAfterLogin(yyyfLoginDto,yyyfUserDto);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
@ -211,11 +204,12 @@ public class LoginController {
*/
private ResultDTO handleAfterLogin(YyyfLoginDto yyyfLoginDto, YyyfUserDto yyyfUserDto) {
int status = yyyfLoginDto.getStatus();
String token = generateToken(String.valueOf(yyyfUserDto.getId()), System.currentTimeMillis(), YyyfConstant.YYYF_ZHIXINLIAN_USER_KEY);
String token = generateToken(String.valueOf(yyyfUserDto.getId()), System.currentTimeMillis(),
YyyfConstant.YYYF_ZHIXINLIAN_USER_KEY);
yyyfLoginDto.setYyyfUserToken(token);
if(status==1){
if (status != 2) {
//到时看要不要设定时长
redisTemplate.opsForValue().set(token,yyyfUserDto);
redisTemplate.opsForValue().set(token, yyyfUserDto);
}
return ResultDTO.requstSuccess(yyyfLoginDto);
}

@ -0,0 +1,93 @@
package com.blockchain.server.yyyf.controller;
import com.blockchain.common.base.constant.YyyfConstant;
import com.blockchain.common.base.dto.ResultDTO;
import com.blockchain.server.train.dto.ExamPaperDto;
import com.blockchain.server.yyyf.controller.api.StudentAnswerApi;
import com.blockchain.server.yyyf.dto.StudentAnswerDto;
import com.blockchain.server.yyyf.service.AssessUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* @author huangxl
* @data 2019/2/21 15:06
* 用户注册, 登录控制器
*/
@RestController
@Api(StudentAnswerApi.CONTROLLER_API)
@RequestMapping("/loginFromYyyf")
public class StudentAnswerController {
private static final Logger LOG = LoggerFactory.getLogger(StudentAnswerController.class);
@Autowired
private AssessUserService assessUserService;
@Autowired
private RedisTemplate redisTemplate;
@PostMapping("/studentAnswer")
@ApiOperation(value = StudentAnswerApi.StudentAnswer.METHOD_NAME,
notes = StudentAnswerApi.StudentAnswer.METHOD_NOTE)
public ResultDTO studentAnswer(@ApiParam(StudentAnswerApi.StudentAnswer.METHOD_YYYF_USER_ID) @RequestParam(name = "yyyfUserId")String yyyfUserId,
@ApiParam(StudentAnswerApi.StudentAnswer.METHOD_STUDENT_TASK_RATE) @RequestParam(name = "taskRate")String taskRate,
@ApiParam(StudentAnswerApi.StudentAnswer.METHOD_STARGE_ID) @RequestParam(name = "targeId")String targeId) {
String caseKey = YyyfConstant.CASE_KEY + yyyfUserId;
String studentAnswerDtoKey = null;
/* if (redisTemplate.hasKey(caseKey)) {
Map<String,String> map = (Map<String,String>) redisTemplate.opsForValue().get(caseKey);
String caseId=map.get("examPaperId");
studentAnswerDtoKey = YyyfConstant.ANSER_KEY +yyyfUserId + caseId;
ValueOperations<String, Object> studentAnsweValueOperations = redisTemplate.opsForValue();
StudentAnswerDto studentAnswerDto = (StudentAnswerDto) studentAnsweValueOperations.get(studentAnswerDtoKey);
if (studentAnswerDto == null || (studentAnswerDto != null && studentAnswerDto.getTotalScore() != null)) {
return;
}
ExamPaperDto examPaperDto = (ExamPaperDto) redisTemplate.opsForHash().get(YyyfConstant.EXAM_PAPER_KEY, studentAnswerDto.getExamPaperId());
//交易id
String trxId = studentAnswer.value();
Map<String, Double> result = studentAnswerDto.getResult();
if (result == null) {
result = new HashMap<>();
}
AtomicBoolean flag = new AtomicBoolean(false);
examPaperDto.getTradeList().stream().forEach(bd -> {
if (bd.getId().equals(trxId)) {
flag.set(true);
}
});
if (flag.get()) {
result.put(trxId, 1);
studentAnswerDto.setResult(result);
studentAnsweValueOperations.set(studentAnswerDtoKey, studentAnswerDto);
}
redisTemplate.expire(caseKey, 2, TimeUnit.HOURS);
redisTemplate.expire(studentAnswerDtoKey, 2, TimeUnit.HOURS);
}*/
return new ResultDTO();
}
}

@ -0,0 +1,18 @@
package com.blockchain.server.yyyf.controller.api;
/**
* @author huangxl
* @create 2018-11-16 14:51
*/
public class StudentAnswerApi {
public static final String CONTROLLER_API = "案例答题控制器";
public static class StudentAnswer {
public static final String METHOD_NAME = "学生答题";
public static final String METHOD_NOTE = "学生答题统一调用";
public static final String METHOD_YYYF_USER_ID = "以渔有方用户id";
public static final String METHOD_STUDENT_TASK_RATE="学生任务目标比率";
public static final String METHOD_STARGE_ID="指标id";
}
}

@ -1,32 +0,0 @@
package com.blockchain.server.yyyf.dto;
import lombok.Data;
import java.util.List;
@Data
public class ExamPaperDto {
/**
* id
*/
private String id;
/**
* 案例名称
*/
private String name;
/**
* 案例数据
*/
List caseDataList;
/**
* 计分交易数据
*/
List tradeList;
/**
* 案例内容描述
*/
private String content;
}

@ -17,9 +17,9 @@ public class StudentAnswerDto extends ExamDto {
*/
private String userName;
/**
* 答题结果 0答错1答对
* 答题结果,value 是学生的指标
*/
private Map<String, Integer> result;
private Map<String, Double> result;
/**
* 总分

@ -0,0 +1,19 @@
package com.blockchain.server.yyyf.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author Mr.Xu
* @version 1.0
* @className StudentTrainCaseTargetDto
* @description
* @date 2020-05-07 20:30
*/
@Data
public class StudentTrainCaseTargetDto implements Serializable {
private static final long serialVersionUID = -7079847727022972640L;
}

@ -3,8 +3,6 @@ package com.blockchain.server.yyyf.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;

@ -33,8 +33,8 @@
<custom-project-version>latest</custom-project-version>
<!-- 配置信息 -->
<eureka-host>zhixinlian:zhi123xin678lian@10.10.17.84</eureka-host>
<redis-host>10.10.17.84</redis-host>
<eureka-host>zhixinlian:zhi123xin678lian@127.0.0.1</eureka-host>
<redis-host>127.0.0.1</redis-host>
</properties>
<dependencies>

Loading…
Cancel
Save