app安全教育完成
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
package com.ruoyi.wgz.bo.req;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.ruoyi.common.domain.Annex;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -10,7 +9,6 @@ import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ -18,7 +16,7 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("务工者APP-实名认证对象")
|
||||
public class WgzRealNameAuthenticationReq implements Serializable {
|
||||
public class WgzAppRealNameAuthenticationReq implements Serializable {
|
||||
@ApiModelProperty("唯一标识")
|
||||
@NotNull(message = "唯一标识不能为空")
|
||||
private Long userId;
|
@ -0,0 +1,26 @@
|
||||
package com.ruoyi.wgz.bo.req;
|
||||
|
||||
import com.ruoyi.wgz.bo.rests.WgzAppSubmitATestPaperTwo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("务工者APP-提交考试信息请求对象")
|
||||
public class WgzAppSubmitATestPaperReq implements Serializable {
|
||||
@ApiModelProperty("务工者唯一标识")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("用时时间(时间戳/秒)")
|
||||
private Long takeTime;
|
||||
|
||||
@ApiModelProperty("list")
|
||||
private List<WgzAppSubmitATestPaperTwo> list;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.ruoyi.wgz.bo.res;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("务工者APP-提交考试信息返回对象")
|
||||
public class WgzAppSubmitATestPaperRes implements Serializable {
|
||||
@ApiModelProperty("总考试时间(分钟)")
|
||||
private Integer answerTime;
|
||||
|
||||
@ApiModelProperty("用时时间(时间戳/秒)")
|
||||
private Long takeTime;
|
||||
|
||||
@ApiModelProperty("满分")
|
||||
private Double fullMark;
|
||||
|
||||
@ApiModelProperty("及格分")
|
||||
private Double passingScore;
|
||||
|
||||
@ApiModelProperty("当前分")
|
||||
private Double score;
|
||||
|
||||
@ApiModelProperty("答对题数")
|
||||
private Integer number;
|
||||
|
||||
@ApiModelProperty("试卷")
|
||||
private String pdfStr;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.ruoyi.wgz.bo.rests;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class WgzAppSubmitATestPaperTwo implements Serializable {
|
||||
@ApiModelProperty("题库ID")
|
||||
private long bankId;
|
||||
|
||||
@ApiModelProperty("答案")
|
||||
private String answer;
|
||||
|
||||
@ApiModelProperty("当前题分数")
|
||||
private double score;
|
||||
}
|
@ -59,7 +59,7 @@ public class WgzQuestionSave implements Serializable {
|
||||
/** 得分(当前题) */
|
||||
@Excel(name = "得分" , readConverterExp = "当=前题")
|
||||
@ApiModelProperty("得分(当前题)")
|
||||
private Long score;
|
||||
private Double score;
|
||||
|
||||
/** 签名路径 */
|
||||
@Excel(name = "签名路径")
|
||||
@ -74,7 +74,7 @@ public class WgzQuestionSave implements Serializable {
|
||||
/** 最大超时时间(单位/分钟) */
|
||||
@Excel(name = "最大超时时间" , readConverterExp = "单=位/分钟")
|
||||
@ApiModelProperty("最大超时时间(单位/分钟)")
|
||||
private Long timeOut;
|
||||
private Integer timeOut;
|
||||
|
||||
/** 及格线/总分(格式:60,100) */
|
||||
@Excel(name = "及格线/总分" , readConverterExp = "格=式:60,100")
|
||||
@ -84,7 +84,7 @@ public class WgzQuestionSave implements Serializable {
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
@Excel(name = "删除标志" , readConverterExp = "0=代表存在,2=代表删除")
|
||||
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||
@TableLogic
|
||||
// @TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/** 创建者 */
|
||||
|
@ -69,12 +69,12 @@ public class WgzQuestionsConfiguration implements Serializable {
|
||||
/** 满分 */
|
||||
@Excel(name = "满分")
|
||||
@ApiModelProperty("满分")
|
||||
private Long fullMark;
|
||||
private Double fullMark;
|
||||
|
||||
/** 及格线 */
|
||||
@Excel(name = "及格线")
|
||||
@ApiModelProperty("及格线")
|
||||
private Long passingScore;
|
||||
private Double passingScore;
|
||||
|
||||
/** 答题最大时间(单位/分钟) */
|
||||
@Excel(name = "答题最大时间" , readConverterExp = "单=位/分钟")
|
||||
|
@ -4,6 +4,10 @@ import com.ruoyi.wgz.domain.WgzQuestionSave;
|
||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
||||
import com.ruoyi.common.core.mybatisplus.cache.MybatisPlusRedisCache;
|
||||
import org.apache.ibatis.annotations.CacheNamespace;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户试卷存储Mapper接口
|
||||
@ -15,4 +19,11 @@ import org.apache.ibatis.annotations.CacheNamespace;
|
||||
@CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class)
|
||||
public interface WgzQuestionSaveMapper extends BaseMapperPlus<WgzQuestionSave> {
|
||||
|
||||
@Select("SELECT SUM(score) AS sumScore, " +
|
||||
"(SELECT pass FROM bus_question_save WHERE user_id = #{userId} AND del_flag = '0' ORDER BY id ASC LIMIT 1) AS pass, " +
|
||||
"(SELECT sign FROM bus_question_save WHERE user_id = #{userId} AND del_flag = '0' ORDER BY id ASC LIMIT 1) AS sign " +
|
||||
"FROM wgz_question_save " +
|
||||
"WHERE correct = 1 AND user_id = #{userId}")
|
||||
Map<String, Object> getSumScoreAndPassAndSign(@Param("userId") Long userId);
|
||||
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ public interface IWgzQuestionBankService extends IServicePlus<WgzQuestionBank> {
|
||||
* =================================================================================================================
|
||||
* =================================================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* 随机获取指定个数类型的题
|
||||
* @param type 类型
|
||||
@ -70,4 +71,9 @@ public interface IWgzQuestionBankService extends IServicePlus<WgzQuestionBank> {
|
||||
* @param num 数量
|
||||
*/
|
||||
List<WgzAppGetTestPaperThree> appQueryList(int type, int num);
|
||||
|
||||
/**
|
||||
* 根据id查询得到具体题库的信息
|
||||
*/
|
||||
WgzQuestionBank selectById(Long id);
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.ruoyi.wgz.service;
|
||||
|
||||
import com.ruoyi.wgz.bo.req.WgzAppSubmitATestPaperReq;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppSubmitATestPaperRes;
|
||||
import com.ruoyi.wgz.domain.WgzQuestionSave;
|
||||
import com.ruoyi.wgz.bo.WgzQuestionSaveQueryBo;
|
||||
import com.ruoyi.common.core.mybatisplus.core.IServicePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -52,4 +56,16 @@ public interface IWgzQuestionSaveService extends IServicePlus<WgzQuestionSave> {
|
||||
* @return
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* APP相关
|
||||
* =================================================================================================================
|
||||
* =================================================================================================================
|
||||
* =================================================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* 安全教育试卷提交保存
|
||||
*/
|
||||
WgzAppSubmitATestPaperRes userSubmitATestPaper(@Validated @RequestBody WgzAppSubmitATestPaperReq req);
|
||||
}
|
||||
|
@ -64,5 +64,5 @@ public interface IWgzQuestionsConfigurationService extends IServicePlus<WgzQuest
|
||||
/**
|
||||
* 根据id查询到具体信息
|
||||
*/
|
||||
WgzQuestionsConfiguration appQueryById(Long id);
|
||||
WgzQuestionsConfiguration appQueryLimitOne();
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import com.ruoyi.wgz.bo.WgzUserQueryBo;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppModifyingUserProfilePictureReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppPersonalBasicInformationReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppUserRegisterReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzRealNameAuthenticationReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppRealNameAuthenticationReq;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppPersonalBasicInformationRes;
|
||||
import com.ruoyi.wgz.domain.WgzUser;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -91,5 +91,5 @@ public interface IWgzUserService extends IServicePlus<WgzUser> {
|
||||
/**
|
||||
* 务工者APP实名认证
|
||||
*/
|
||||
Boolean userRealNameAuthentication(@Validated @RequestBody WgzRealNameAuthenticationReq req);
|
||||
Boolean userRealNameAuthentication(@Validated @RequestBody WgzAppRealNameAuthenticationReq req);
|
||||
}
|
||||
|
@ -100,4 +100,9 @@ public class WgzQuestionBankServiceImpl extends ServicePlusImpl<WgzQuestionBankM
|
||||
BeanUtils.copyProperties(wgzQuestionBanks, wgzAppGetTestPaperThrees);
|
||||
return wgzAppGetTestPaperThrees;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WgzQuestionBank selectById(Long id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
package com.ruoyi.wgz.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.core.page.PagePlus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppSubmitATestPaperReq;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppSubmitATestPaperRes;
|
||||
import com.ruoyi.wgz.domain.WgzQuestionBank;
|
||||
import com.ruoyi.wgz.domain.WgzQuestionsConfiguration;
|
||||
import com.ruoyi.wgz.service.IWgzQuestionBankService;
|
||||
import com.ruoyi.wgz.service.IWgzQuestionsConfigurationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -14,10 +19,12 @@ import com.ruoyi.wgz.bo.WgzQuestionSaveQueryBo;
|
||||
import com.ruoyi.wgz.domain.WgzQuestionSave;
|
||||
import com.ruoyi.wgz.mapper.WgzQuestionSaveMapper;
|
||||
import com.ruoyi.wgz.service.IWgzQuestionSaveService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* 用户试卷存储Service业务层处理
|
||||
@ -28,6 +35,12 @@ import java.util.Collection;
|
||||
@Service
|
||||
public class WgzQuestionSaveServiceImpl extends ServicePlusImpl<WgzQuestionSaveMapper, WgzQuestionSave> implements IWgzQuestionSaveService {
|
||||
|
||||
@Autowired
|
||||
private IWgzQuestionsConfigurationService iWgzQuestionsConfigurationService;
|
||||
|
||||
@Autowired
|
||||
private IWgzQuestionBankService iWgzQuestionBankService;
|
||||
|
||||
@Override
|
||||
public WgzQuestionSave queryById(Long id){
|
||||
return getById(id);
|
||||
@ -81,4 +94,94 @@ public class WgzQuestionSaveServiceImpl extends ServicePlusImpl<WgzQuestionSaveM
|
||||
}
|
||||
return removeByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* APP相关
|
||||
* =================================================================================================================
|
||||
* =================================================================================================================
|
||||
* =================================================================================================================
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public WgzAppSubmitATestPaperRes userSubmitATestPaper(WgzAppSubmitATestPaperReq req) {
|
||||
// 初始化第一次分数和当前考试的分数
|
||||
double scoreOne = 0.00;
|
||||
double scoreTwo = 0.00;
|
||||
//1、获取上次考试的分数
|
||||
Map<String, Object> spMap = baseMapper.getSumScoreAndPassAndSign(req.getUserId());
|
||||
if (spMap != null) {
|
||||
String pass = (String) spMap.get("pass");
|
||||
if (pass != null && !pass.isEmpty()) {
|
||||
String[] split = pass.split(",");
|
||||
double float1 = Double.parseDouble(split[1]);
|
||||
double sumScore = (double) spMap.get("sumScore");
|
||||
scoreOne = 100.00 / float1 * sumScore;
|
||||
}
|
||||
}
|
||||
//2、获取配置信息
|
||||
WgzQuestionsConfiguration configuration = iWgzQuestionsConfigurationService.appQueryLimitOne();
|
||||
//3、计算这次用户提交的试卷信息所得到的分数
|
||||
List<WgzQuestionSave> bqs = new ArrayList<>();
|
||||
AtomicReference<Double> fenshu = new AtomicReference<>(0.0);
|
||||
AtomicInteger number = new AtomicInteger(0);
|
||||
AtomicInteger index = new AtomicInteger(0);
|
||||
req.getList().forEach(data -> {
|
||||
String correct = "";
|
||||
String pass = "";
|
||||
// 获取题库的正确答案,然后和用户的答案作对比
|
||||
WgzQuestionBank bqb = iWgzQuestionBankService.selectById(data.getBankId());
|
||||
if (bqb == null) {
|
||||
throw new RuntimeException("您的试卷被外星人卷走了!");
|
||||
} else {
|
||||
if (StringUtils.isEmpty(data.getAnswer())) {
|
||||
throw new RuntimeException("您还有题未答完!");
|
||||
}
|
||||
if (bqb.getCorrectAnswer().toLowerCase().contains(data.getAnswer().toLowerCase())) {
|
||||
correct = "1";
|
||||
fenshu.updateAndGet(v -> v + data.getScore());
|
||||
number.incrementAndGet();
|
||||
} else {
|
||||
correct = "2";
|
||||
}
|
||||
}
|
||||
// 记录这次的及格线和总分
|
||||
pass = configuration.getPassingScore().toString() + "," + configuration.getFullMark().toString();
|
||||
WgzQuestionSave bqsTwo = new WgzQuestionSave();
|
||||
bqsTwo.setUserId(req.getUserId());
|
||||
bqsTwo.setBankId(data.getBankId());
|
||||
bqsTwo.setAnswer(data.getAnswer());
|
||||
bqsTwo.setCorrect(correct);
|
||||
bqsTwo.setScore(data.getScore());
|
||||
//这几条数据只在每张试卷的第一条数据中存储(重复的没必要每条都存储)
|
||||
if (index.get() == 0) {
|
||||
bqsTwo.setTakeTime(req.getTakeTime());
|
||||
bqsTwo.setTimeOut(configuration.getAnswerTime());
|
||||
bqsTwo.setPass(pass);
|
||||
}
|
||||
bqs.add(bqsTwo);
|
||||
index.incrementAndGet();
|
||||
});
|
||||
Double fullMark = configuration.getFullMark();
|
||||
scoreTwo = 100.00 / fullMark * fenshu.get();
|
||||
WgzAppSubmitATestPaperRes res = new WgzAppSubmitATestPaperRes();
|
||||
res.setAnswerTime(configuration.getAnswerTime());
|
||||
res.setTakeTime(req.getTakeTime());
|
||||
res.setFullMark(fullMark);
|
||||
res.setPassingScore(configuration.getPassingScore());
|
||||
res.setScore(fenshu.get());
|
||||
res.setNumber(number.get());
|
||||
//4、两次卷子的分数对比,第一次的分数比第二次大那么第二次只返回结果;第二次的分数比第一次大那么删除第一次的数据再重新插入
|
||||
if (scoreOne > scoreTwo) {
|
||||
return res;
|
||||
} else {
|
||||
// 先查询当前用户是否有答题,有就把之前的删除(真删)
|
||||
int deleteResult = baseMapper.delete(new LambdaQueryWrapper<WgzQuestionSave>().eq(WgzQuestionSave::getUserId, req.getUserId()));
|
||||
if (deleteResult >0){
|
||||
// 插入新数据
|
||||
super.saveBatch(bqs);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.ruoyi.wgz.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.utils.PageUtils;
|
||||
import com.ruoyi.common.core.page.PagePlus;
|
||||
@ -89,7 +90,13 @@ public class WgzQuestionsConfigurationServiceImpl extends ServicePlusImpl<WgzQue
|
||||
*/
|
||||
|
||||
@Override
|
||||
public WgzQuestionsConfiguration appQueryById(Long id) {
|
||||
return baseMapper.selectById(id);
|
||||
public WgzQuestionsConfiguration appQueryLimitOne() {
|
||||
QueryWrapper<WgzQuestionsConfiguration> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.last("LIMIT 1");
|
||||
WgzQuestionsConfiguration wgzQuestionsConfiguration = baseMapper.selectOne(queryWrapper);
|
||||
if(wgzQuestionsConfiguration==null){
|
||||
throw new RuntimeException("题库配置为空");
|
||||
}
|
||||
return wgzQuestionsConfiguration;
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import com.ruoyi.wgz.bo.WgzUserQueryBo;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppModifyingUserProfilePictureReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppPersonalBasicInformationReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppUserRegisterReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzRealNameAuthenticationReq;
|
||||
import com.ruoyi.wgz.bo.req.WgzAppRealNameAuthenticationReq;
|
||||
import com.ruoyi.wgz.bo.res.WgzAppPersonalBasicInformationRes;
|
||||
import com.ruoyi.wgz.common.SnowflakeIdUtil;
|
||||
import com.ruoyi.wgz.domain.WgzUser;
|
||||
@ -168,7 +168,7 @@ public class WgzUserServiceImpl extends ServicePlusImpl<WgzUserMapper, WgzUser>
|
||||
//实名认证
|
||||
@Override
|
||||
@Transactional()
|
||||
public Boolean userRealNameAuthentication(WgzRealNameAuthenticationReq req) {
|
||||
public Boolean userRealNameAuthentication(WgzAppRealNameAuthenticationReq req) {
|
||||
//1、对指定用户进行实名认证
|
||||
WgzUser user = new WgzUser();
|
||||
BeanUtils.copyProperties(req, user);
|
||||
|
Reference in New Issue
Block a user