diff --git a/docs/docs/use/spj.md b/docs/docs/use/spj.md index 4ac03e21..cf9be8ec 100644 --- a/docs/docs/use/spj.md +++ b/docs/docs/use/spj.md @@ -28,8 +28,6 @@ using namespace std; -int spj(int user_output, FILE *output); - void close_file(FILE *f){ if(f != NULL){ fclose(f); @@ -37,15 +35,12 @@ void close_file(FILE *f){ } int main(int argc, char *args[]){ - if(argc != 3){ - return ERROR; - } /** input:输入 output:样例的输出 user_output:用户的输出 **/ - FILE *input = fopen(args[1], "r") + FILE *input = fopen(args[1], "r"); FILE *output = fopen(args[2], "r"); double std_out; diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/FileController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/FileController.java index 31b31392..636321f5 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/FileController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/FileController.java @@ -795,10 +795,10 @@ public class FileController { UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo"); List problemDtos = new LinkedList<>(); - List tagList = tagService.list(); - HashMap tagMap = new HashMap<>(); + List tagList = tagService.list(new QueryWrapper().eq("oj", "ME")); + HashMap tagMap = new HashMap<>(); for (Tag tag : tagList) { - tagMap.put(tag.getName(), tag.getId()); + tagMap.put(tag.getName().toUpperCase(), tag); } for (String key : problemInfo.keySet()) { ImportProblemVo importProblemVo = problemVoMap.get(key); @@ -825,6 +825,18 @@ public class FileController { } codeTemplates.add(new CodeTemplate().setCode(code).setStatus(true).setLid(lid)); } + + // 格式化标签 + List tags = new LinkedList<>(); + for (String tagStr : importProblemVo.getTags()) { + Tag tag = tagMap.getOrDefault(tagStr.toUpperCase(), null); + if (tag == null) { + tags.add(new Tag().setName(tagStr).setOj("ME")); + } else { + tags.add(tag); + } + } + Problem problem = BeanUtil.mapToBean(importProblemVo.getProblem(), Problem.class, true); if (problem.getAuthor() == null) { problem.setAuthor(userRolesVo.getUsername()); @@ -838,7 +850,7 @@ public class FileController { problemDto.setIsSpj(importProblemVo.getIsSpj()) .setProblem(problem) .setCodeTemplates(codeTemplates) - .setTags(importProblemVo.getTags().stream().map(tag -> new Tag().setName(tag).setId(tagMap.getOrDefault(tag, null))).collect(Collectors.toList())) + .setTags(tags) .setLanguages(languages) .setUploadTestcaseDir(fileDir + File.separator + key) .setIsUploadTestCase(true) @@ -948,10 +960,10 @@ public class FileController { HttpSession session = request.getSession(); UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo"); - List tagList = tagService.list(); - HashMap tagMap = new HashMap<>(); + List tagList = tagService.list(new QueryWrapper().eq("oj", "ME")); + HashMap tagMap = new HashMap<>(); for (Tag tag : tagList) { - tagMap.put(tag.getName(), tag.getId()); + tagMap.put(tag.getName().toUpperCase(), tag); } List problemDtos = new LinkedList<>(); @@ -964,6 +976,17 @@ public class FileController { languages.add(new Language().setId(lid).setName(lang)); } + // 格式化标签 + List tags = new LinkedList<>(); + for (String tagStr : qdojProblemDto.getTags()) { + Tag tag = tagMap.getOrDefault(tagStr.toUpperCase(), null); + if (tag == null) { + tags.add(new Tag().setName(tagStr).setOj("ME")); + } else { + tags.add(tag); + } + } + Problem problem = qdojProblemDto.getProblem(); if (problem.getAuthor() == null) { problem.setAuthor(userRolesVo.getUsername()); @@ -972,7 +995,7 @@ public class FileController { problemDto.setIsSpj(qdojProblemDto.getIsSpj()) .setProblem(problem) .setCodeTemplates(qdojProblemDto.getCodeTemplates()) - .setTags(qdojProblemDto.getTags().stream().map(tag -> new Tag().setName(tag).setId(tagMap.getOrDefault(tag, null))).collect(Collectors.toList())) + .setTags(tags) .setLanguages(languages) .setUploadTestcaseDir(fileDir + File.separator + key + File.separator + "testcase") .setIsUploadTestCase(true) 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 8452d6b7..4d55c9c7 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 @@ -156,13 +156,15 @@ public class JudgeController { // 管理员比赛前的提交不纳入记录 if (contest.getStatus().intValue() == Constants.Contest.STATUS_RUNNING.getCode()) { - // 先查询是否为首次可能AC提交 - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("cid", judge.getCid()) - .eq("status", Constants.Contest.RECORD_AC.getCode()) - .eq("pid", judge.getPid()); - - boolean FirstACAttempt = contestRecordService.count(queryWrapper) == 0; +// 方法废弃,为了考虑比赛重测问题,不使用字段记录是否为first AC,在排行榜计算自有排序解决first AC的判断 +// // 先查询是否为首次可能AC提交 +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.eq("cid", judge.getCid()) +// .eq("status", Constants.Contest.RECORD_AC.getCode()) +// .lt("submit_time", judge.getSubmitTime()) +// .eq("pid", judge.getPid()); +// +// boolean FirstACAttempt = contestRecordService.count(queryWrapper) == 0; // 同时初始化写入contest_record表 ContestRecord contestRecord = new ContestRecord(); @@ -177,11 +179,11 @@ public class JudgeController { .setSubmitTime(judge.getSubmitTime()) // 设置比赛开始时间到提交时间之间的秒数 .setTime(DateUtil.between(contest.getStartTime(), judge.getSubmitTime(), DateUnit.SECOND)); - if (FirstACAttempt) { - contestRecord.setFirstBlood(true); - } else { - contestRecord.setFirstBlood(false); - } +// if (FirstACAttempt) { +// contestRecord.setFirstBlood(true); +// } else { +// contestRecord.setFirstBlood(false); +// } updateContestRecord = contestRecordService.saveOrUpdate(contestRecord); } diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserRecordMapper.xml b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserRecordMapper.xml index af25d449..23d0f1f3 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserRecordMapper.xml +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/UserRecordMapper.xml @@ -3,23 +3,20 @@ diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/ACMRankVo.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/ACMRankVo.java index 911f6ef9..21ef1f9e 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/ACMRankVo.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/ACMRankVo.java @@ -33,9 +33,6 @@ public class ACMRankVo implements Serializable { @ApiModelProperty(value = "头像地址") private String avatar; - @ApiModelProperty(value = "解决问题数") - private Integer solved; - @ApiModelProperty(value = "总提交数") private Integer total; diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java index e3fbef1a..586da1f0 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java @@ -103,6 +103,8 @@ public class ContestRecordServiceImpl extends ServiceImpl firstACMap = new HashMap<>(); + for (ContestRecord contestRecord : contestRecordList) { ACMContestRankVo ACMContestRankVo; if (!uidMapIndex.containsKey(contestRecord.getUid())) { // 如果该用户信息没还记录 @@ -141,9 +143,22 @@ public class ContestRecordServiceImpl extends ServiceImpl diff --git a/hoj-vue/src/views/oj/rank/ACMRank.vue b/hoj-vue/src/views/oj/rank/ACMRank.vue index c87416f7..6d5e45d4 100644 --- a/hoj-vue/src/views/oj/rank/ACMRank.vue +++ b/hoj-vue/src/views/oj/rank/ACMRank.vue @@ -58,15 +58,7 @@ - - + + +