use of top.hcode.hoj.pojo.dto.SubmitIdListDto in project HOJ by HimitZH.
the class JudgeController method checkCommonJudgeResult.
/**
* @MethodName checkJudgeResult
* @Params * @param null
* @Description 对提交列表状态为Pending和Judging的提交进行更新检查
* @Return
* @Since 2021/1/3
*/
@RequestMapping(value = "/check-submissions-status", method = RequestMethod.POST)
public CommonResult checkCommonJudgeResult(@RequestBody SubmitIdListDto submitIdListDto) {
List<Long> submitIds = submitIdListDto.getSubmitIds();
if (CollectionUtils.isEmpty(submitIds)) {
return CommonResult.successResponse(new HashMap<>(), "查询的提交id列表为空!");
}
QueryWrapper<Judge> queryWrapper = new QueryWrapper<>();
// lambada表达式过滤掉code
queryWrapper.select(Judge.class, info -> !info.getColumn().equals("code")).in("submit_id", submitIds);
List<Judge> judgeList = judgeService.list(queryWrapper);
HashMap<Long, Object> result = new HashMap<>();
for (Judge judge : judgeList) {
judge.setCode(null);
judge.setErrorMessage(null);
judge.setVjudgeUsername(null);
judge.setVjudgeSubmitId(null);
judge.setVjudgePassword(null);
result.put(judge.getSubmitId(), judge);
}
return CommonResult.successResponse(result, "获取最新判题数据成功!");
}
use of top.hcode.hoj.pojo.dto.SubmitIdListDto in project HOJ by HimitZH.
the class JudgeController method checkContestJudgeResult.
/**
* @MethodName checkContestJudgeResult
* @Params * @param submitIdListDto
* @Description 需要检查是否为封榜,是否可以查询结果,避免有人恶意查询
* @Return
* @Since 2021/6/11
*/
@RequestMapping(value = "/check-contest-submissions-status", method = RequestMethod.POST)
@RequiresAuthentication
public CommonResult checkContestJudgeResult(@RequestBody SubmitIdListDto submitIdListDto, HttpServletRequest request) {
if (submitIdListDto.getCid() == null) {
return CommonResult.errorResponse("查询比赛ID不能为空");
}
if (CollectionUtils.isEmpty(submitIdListDto.getSubmitIds())) {
return CommonResult.successResponse(new HashMap<>(), "查询的提交id列表为空!");
}
HttpSession session = request.getSession();
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
// 是否为超级管理员
boolean isRoot = SecurityUtils.getSubject().hasRole("root");
Contest contest = contestService.getById(submitIdListDto.getCid());
boolean isContestAdmin = isRoot || userRolesVo.getUid().equals(contest.getUid());
// 如果是封榜时间且不是比赛管理员和超级管理员
boolean isSealRank = contestService.isSealRank(userRolesVo.getUid(), contest, true, isRoot);
QueryWrapper<Judge> queryWrapper = new QueryWrapper<>();
// lambada表达式过滤掉code
queryWrapper.select(Judge.class, info -> !info.getColumn().equals("code")).in("submit_id", submitIdListDto.getSubmitIds()).eq("cid", submitIdListDto.getCid()).between(isSealRank, "submit_time", contest.getStartTime(), contest.getSealRankTime());
List<Judge> judgeList = judgeService.list(queryWrapper);
HashMap<Long, Object> result = new HashMap<>();
for (Judge judge : judgeList) {
judge.setCode(null);
judge.setDisplayPid(null);
judge.setErrorMessage(null);
judge.setVjudgeUsername(null);
judge.setVjudgeSubmitId(null);
judge.setVjudgePassword(null);
if (!judge.getUid().equals(userRolesVo.getUid()) && !isContestAdmin) {
judge.setTime(null);
judge.setMemory(null);
judge.setLength(null);
}
result.put(judge.getSubmitId(), judge);
}
return CommonResult.successResponse(result, "获取最新判题数据成功!");
}
Aggregations