实现重新开始练习、倒计时等数据绑定

pull/1/head
unclekh 5 years ago
parent 2e4670a975
commit 4060be631a
  1. 5
      blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/constant/YyyfConstant.java
  2. 7
      blockchain-server/blockchain-server-user/src/main/java/com/blockchain/server/user/controller/LoginController.java
  3. 43
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/ExamController.java
  4. 20
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java
  5. 5
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/api/ExamApi.java
  6. 18
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/UserTimeMoneyDto.java
  7. 4
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginDto.java
  8. 2
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/YyyfMoney.java
  9. 9
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java
  10. 9
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java
  11. 9
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTargetService.java
  12. 18
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java
  13. 12
      blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTargetServiceImpl.java
  14. 13
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml
  15. 2
      blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTargetMapper.xml

@ -32,5 +32,10 @@ public class YyyfConstant {
/**以渔有方与智信链用户绑定的cookies*/
public static final String YYYF_ZHIXINLIAN_USER_KEY="yyyfZhixinlianUserKey";
/**注册的key*/
public static final String REGISTER_KEY = "user:sms:register:";
/**注册码的时效性*/
public static final int TIME_OUT=10;
}

@ -103,8 +103,6 @@ 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);
//处理区块链用户id
dealBindYyyfAccount(userMain.getId(),request);
return handleAppAfterLogin(userMain, clientId, getUserLocale(request));
}
@ -195,11 +193,14 @@ 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);
//处理区块链用户id
dealBindYyyfAccount(userMain.getId(),request);
return handleAfterLogin(userMain, TokenTypeEnums.PC.getValue());
}

