增加后台题目oj筛选,剔除管理员在比赛中的提交记录

This commit is contained in:
Himit_ZH 2021-07-29 22:22:06 +08:00
parent 6d3cc351af
commit 542352e840
13 changed files with 112 additions and 24 deletions

View File

@ -198,7 +198,8 @@ public class AdminContestController {
@RequestParam(value = "currentPage", required = false) Integer currentPage, @RequestParam(value = "currentPage", required = false) Integer currentPage,
@RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "cid", required = false) Long cid, @RequestParam(value = "cid", required = false) Long cid,
@RequestParam(value = "problemType", required = false) Integer problemType) { @RequestParam(value = "problemType", required = false) Integer problemType,
@RequestParam(value = "oj", required = false) String oj) {
if (cid == null) { if (cid == null) {
return CommonResult.errorResponse("参数错误!", CommonResult.STATUS_NOT_FOUND); return CommonResult.errorResponse("参数错误!", CommonResult.STATUS_NOT_FOUND);
} }
@ -227,7 +228,7 @@ public class AdminContestController {
if (problemType != null) { // 必备条件 隐藏的不可取来做比赛题目 if (problemType != null) { // 必备条件 隐藏的不可取来做比赛题目
problemQueryWrapper problemQueryWrapper
// vj题目不限制赛制 // vj题目不限制赛制
.and(wrapper->wrapper.eq("type", problemType) .and(wrapper -> wrapper.eq("type", problemType)
.or().eq("is_remote", true)) .or().eq("is_remote", true))
.ne("auth", 2); .ne("auth", 2);
} }
@ -248,6 +249,15 @@ public class AdminContestController {
.like("author", keyword)); .like("author", keyword));
} }
// 根据oj筛选过滤
if (oj != null && !"All".equals(oj)) {
if (!Constants.RemoteOJ.isRemoteOJ(oj)) {
problemQueryWrapper.eq("is_remote", false);
} else {
problemQueryWrapper.eq("is_remote", true).likeLeft("problem_id", oj);
}
}
IPage<Problem> problemList = problemService.page(iPage, problemQueryWrapper); IPage<Problem> problemList = problemService.page(iPage, problemQueryWrapper);
HashMap<String, Object> contestProblem = new HashMap<>(); HashMap<String, Object> contestProblem = new HashMap<>();
contestProblem.put("problemList", problemList); contestProblem.put("problemList", problemList);

View File

