增加后台题目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 = "keyword", required = false) String keyword,
@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) {
return CommonResult.errorResponse("参数错误!", CommonResult.STATUS_NOT_FOUND);
}
@ -227,8 +228,8 @@ public class AdminContestController {
if (problemType != null) { // 必备条件 隐藏的不可取来做比赛题目
problemQueryWrapper
// vj题目不限制赛制
.and(wrapper->wrapper.eq("type", problemType)
.or().eq("is_remote", true))
.and(wrapper -> wrapper.eq("type", problemType)
.or().eq("is_remote", true))
.ne("auth", 2);
}
@ -248,6 +249,15 @@ public class AdminContestController {
.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);
HashMap<String, Object> contestProblem = new HashMap<>();
contestProblem.put("problemList", problemList);

View File

@ -226,10 +226,10 @@ public class ContestController {
if (contest.getSealRank() && contest.getStatus().intValue() == Constants.Contest.STATUS_RUNNING.getCode() &&
contest.getSealRankTime().before(new Date())) {
contestProblemList = contestProblemService.getContestProblemList(cid, contest.getStartTime(), contest.getEndTime(),
contest.getSealRankTime(), isAdmin);
contest.getSealRankTime(), isAdmin, contest.getAuthor());
} else {
contestProblemList = contestProblemService.getContestProblemList(cid, contest.getStartTime(), contest.getEndTime(),
null, isAdmin);
null, isAdmin, contest.getAuthor());
}
if (contestProblemList.size() == 0) {
@ -321,9 +321,15 @@ public class ContestController {
contest.getSealRankTime().before(new Date())) {
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(),
contestProblem.getCid(), contest.getStartTime(), sealRankTime);
contestProblem.getCid(), contest.getStartTime(), sealRankTime, superAdminUidList);
// 获取题目的代码模板
QueryWrapper<CodeTemplate> codeTemplateQueryWrapper = new QueryWrapper<>();

View File

@ -23,5 +23,5 @@ import java.util.List;
public interface ContestProblemMapper extends BaseMapper<ContestProblem> {
List<ContestProblemVo> getContestProblemList(@Param("cid") Long cid, @Param("startTime") Date startTime,
@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 java.util.Date;
import java.util.List;
/**
@ -35,7 +36,8 @@ public interface JudgeMapper extends BaseMapper<Judge> {
int getTodayJudgeNum();
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);
}

View File

@ -6,6 +6,13 @@
(select count(*) from judge
<where>
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>
<when test="isAdmin">
AND submit_time >= #{startTime} AND #{endTime}>submit_time
@ -22,6 +29,13 @@
(select count(*) from judge
<where>
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>
<when test="isAdmin">
AND submit_time >= #{startTime} AND #{endTime}>=submit_time

View File

@ -91,6 +91,13 @@
<if test="sealRankTime!=null">
and #{sealRankTime} > submit_time
</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>
</select>

View File

@ -16,5 +16,6 @@ import java.util.List;
* @since 2020-10-23
*/
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 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);
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);
}

View File

@ -3,6 +3,7 @@ package top.hcode.hoj.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import top.hcode.hoj.pojo.entity.ContestProblem;
import top.hcode.hoj.dao.ContestProblemMapper;
import top.hcode.hoj.pojo.entity.UserInfo;
import top.hcode.hoj.pojo.vo.ContestProblemVo;
import top.hcode.hoj.service.ContestProblemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
@ -25,8 +27,16 @@ public class ContestProblemServiceImpl extends ServiceImpl<ContestProblemMapper,
@Autowired
private ContestProblemMapper contestProblemMapper;
@Autowired
private ContestRecordServiceImpl contestRecordService;
@Override
public List<ContestProblemVo> getContestProblemList(Long cid, Date startTime, Date endTime, Date sealTime,Boolean isAdmin) {
return contestProblemMapper.getContestProblemList(cid, startTime,endTime,sealTime,isAdmin);
public List<ContestProblemVo> getContestProblemList(Long cid, Date startTime, Date endTime, Date sealTime, Boolean isAdmin, String contestAuthorUid) {
// 筛去 比赛管理员和超级管理员的提交
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 java.util.Date;
import java.util.List;
/**
@ -71,8 +72,8 @@ public class JudgeServiceImpl extends ServiceImpl<JudgeMapper, Judge> implements
}
@Override
public ProblemCountVo getContestProblemCount(Long pid, Long cpid, Long cid, Date startTime, Date sealRankTime) {
return judgeMapper.getContestProblemCount(pid, cpid, cid, startTime, 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, adminList);
}
@Override

View File

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

View File

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

View File

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