From 6e858ab9bc36a14e102c53d50bbe71aabe9546f1 Mon Sep 17 00:00:00 2001 From: Himit_ZH <372347736@qq.com> Date: Tue, 28 Dec 2021 16:29:20 +0800 Subject: [PATCH] fix seal contest rank --- .../top/hcode/hoj/controller/oj/ContestController.java | 6 +++--- .../top/hcode/hoj/controller/oj/JudgeController.java | 9 ++------- .../top/hcode/hoj/controller/oj/ProblemController.java | 3 +-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ContestController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ContestController.java index ec314590..dfecac8e 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ContestController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ContestController.java @@ -262,7 +262,7 @@ public class ContestController { List contestProblemList; boolean isAdmin = isRoot || contest.getAuthor().equals(userRolesVo.getUsername()); // 如果比赛开启封榜 - if (contestService.isSealRank(userRolesVo.getUid(), contest, false, isRoot)) { + if (contestService.isSealRank(userRolesVo.getUid(), contest, true, isRoot)) { contestProblemList = contestProblemService.getContestProblemList(cid, contest.getStartTime(), contest.getEndTime(), contest.getSealRankTime(), isAdmin, contest.getAuthor()); } else { @@ -356,7 +356,7 @@ public class ContestController { Date sealRankTime = null; //封榜时间除超级管理员和比赛管理员外 其它人不可看到最新数据 - if (contestService.isSealRank(userRolesVo.getUid(), contest, false, isRoot)) { + if (contestService.isSealRank(userRolesVo.getUid(), contest, true, isRoot)) { sealRankTime = contest.getSealRankTime(); } @@ -435,7 +435,7 @@ public class ContestController { Date sealRankTime = null; // 需要判断是否需要封榜 - if (contestService.isSealRank(userRolesVo.getUid(), contest, false, isRoot)) { + if (contestService.isSealRank(userRolesVo.getUid(), contest, true, isRoot)) { sealRankTime = contest.getSealRankTime(); } // OI比赛封榜期间不更新,ACM比赛封榜期间可看到自己的提交,但是其它人的不可见 diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/JudgeController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/JudgeController.java index 4fe3f491..e9887ac2 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/JudgeController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/JudgeController.java @@ -289,7 +289,7 @@ public class JudgeController { if (!isRoot && !userRolesVo.getUid().equals(contest.getUid())) { // 如果是比赛,那么还需要判断是否为封榜,比赛管理员和超级管理员可以有权限查看(ACM题目除外) if (contest.getType().intValue() == Constants.Contest.TYPE_OI.getCode() - && contestService.isSealRank(userRolesVo.getUid(), contest, false, false)) { + && contestService.isSealRank(userRolesVo.getUid(), contest, true, false)) { result.put("submission", new Judge().setStatus(Constants.Judge.STATUS_SUBMITTED_UNKNOWN_RESULT.getStatus())); return CommonResult.successResponse(result, "获取提交数据成功!"); } @@ -479,15 +479,10 @@ public class JudgeController { Contest contest = contestService.getById(submitIdListDto.getCid()); - boolean isSealRank = false; boolean isContestAdmin = isRoot || userRolesVo.getUid().equals(contest.getUid()); // 如果是封榜时间且不是比赛管理员和超级管理员 - if (contest.getStatus().intValue() == Constants.Contest.STATUS_RUNNING.getCode() && - contest.getSealRank() && contest.getSealRankTime().before(new Date()) && - !isContestAdmin) { - isSealRank = true; - } + boolean isSealRank = contestService.isSealRank(userRolesVo.getUid(), contest, true, isRoot); QueryWrapper queryWrapper = new QueryWrapper<>(); // lambada表达式过滤掉code diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ProblemController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ProblemController.java index c4db956f..21e1c2cb 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ProblemController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/ProblemController.java @@ -166,11 +166,10 @@ public class ProblemController { HashMap temp = new HashMap<>(); if (pidListDto.getIsContestProblemList()) { if (!isACMContest) { - if (!result.containsKey(judge.getPid())) { // IO比赛的,如果还未写入,则使用最新一次提交的结果 // 判断该提交是否为封榜之后的提交,OI赛制封榜后的提交看不到提交结果, // 只有比赛结束可以看到,比赛管理员与超级管理员的提交除外 - if (contestService.isSealRank(userRolesVo.getUid(), contest, false, + if (contestService.isSealRank(userRolesVo.getUid(), contest, true, SecurityUtils.getSubject().hasRole("root"))) { temp.put("status", Constants.Judge.STATUS_SUBMITTED_UNKNOWN_RESULT.getStatus()); temp.put("score", null);