6156ffce sonin

考试 优化

1 个父辈 8a8794c0
package com.skua.modules.edu.controller;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.common.constant.BusinessConstant;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.util.DateUtils;
import com.skua.modules.base.service.IBaseService;
import com.skua.modules.biz.IBusinessService;
import com.skua.modules.edu.entity.*;
import com.skua.modules.edu.service.IPaperService;
import com.skua.modules.edu.service.IUserPaperService;
......@@ -30,6 +35,11 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Api(tags="在线考试-用户考试")
......@@ -41,6 +51,10 @@ public class UserPaperController {
@Autowired
private IUserPaperService userPaperService;
@Autowired
private IBaseService baseService;
@Autowired
private IBusinessService businessService;
// 我的 考试
@AutoLog(value = "在线考试--试卷列表")
......@@ -58,10 +72,11 @@ public class UserPaperController {
queryWrapper.le("start_time",currentDate);// 当前时间 > 开始结束时间
queryWrapper.ge("end_time",currentDate);
IPage<Paper> pageList = paperService.page(page, queryWrapper);*/
paper.setUserId(BaseContextHandler.getUserId());
String userId = BaseContextHandler.getUserId();
// paper.setUserId(userId);
paper.setStartTime(DateUtils.now());
paper.setEndTime( DateUtils.now() );
paper.setExamStatus(0);//考试状态是未考试的
// paper.setExamStatus(0);//考试状态是未考试的
IPage<Paper> pageList = paperService.queryMyPaperByList(page ,paper);
result.setSuccess(true);
result.setResult(pageList);
......@@ -148,12 +163,11 @@ public class UserPaperController {
@AutoLog(value = "在线考试--历史试卷列表")
@ApiOperation(value="在线考试--历史试卷列表", notes="在线考试--历史试卷列表")
@GetMapping(value = "/historyList")
public Result<IPage<Paper>> historyList(
public Result<Object> historyList(
Paper paper,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) throws Exception {
Result<IPage<Paper>> result = new Result<IPage<Paper>>();
/* StringBuffer sql = new StringBuffer();
sql.append("select up.score, p.* from edu_user_paper up ");
sql.append(" left join edu_paper p on p.id = up.paper_id ");
......@@ -164,16 +178,34 @@ public class UserPaperController {
Page<Map<String, Object>> pageList = iCommonSqlService.queryForPage(page, sql.toString());
List<Paper> paperList = JoinSqlUtils.multiMaps2Beans(pageList.getRecords(), Paper.class);
*/
Page<Paper> page = new Page<Paper>(pageNo, pageSize);
if(StringUtils.isEmpty(paper.getUserId())){
paper.setUserId(BaseContextHandler.getUserId());//获取当前用户编号
}
IPage<Paper> paperList = paperService.queryMyPaperRecoredByList(page,paper);
result.setResult(paperList);
result.setSuccess(true);
return result;
String departIds = BaseContextHandler.getDeparts();
QueryWrapper<?> queryWrapper0 = new QueryWrapper<>();
queryWrapper0.eq(StringUtils.isNotEmpty(paper.getUserId()),"edu_user_paper.user_id", paper.getUserId())
.like(StringUtils.isNotEmpty(paper.getPaperTitle()), "edu_paper.paper_title", paper.getPaperTitle())
.in("edu_user_paper.depart_id", Arrays.asList(departIds.split(",")))
.orderByDesc("edu_user_paper.start_time", "edu_user_paper.score");
List<String> columnList = new ArrayList<String>(){{
add("edu_user_paper.score");
add("edu_user_paper.user_id");
add("edu_user_paper.rank");
add("edu_user_paper.depart_id");
add("edu_user_paper.id as 'user_paper_id'");
add("edu_paper.*");
}};
IPage<Map<String, Object>> mapIPage = baseService.queryForPage(new Page<>(pageNo, pageSize), "select " + String.join(",", columnList) + " from edu_user_paper left join edu_paper on edu_user_paper.paper_id = edu_paper.id", queryWrapper0);
// 翻译
Map<String, String> sysDepartDictMap = businessService.dictMap("sys_depart", null);
Map<String, String> sysUserDictMap = businessService.dictMap("sys_user", null);
// 封装结果集
IPage<Map<String, Object>> paperIPage = new Page<>(pageNo, pageSize);
paperIPage.setTotal(mapIPage.getTotal());
paperIPage.setRecords(mapIPage.getRecords().stream().map(item -> {
Map<String, Object> tmpMap = BeanUtil.beanToMap(BeanUtil.toBean(item, Paper.class));
tmpMap.put("userId" + BusinessConstant.dictText, sysUserDictMap.get(tmpMap.get("userId")));
tmpMap.put("departId" + BusinessConstant.dictText, sysDepartDictMap.get(tmpMap.get("departId")));
return tmpMap;
}).collect(Collectors.toList()));
return Result.ok(paperIPage);
}
//历史试卷详情 history_detail
@AutoLog(value = "在线考试--历史试卷详情(复习)")
......
......@@ -87,6 +87,7 @@ public class MybatisInterceptor implements Interceptor {
add("inspection_point_trigger_config");
//在线考试
add("edu_paper");//用户的试卷
add("edu_user_paper");//用户的试卷
add("edu_question");//试题
add("edu_question_db");//题库
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!