@ -6,6 +6,8 @@ import com.blockchain.common.base.dto.YyyfUserDto;
import com.blockchain.common.base.util.YyyfUserDtoUtils;
import com.blockchain.server.yyyf.controller.api.ExamApi;
import com.blockchain.server.yyyf.dto.AssessUserDto;
import com.blockchain.server.yyyf.dto.UserTimeMoneyDto;
import com.blockchain.server.yyyf.dto.YyyfLoginDto;
import com.blockchain.server.yyyf.entity.AssessUser;
import com.blockchain.server.yyyf.entity.AssessUserTarget;
import com.blockchain.server.yyyf.entity.YyyfMoney;
@ -26,7 +28,9 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.TimeUnit;
/**
@ -102,7 +106,7 @@ public class ExamController {
@GetMapping("/reStart")
@ApiOperation(value = ExamApi.Restart.METHOD_NAME,
notes = ExamApi.Restart.METHOD_NOTE)
public ResultDTO reStart(HttpServletRequest request) {
public ResultDTO<YyyfLoginDto> reStart(HttpServletRequest request) {
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate);
String assessUserId = yyyfUserDto.getAssessUserId();
@ -111,7 +115,21 @@ public class ExamController {
throw new YyyfException(YyyfEnums.FODBID_EXAM_RESTART);
}
Date now=new Date();
System.out.println(now.getTime());
//系统账户初始化
String tel=new SimpleDateFormat("yyMMddHHmm").format(now).concat(String.valueOf(yyyfUserDto.getUserId()));
//第一次进入进行注册
String code=String.format("%06d",new Random().nextInt(1000000));
redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel),code,YyyfConstant.TIME_OUT, TimeUnit.MINUTES);
//本系统密码
String password=String.format("%08d",new Random().nextInt(10000000));
assessUser.setTel(tel);
assessUser.setPassword(password);
assessUser.setStartTime(now);
assessUser.setEndTime(null);
this.assessUserService.update(assessUser);
//区块链原始金额还原
@ -123,11 +141,32 @@ public class ExamController {
yyyfMoney.setBtc(BigDecimal.ZERO);
yyyfMoney.setEth(BigDecimal.ZERO);
yyyfMoney.setUsdt(BigDecimal.ZERO);
yyyfMoney.setEos(BigDecimal.ZERO);
yyyfMoney.setUpdateTime(now);
this.yyyfMoneyService.update(yyyfMoney);
return ResultDTO.requstSuccess();
this.assessUserTargetService.restoreByAssessUserId(assessUserId);
YyyfLoginDto yyyfLoginDto = new YyyfLoginDto();
yyyfLoginDto.setCode(code);
yyyfLoginDto.setTel(tel);
yyyfLoginDto.setPassword(password);
return ResultDTO.requstSuccess(yyyfLoginDto);
}
@SneakyThrows
@GetMapping("/getUserTimeMoneyDto")
@ApiOperation(value = ExamApi.GetUserTimeMoneyDto.METHOD_NAME,
notes = ExamApi.GetUserTimeMoneyDto.METHOD_NOTE)
public ResultDTO<UserTimeMoneyDto> getUserTimeMoneyDto(HttpServletRequest request) {
YyyfUserDto yyyfUserDto = YyyfUserDtoUtils.getYyyfUserDto(request, redisTemplate);
String assessUserId = yyyfUserDto.getAssessUserId();
UserTimeMoneyDto userTimeMoneyDto =this.assessUserService.getUserTimeMoneyDtoByAssessUserId(assessUserId);
return ResultDTO.requstSuccess(userTimeMoneyDto);
}
}

@ -44,11 +44,6 @@ public class LoginController {
private static final Logger LOG = LoggerFactory.getLogger(LoginController.class);
private static final String REGISTER_KEY = "user:sms:register:";
private static final int TIME_OUT=10;
@Autowired
private AssessUserService assessUserService;
@ -108,7 +103,7 @@ public class LoginController {
//第一次进入进行注册
String code=String.format("%06d",new Random().nextInt(1000000));
redisTemplate.opsForValue().set(REGISTER_KEY.concat(tel),code,TIME_OUT, TimeUnit.MINUTES);
redisTemplate.opsForValue().set(YyyfConstant.REGISTER_KEY.concat(tel),code,YyyfConstant.TIME_OUT, TimeUnit.MINUTES);
yyyfLoginDto.setCode(code);
String password=String.format("%08d",new Random().nextInt(10000000));
@ -168,7 +163,7 @@ public class LoginController {
examDto.setExamPaperId(examPaperId);
examDtoOpsForHash.put(YyyfConstant.EXAM_KEY, examId, examDto);
}
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000);
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId);
if (joinStuIds == null) {
joinStuIds = new ArrayList<Integer>();
@ -179,21 +174,24 @@ public class LoginController {
joinStuIds.add(userId);
studentOpsForHash.put(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId, joinStuIds);
} else {
yyyfLoginDto.setStatus(1);
yyyfLoginDto.setStatus(3);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}
} else {
String jioinExamId=null;
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"));
jioinExamId= examMsgMap.get("examId");
joinStuIds = studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY,jioinExamId);
}
//缓存是考试,要进入练习,则不让进入
if (joinStuIds != null && joinStuIds.stream()
.filter(stuIds -> (stuIds.equals(userId))).count() != 0) {
yyyfLoginDto.setStatus(1);
yyyfLoginDto.setStatus(3);
yyyfLoginDto.setMsg(YyyfConstant.NO_ENTRY_INTO_PRACTICE);
ExamDto examDto = examDtoOpsForHash.get(YyyfConstant.EXAM_KEY, examId);
yyyfLoginDto.setRemainingTime((examDto.getEndTime().getTime() - new Date().getTime() )/ 1000);
return handleAfterLogin(yyyfLoginDto, yyyfUserDto);
}

@ -25,4 +25,9 @@ public class ExamApi {
public static final String METHOD_NAME = "重新开始练习";
public static final String METHOD_NOTE = "重新开始练习,若考试则抛出异常 ";
}
public static class GetUserTimeMoneyDto {
public static final String METHOD_NAME = "获取用户目前余额情况";
public static final String METHOD_NOTE = "获取用户目前余额情况";
}
}

@ -1,8 +1,12 @@
package com.blockchain.server.yyyf.dto;
import com.blockchain.server.yyyf.entity.YyyfMoney;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
@ -12,13 +16,21 @@ import java.util.Date;
* @description 包含以渔有方userId本系统userId开始时间以及各个币种余额情况
* @date 2020-06-01 21:23
*/
@ApiModel("用户余额Dto")
@Data
public class UserTimeMoneyDto extends YyyfMoney implements Serializable {
private static final long serialVersionUID = 5093452353347277920L;
/**以渔有方用户id**/
@ApiModelProperty("以渔有方用户id")
private Integer userId;
/**本系统用户id**/
@ApiModelProperty("本系统用户id")
private String qUserId;
/**开始时间**/
@ApiModelProperty("开始时间")
private Date startTime;
@ApiModelProperty("支付宝初始资金")
private BigDecimal aliPayInit;
@ApiModelProperty("微信支付初始资金")
private BigDecimal wxPayInit;
@ApiModelProperty("银行卡初始资金")
private BigDecimal bankCardInit;
}