@ -226,10 +226,10 @@ public class ContestController {
if (contest.getSealRank() && contest.getStatus().intValue() == Constants.Contest.STATUS_RUNNING.getCode() && if (contest.getSealRank() && contest.getStatus().intValue() == Constants.Contest.STATUS_RUNNING.getCode() &&
contest.getSealRankTime().before(new Date())) { contest.getSealRankTime().before(new Date())) {
contestProblemList = contestProblemService.getContestProblemList(cid, contest.getStartTime(), contest.getEndTime(), contestProblemList = contestProblemService.getContestProblemList(cid, contest.getStartTime(), contest.getEndTime(),
contest.getSealRankTime(), isAdmin); contest.getSealRankTime(), isAdmin, contest.getAuthor());
} else { } else {
contestProblemList = contestProblemService.getContestProblemList(cid, contest.getStartTime(), contest.getEndTime(), contestProblemList = contestProblemService.getContestProblemList(cid, contest.getStartTime(), contest.getEndTime(),
null, isAdmin); null, isAdmin, contest.getAuthor());
} }
if (contestProblemList.size() == 0) { if (contestProblemList.size() == 0) {
@ -321,9 +321,15 @@ public class ContestController {
contest.getSealRankTime().before(new Date())) { contest.getSealRankTime().before(new Date())) {
sealRankTime = contest.getSealRankTime(); sealRankTime = contest.getSealRankTime();
} }
// 筛去 比赛管理员和超级管理员的提交
List<UserInfo> superAdminList = contestRecordService.getSuperAdminList();
List<String> superAdminUidList = superAdminList.stream().map(UserInfo::getUuid).collect(Collectors.toList());
superAdminUidList.add(contest.getUid());
// 获取题目的提交记录 // 获取题目的提交记录
ProblemCountVo problemCount = judgeService.getContestProblemCount(contestProblem.getPid(), contestProblem.getId(), ProblemCountVo problemCount = judgeService.getContestProblemCount(contestProblem.getPid(), contestProblem.getId(),
contestProblem.getCid(), contest.getStartTime(), sealRankTime); contestProblem.getCid(), contest.getStartTime(), sealRankTime, superAdminUidList);
// 获取题目的代码模板 // 获取题目的代码模板
QueryWrapper<CodeTemplate> codeTemplateQueryWrapper = new QueryWrapper<>(); QueryWrapper<CodeTemplate> codeTemplateQueryWrapper = new QueryWrapper<>();

View File

@ -23,5 +23,5 @@ import java.util.List;
public interface ContestProblemMapper extends BaseMapper<ContestProblem> { public interface ContestProblemMapper extends BaseMapper<ContestProblem> {
List<ContestProblemVo> getContestProblemList(@Param("cid") Long cid, @Param("startTime") Date startTime, List<ContestProblemVo> getContestProblemList(@Param("cid") Long cid, @Param("startTime") Date startTime,
@Param("endTime") Date endTime, @Param("sealTime") Date sealTime, @Param("endTime") Date endTime, @Param("sealTime") Date sealTime,
@Param("isAdmin") Boolean isAdmin); @Param("isAdmin") Boolean isAdmin, @Param("adminList") List<String> adminList);
} }

View File

@ -11,6 +11,7 @@ import top.hcode.hoj.pojo.vo.JudgeVo;
import top.hcode.hoj.pojo.vo.ProblemCountVo; import top.hcode.hoj.pojo.vo.ProblemCountVo;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
@ -35,7 +36,8 @@ public interface JudgeMapper extends BaseMapper<Judge> {
int getTodayJudgeNum(); int getTodayJudgeNum();
ProblemCountVo getContestProblemCount(@Param("pid") Long pid, @Param("cpid") Long cpid, @Param("cid") Long cid, ProblemCountVo getContestProblemCount(@Param("pid") Long pid, @Param("cpid") Long cpid, @Param("cid") Long cid,
@Param("startTime") Date startTime, @Param("sealRankTime") Date sealRankTime); @Param("startTime") Date startTime, @Param("sealRankTime") Date sealRankTime,
@Param("adminList") List<String> adminList);
ProblemCountVo getProblemCount(@Param("pid") Long pid); ProblemCountVo getProblemCount(@Param("pid") Long pid);
} }

View File

@ -6,6 +6,13 @@
(select count(*) from judge (select count(*) from judge
<where> <where>
cpid=cp.id and cid=cp.cid and pid=cp.pid cpid=cp.id and cid=cp.cid and pid=cp.pid
<if test="adminList!=null and adminList.size>0">
and uid NOT IN
<foreach collection="adminList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<choose> <choose>
<when test="isAdmin"> <when test="isAdmin">
AND submit_time >= #{startTime} AND #{endTime}>submit_time AND submit_time >= #{startTime} AND #{endTime}>submit_time
@ -22,6 +29,13 @@
(select count(*) from judge (select count(*) from judge
<where> <where>
cpid=cp.id and cid=cp.cid and pid =cp.pid and status=0 cpid=cp.id and cid=cp.cid and pid =cp.pid and status=0
<if test="adminList!=null and adminList.size>0">
and uid NOT IN
<foreach collection="adminList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
<choose> <choose>
<when test="isAdmin"> <when test="isAdmin">
AND submit_time >= #{startTime} AND #{endTime}>=submit_time AND submit_time >= #{startTime} AND #{endTime}>=submit_time

View File

@ -91,6 +91,13 @@
<if test="sealRankTime!=null"> <if test="sealRankTime!=null">
and #{sealRankTime} > submit_time and #{sealRankTime} > submit_time
</if> </if>
<if test="adminList!=null and adminList.size>0">
and uid NOT IN
<foreach collection="adminList" index="index" item="item"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where> </where>
</select> </select>

View File

@ -16,5 +16,6 @@ import java.util.List;
* @since 2020-10-23 * @since 2020-10-23
*/ */
public interface ContestProblemService extends IService<ContestProblem> { public interface ContestProblemService extends IService<ContestProblem> {
List<ContestProblemVo> getContestProblemList(Long cid, Date startTime, Date endTime, Date sealTime, Boolean isAdmin); List<ContestProblemVo> getContestProblemList(Long cid, Date startTime, Date endTime, Date sealTime,
Boolean isAdmin, String contestAuthorUid);
} }

View File

@ -8,6 +8,7 @@ import top.hcode.hoj.pojo.vo.JudgeVo;
import top.hcode.hoj.pojo.vo.ProblemCountVo; import top.hcode.hoj.pojo.vo.ProblemCountVo;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
@ -29,7 +30,7 @@ public interface JudgeService extends IService<Judge> {
void failToUseRedisPublishJudge(Long submitId, Long pid, Boolean isContest); void failToUseRedisPublishJudge(Long submitId, Long pid, Boolean isContest);
ProblemCountVo getContestProblemCount(Long pid, Long cpid, Long cid, Date startTime, Date sealRankTime); ProblemCountVo getContestProblemCount(Long pid, Long cpid, Long cid, Date startTime, Date sealRankTime, List<String> adminList);
ProblemCountVo getProblemCount(Long pid); ProblemCountVo getProblemCount(Long pid);
} }

View File

@ -3,6 +3,7 @@ package top.hcode.hoj.service.impl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import top.hcode.hoj.pojo.entity.ContestProblem; import top.hcode.hoj.pojo.entity.ContestProblem;
import top.hcode.hoj.dao.ContestProblemMapper; import top.hcode.hoj.dao.ContestProblemMapper;
import top.hcode.hoj.pojo.entity.UserInfo;
import top.hcode.hoj.pojo.vo.ContestProblemVo; import top.hcode.hoj.pojo.vo.ContestProblemVo;
import top.hcode.hoj.service.ContestProblemService; import top.hcode.hoj.service.ContestProblemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -25,8 +27,16 @@ public class ContestProblemServiceImpl extends ServiceImpl<ContestProblemMapper,
@Autowired @Autowired
private ContestProblemMapper contestProblemMapper; private ContestProblemMapper contestProblemMapper;
@Autowired
private ContestRecordServiceImpl contestRecordService;
@Override @Override
public List<ContestProblemVo> getContestProblemList(Long cid, Date startTime, Date endTime, Date sealTime,Boolean isAdmin) { public List<ContestProblemVo> getContestProblemList(Long cid, Date startTime, Date endTime, Date sealTime, Boolean isAdmin, String contestAuthorUid) {
return contestProblemMapper.getContestProblemList(cid, startTime,endTime,sealTime,isAdmin); // 筛去 比赛管理员和超级管理员的提交
List<UserInfo> superAdminList = contestRecordService.getSuperAdminList();
List<String> superAdminUidList = superAdminList.stream().map(UserInfo::getUuid).collect(Collectors.toList());
superAdminUidList.add(contestAuthorUid);
return contestProblemMapper.getContestProblemList(cid, startTime, endTime, sealTime, isAdmin, superAdminUidList);
} }
} }

View File

@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
import top.hcode.hoj.utils.Constants; import top.hcode.hoj.utils.Constants;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
@ -71,8 +72,8 @@ public class JudgeServiceImpl extends ServiceImpl<JudgeMapper, Judge> implements
} }
@Override @Override
public ProblemCountVo getContestProblemCount(Long pid, Long cpid, Long cid, Date startTime, Date sealRankTime) { public ProblemCountVo getContestProblemCount(Long pid, Long cpid, Long cid, Date startTime, Date sealRankTime, List<String> adminList) {
return judgeMapper.getContestProblemCount(pid, cpid, cid, startTime, sealRankTime); return judgeMapper.getContestProblemCount(pid, cpid, cid, startTime, sealRankTime, adminList);
} }
@Override @Override