@ -14,7 +14,7 @@ public class YyyfLoginDto implements Serializable {
@ApiModelProperty("提示信息")
private String msg;
@ApiModelProperty("状态:0,失败,1成功,2 考试提交后重复进入,3 练习未提交提醒")
@ApiModelProperty("状态:0,失败,1成功,2 考试提交后重复进入,3 考试未完成提醒")
private int status;
/*@ApiModelProperty("练习重新开始参数封装")
@ -33,4 +33,6 @@ public class YyyfLoginDto implements Serializable {
@ApiModelProperty("昵称")
private String nickName;
@ApiModelProperty("剩余时间")
private Long remainingTime;
}

@ -33,6 +33,8 @@ public class YyyfMoney implements Serializable {
private BigDecimal btc;
@Column(name = "usdt")
private BigDecimal usdt;
@Column(name = "eos")
private BigDecimal eos;
@Column(name = "eth")
private BigDecimal eth;

@ -41,4 +41,13 @@ public interface AssessUserMapper extends Mapper<AssessUser> {
* @return java.util.List<com.blockchain.server.yyyf.dto.UserTimeMoneyDto>
**/
List<UserTimeMoneyDto> selectUserTimeMoneyDtosForNotEnd();
/**
* @description assessUserId通过assessUserId 获取余额情况
* @author Mr.Xu
* @date 2020-06-02 21:07:23
* @param [assessUserId]
* @return com.blockchain.server.yyyf.dto.UserTimeMoneyDto
**/
UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(@Param("assessUserId") String assessUserId);
}

@ -97,4 +97,13 @@ public interface AssessUserService {
* @return java.util.List<com.blockchain.server.yyyf.dto.UserTimeMoneyDto>
**/
public List<UserTimeMoneyDto> selectUserTimeMoneyDtosForNotEnd();
/**
* @description assessUserId通过assessUserId 获取余额情况
* @author Mr.Xu
* @date 2020-06-02 21:06:35
* @param [assessUserId]
* @return com.blockchain.server.yyyf.dto.UserTimeMoneyDto
**/
UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(String assessUserId);
}

@ -32,4 +32,13 @@ public interface AssessUserTargetService{
List<AssessUserTarget> selectAllStudentAssessUserTargetByIssueId(String issueId);
List<StudentTargetErrorStatisticsDto> getStudentTargetErrorStatisticsDtoListByIssueId(String issueId);
/**
* @description 还原指标表
* @author Mr.Xu
* @date 2020-06-03 00:05:17
* @param [assessUserId]
* @return void
**/
void restoreByAssessUserId(String assessUserId);
}