View File

@ -43,10 +43,32 @@
@keyup.enter.native="filterByKeyword" @keyup.enter.native="filterByKeyword"
></vxe-input> ></vxe-input>
</span> </span>
<span>
<el-select
v-model="oj"
@change="ProblemListChangeFilter"
size="small"
style="width: 180px;"
>
<el-option
:label="$t('m.All_Problem')"
:value="'All'"
></el-option>
<el-option :label="$t('m.My_OJ')" :value="'Mine'"></el-option>
<el-option
:label="remoteOj.name"
:key="index"
:value="remoteOj.key"
v-for="(remoteOj, index) in REMOTE_OJ"
></el-option>
</el-select>
</span>
<span v-if="!contestId"> <span v-if="!contestId">
<el-select <el-select
v-model="problemListAuth" v-model="problemListAuth"
@change="ProblemListChangeAuth" @change="ProblemListChangeFilter"
size="small" size="small"
style="width: 180px;" style="width: 180px;"
> >
@ -315,6 +337,7 @@ export default {
data() { data() {
return { return {
problemListAuth: 0, problemListAuth: 0,
oj: 'Mine',
pageSize: 10, pageSize: 10,
total: 0, total: 0,
problemList: [], problemList: [],
@ -392,6 +415,7 @@ export default {
currentPage: page, currentPage: page,
keyword: this.keyword, keyword: this.keyword,
cid: this.contestId, cid: this.contestId,
oj: this.oj,
}; };
if (this.problemListAuth != 0) { if (this.problemListAuth != 0) {
params['auth'] = this.problemListAuth; params['auth'] = this.problemListAuth;
@ -485,7 +509,7 @@ export default {
this.$alert(this.$i18n.t('m.Download_Testcase_Success'), 'Tips'); this.$alert(this.$i18n.t('m.Download_Testcase_Success'), 'Tips');
}); });
}, },
ProblemListChangeAuth() { ProblemListChangeFilter() {
this.currentChange(1); this.currentChange(1);
}, },
filterByKeyword() { filterByKeyword() {

View File

@ -294,11 +294,6 @@ export default {
table: true, table: true,
tag: true, tag: true,
}, },
page: {
currentPage: 1,
pageSize: 30,
totalResult: 300,
},
filterConfig: { remote: true }, filterConfig: { remote: true },
routeName: '', routeName: '',
query: { query: {
@ -310,6 +305,9 @@ export default {
}, },
}; };
}, },
created() {
this.init();
},
mounted() { mounted() {
this.PROBLEM_LEVEL = Object.assign({}, PROBLEM_LEVEL); this.PROBLEM_LEVEL = Object.assign({}, PROBLEM_LEVEL);
@ -336,7 +334,7 @@ export default {
this.$refs.problemList.refreshColumn(); this.$refs.problemList.refreshColumn();
this.loadings.table = false; this.loadings.table = false;
}, 200); }, 200);
this.init(); this.getData();
}, },
methods: { methods: {
init() { init() {
@ -350,10 +348,13 @@ export default {
if (this.query.currentPage < 1) { if (this.query.currentPage < 1) {
this.query.currentPage = 1; this.query.currentPage = 1;
} }
this.getTagList(this.query.oj); },
getData() {
this.getTagList(this.query.oj);
this.getProblemList(); this.getProblemList();
}, },
pushRouter() { pushRouter() {
this.$router.push({ this.$router.push({
path: '/problem', path: '/problem',
@ -549,11 +550,13 @@ export default {
$route(newVal, oldVal) { $route(newVal, oldVal) {
if (newVal !== oldVal) { if (newVal !== oldVal) {
this.init(); this.init();
this.getData();
} }
}, },
isAuthenticated(newVal) { isAuthenticated(newVal) {
if (newVal === true) { if (newVal === true) {
this.init(); this.init();
this.getData();
} }
}, },
}, },

View File

@ -349,6 +349,9 @@ export default {
RULE_TYPE: {}, RULE_TYPE: {},
}; };
}, },
created() {
this.init();
},
mounted() { mounted() {
this.JUDGE_STATUS = Object.assign({}, JUDGE_STATUS); this.JUDGE_STATUS = Object.assign({}, JUDGE_STATUS);
this.JUDGE_STATUS_LIST = Object.assign({}, JUDGE_STATUS); this.JUDGE_STATUS_LIST = Object.assign({}, JUDGE_STATUS);
@ -360,7 +363,7 @@ export default {
delete this.JUDGE_STATUS_LIST['6']; delete this.JUDGE_STATUS_LIST['6'];
delete this.JUDGE_STATUS_LIST['7']; delete this.JUDGE_STATUS_LIST['7'];
delete this.JUDGE_STATUS_LIST['-10']; delete this.JUDGE_STATUS_LIST['-10'];
this.init(); this.getData();
}, },
methods: { methods: {
init() { init() {
@ -380,6 +383,9 @@ export default {
} }
this.limit = parseInt(query.limit) || 15; this.limit = parseInt(query.limit) || 15;
this.routeName = this.$route.name; this.routeName = this.$route.name;
},
getData() {
// ACM // ACM
if (this.contestID && this.contestRuleType == RULE_TYPE.ACM) { if (this.contestID && this.contestRuleType == RULE_TYPE.ACM) {
this.loadingTable = true; this.loadingTable = true;
@ -392,6 +398,7 @@ export default {
} }
this.getSubmissions(); this.getSubmissions();
}, },
buildQuery() { buildQuery() {
return { return {
onlyMine: this.formFilter.onlyMine, onlyMine: this.formFilter.onlyMine,
@ -750,10 +757,12 @@ export default {
clearInterval(this.refreshStatus); clearInterval(this.refreshStatus);
} }
this.init(); this.init();
this.getData();
} }
}, },
isAuthenticated() { isAuthenticated() {
this.init(); this.init();
this.getData();
}, },
}, },
beforeRouteLeave(to, from, next) { beforeRouteLeave(to, from, next) {