@ -32,10 +32,7 @@ import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
@ -113,6 +110,7 @@ public class AssessUserServiceImpl implements AssessUserService {
assessUserTarget.setSort(j++);
assessUserTarget.setAnswer(1);
assessUserTarget.setId(IdGenerator.uuid());
assessUserTarget.setStudentRate(0d);
list.add(assessUserTarget);
}
@ -125,6 +123,7 @@ public class AssessUserServiceImpl implements AssessUserService {
yyyfMoney.setBtc(BigDecimal.ZERO);
yyyfMoney.setEth(BigDecimal.ZERO);
yyyfMoney.setUsdt(BigDecimal.ZERO);
yyyfMoney.setEos(BigDecimal.ZERO);
yyyfMoney.setUpdateTime(new Date());
this.assessUserMapper.insert(assessUser);
@ -154,7 +153,8 @@ public class AssessUserServiceImpl implements AssessUserService {
List<AssessUserTarget> assessUserTargetList = this.assessUserTargetMapper.selectByExample(example);
//获取达标参数
Map<String, Float> targetResultMap = indicatorsManager.calculatePageIndicators(assessUserId);
Map<String, Float> targetResultMap =new HashMap<>();// indicatorsManager.calculatePageIndicators(assessUserId);
targetResultMap.put("GrowthRate",20f);
//最终更新的指标库答题结果list
List<AssessUserTarget> updateAssessUserTargetList = new ArrayList<>();
@ -301,6 +301,11 @@ public class AssessUserServiceImpl implements AssessUserService {
return this.assessUserMapper.selectUserTimeMoneyDtosForNotEnd();
}
@Override
public UserTimeMoneyDto getUserTimeMoneyDtoByAssessUserId(String assessUserId) {
return this.assessUserMapper.getUserTimeMoneyDtoByAssessUserId(assessUserId);
}
/**
* @param [assessUserTarget, targetResultMap]
* @return void
@ -314,7 +319,6 @@ public class AssessUserServiceImpl implements AssessUserService {
Double taskRate = 0d;
if (aFloat != null) {
taskRate = Double.valueOf(aFloat);
}
assessUserTarget.setStudentRate(taskRate);
int compareAnswer = taskRate.compareTo(assessUserTarget.getTaskRate());
//最终指标结果一致
@ -323,4 +327,6 @@ public class AssessUserServiceImpl implements AssessUserService {
}
}
}
}

@ -54,4 +54,16 @@ public class AssessUserTargetServiceImpl implements AssessUserTargetService {
return this.assessUserTargetMapper.getStudentTargetErrorStatisticsDtoListByIssueId(issueId);
}
@Override
public void restoreByAssessUserId(String assessUserId) {
Example example=new Example(AssessUserTarget.class);
Example.Criteria criteria = example.createCriteria();
criteria.andCondition(" assess_user_id = " ,assessUserId);
AssessUserTarget assessUserTarget=new AssessUserTarget();
assessUserTarget.setAnswer(1);
assessUserTarget.setStudentRate(0d);
this.assessUserTargetMapper.updateByExampleSelective(assessUserTarget,example);
}
}

@ -45,6 +45,10 @@
<result column="btc" jdbcType="DECIMAL" property="btc" />
<result column="usdt" jdbcType="DECIMAL" property="usdt" />
<result column="eth" jdbcType="DECIMAL" property="eth" />
<result column="eos" jdbcType="DECIMAL" property="eos" />
<result column="alipay_init_money" jdbcType="DECIMAL" property="aliPayInit" />
<result column="wechat_init_money" jdbcType="DECIMAL" property="wxPayInit" />
<result column="bankcard_init_money" jdbcType="DECIMAL" property="bankCardInit" />
</resultMap>
@ -111,8 +115,15 @@
u.id = t.assess_user_id and u.issue_id=#{issueId}
</select>
<select id="selectUserTimeMoneyDtosForNotEnd" resultMap="UserTimeMoneyDtoMap">
SELECT au.id ,m.wx_pay,m.ali_pay,m.bank_card,m.btc,m.eth,m.usdt from yyyf_server_assess_user au,yyyf_money m
SELECT au.id,au.user_id,au.q_user_id,au.start_time,m.wx_pay,m.ali_pay,m.bank_card,m.btc,m.eth,m.usdt,m.eos,au.alipay_init_money,au.wechat_init_money,au.bankcard_init_money
from yyyf_server_assess_user au,yyyf_money m
where au.id=m.assess_user_id and au.end_time is null
</select>
<select id="getUserTimeMoneyDtoByAssessUserId"
resultMap="UserTimeMoneyDtoMap">
SELECT au.id,au.user_id,au.q_user_id,au.alipay_init_money,au.wechat_init_money,au.bankcard_init_money,au.start_time,m.wx_pay,m.ali_pay,m.bank_card,m.btc,m.eth,m.usdt,m.eos
from yyyf_server_assess_user au,yyyf_money m
where au.id=m.assess_user_id and au.id=#{assessUserId}
</select>
</mapper>

@ -32,7 +32,7 @@
<update id="batchUpdateTargetAnswer" parameterType="list">
<foreach collection="list" item="item" separator=";" close=";">
update yyyf_server_assess_user_target
set answer = #{item.answer,jdbcType=INTEGER} where id = #{item.id,jdbcType=VARCHAR}
set answer = #{item.answer,jdbcType=INTEGER},student_rate=#{item.studentRate,jdbcType=DECIMAL} where id = #{item.id,jdbcType=VARCHAR}
</foreach>
</update>

Loading…
Cancel
Save