From 2dd8522c18de5ea14a2e3077e02fe0afb0f14365 Mon Sep 17 00:00:00 2001 From: Himit_ZH <372347736@qq.com> Date: Fri, 16 Apr 2021 16:57:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E8=A7=A3=E8=80=A6JudgeServer?= =?UTF-8?q?=E5=88=A4=E9=A2=98=E9=80=BB=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 17 +- docs/README.md | 428 +++++++++++++ .../top/hcode/hoj/DataBackupApplication.java | 1 - .../admin/AdminContestController.java | 1 + .../admin/AdminProblemController.java | 1 + .../controller/admin/AdminUserController.java | 53 +- .../controller/admin/ConfigController.java | 11 +- .../hoj/controller/oj/ContestController.java | 1 - .../hoj/controller/oj/JudgeController.java | 9 +- .../hoj/controller/oj/ProblemController.java | 1 + .../hcode/hoj/dao/ContestRecordMapper.java | 4 +- .../hcode/hoj/dao/xml/ContestRecordMapper.xml | 17 +- .../java/top/hcode/hoj/pojo/vo/ConfigVo.java | 3 + .../hoj/service/impl/ConfigServiceImpl.java | 4 + .../impl/ContestRecordServiceImpl.java | 2 +- .../hoj/service/impl/EmailServiceImpl.java | 53 +- .../java/top/hcode/hoj/utils/ConfigUtils.java | 9 +- .../java/top/hcode/hoj/utils/Constants.java | 43 +- .../src/main/resources/application.yml | 6 +- .../src/main/resources/bootstrap.yml | 6 +- .../DataBackup/target/classes/application.yml | 6 +- .../DataBackup/target/classes/bootstrap.yml | 6 +- .../hcode/hoj/dao/xml/ContestRecordMapper.xml | 17 +- .../hoj/common/exception/SubmitError.java | 20 + .../hcode/hoj/controller/JudgeController.java | 16 +- .../java/top/hcode/hoj/judge/Compiler.java | 96 +++ .../java/top/hcode/hoj/judge/JudgeRun.java | 398 ++++++++++++ .../top/hcode/hoj/judge/JudgeStrategy.java | 570 +----------------- .../hcode/hoj/judge/ProblemTestCaseUtils.java | 134 ++++ .../java/top/hcode/hoj/judge/SandboxRun.java | 4 +- .../hoj/service/impl/JudgeServiceImpl.java | 10 +- .../src/main/resources/application.yml | 2 +- .../target/classes/application.yml | 2 +- .../hcode/hoj/JudgeServerApplication.class | Bin 0 -> 882 bytes .../top/hcode/hoj/common/CommonResult.class | Bin 0 -> 3498 bytes .../hoj/common/exception/CompileError.class | Bin 0 -> 2006 bytes .../hoj/common/exception/RuntimeError.class | Bin 0 -> 2006 bytes .../hoj/common/exception/SubmitError.class | Bin 0 -> 2002 bytes .../hoj/common/exception/SystemError.class | Bin 0 -> 2002 bytes .../hcode/hoj/config/AsyncTaskConfig.class | Bin 0 -> 1446 bytes .../hcode/hoj/config/MyMetaObjectConfig.class | Bin 0 -> 1018 bytes .../hcode/hoj/config/MybatisPlusConfig.class | Bin 0 -> 891 bytes .../top/hcode/hoj/config/NacosConfig.class | Bin 0 -> 2606 bytes .../top/hcode/hoj/config/RedisConfig.class | Bin 0 -> 3140 bytes .../hcode/hoj/config/RestTemplateConfig.class | Bin 0 -> 1284 bytes .../top/hcode/hoj/config/StartupRunner.class | Bin 0 -> 4049 bytes .../hoj/controller/JudgeController.class | Bin 0 -> 7202 bytes .../controller/SystemConfigController.class | Bin 0 -> 965 bytes .../top/hcode/hoj/dao/ContestMapper.class | Bin 0 -> 438 bytes .../hcode/hoj/dao/ContestRecordMapper.class | Bin 0 -> 456 bytes .../top/hcode/hoj/dao/JudgeCaseMapper.class | Bin 0 -> 444 bytes .../top/hcode/hoj/dao/JudgeMapper.class | Bin 0 -> 432 bytes .../top/hcode/hoj/dao/JudgeServerMapper.class | Bin 0 -> 450 bytes .../top/hcode/hoj/dao/ProblemCaseMapper.class | Bin 0 -> 450 bytes .../hcode/hoj/dao/ProblemCountMapper.class | Bin 0 -> 453 bytes .../top/hcode/hoj/dao/ProblemMapper.class | Bin 0 -> 438 bytes .../hcode/hoj/dao/UserAcproblemMapper.class | Bin 0 -> 456 bytes .../top/hcode/hoj/dao/UserRecordMapper.class | Bin 0 -> 447 bytes .../top/hcode/hoj/judge/Compiler.class | Bin 0 -> 4591 bytes .../top/hcode/hoj/judge/JudgeRun$1.class | Bin 0 -> 2383 bytes .../top/hcode/hoj/judge/JudgeRun$2.class | Bin 0 -> 2738 bytes .../top/hcode/hoj/judge/JudgeRun.class | Bin 0 -> 15020 bytes .../top/hcode/hoj/judge/JudgeStrategy.class | Bin 0 -> 13475 bytes .../hoj/judge/ProblemTestCaseUtils.class | Bin 0 -> 7092 bytes .../top/hcode/hoj/judge/SandboxRun.class | Bin 0 -> 12409 bytes .../remoteJudge/RemoteJudgeGetResult$1.class | Bin 0 -> 5260 bytes .../remoteJudge/RemoteJudgeGetResult.class | Bin 0 -> 3360 bytes .../hoj/remoteJudge/RemoteJudgeToSubmit.class | Bin 0 -> 5869 bytes .../task/Impl/CodeForcesJudge$1.class | Bin 0 -> 1703 bytes .../CodeForcesJudge$CodeForcesToken.class | Bin 0 -> 943 bytes .../task/Impl/CodeForcesJudge.class | Bin 0 -> 11877 bytes .../remoteJudge/task/Impl/HduJudge$1.class | Bin 0 -> 1227 bytes .../hoj/remoteJudge/task/Impl/HduJudge.class | Bin 0 -> 7867 bytes .../task/RemoteJudgeFactory$1.class | Bin 0 -> 858 bytes .../remoteJudge/task/RemoteJudgeFactory.class | Bin 0 -> 1190 bytes .../task/RemoteJudgeStrategy.class | Bin 0 -> 1041 bytes .../hoj/service/ContestRecordService.class | Bin 0 -> 463 bytes .../hcode/hoj/service/ContestService.class | Bin 0 -> 321 bytes .../hcode/hoj/service/JudgeCaseService.class | Bin 0 -> 327 bytes .../hoj/service/JudgeServerService.class | Bin 0 -> 333 bytes .../top/hcode/hoj/service/JudgeService.class | Bin 0 -> 831 bytes .../hoj/service/ProblemCaseService.class | Bin 0 -> 333 bytes .../hoj/service/ProblemCountService.class | Bin 0 -> 381 bytes .../hcode/hoj/service/ProblemService.class | Bin 0 -> 321 bytes .../hoj/service/SystemConfigService.class | Bin 0 -> 273 bytes .../hoj/service/UserAcproblemService.class | Bin 0 -> 339 bytes .../hcode/hoj/service/UserRecordService.class | Bin 0 -> 396 bytes .../impl/ContestRecordServiceImpl.class | Bin 0 -> 4546 bytes .../hoj/service/impl/ContestServiceImpl.class | Bin 0 -> 695 bytes .../service/impl/JudgeCaseServiceImpl.class | Bin 0 -> 709 bytes .../service/impl/JudgeServerServiceImpl.class | Bin 0 -> 723 bytes .../hoj/service/impl/JudgeServiceImpl.class | Bin 0 -> 6086 bytes .../service/impl/ProblemCaseServiceImpl.class | Bin 0 -> 723 bytes .../impl/ProblemCountServiceImpl$1.class | Bin 0 -> 1304 bytes .../impl/ProblemCountServiceImpl.class | Bin 0 -> 4896 bytes .../hoj/service/impl/ProblemServiceImpl.class | Bin 0 -> 695 bytes .../impl/SystemConfigServiceImpl.class | Bin 0 -> 5606 bytes .../impl/UserAcproblemServiceImpl.class | Bin 0 -> 737 bytes .../service/impl/UserRecordServiceImpl.class | Bin 0 -> 4650 bytes .../hoj/util/Constants$CompileConfig.class | Bin 0 -> 4498 bytes .../hcode/hoj/util/Constants$Contest.class | Bin 0 -> 2370 bytes .../top/hcode/hoj/util/Constants$Judge.class | Bin 0 -> 3227 bytes .../hcode/hoj/util/Constants$JudgeDir.class | Bin 0 -> 1545 bytes .../hoj/util/Constants$RemoteJudge.class | Bin 0 -> 2195 bytes .../hcode/hoj/util/Constants$RunConfig.class | Bin 0 -> 3059 bytes .../top/hcode/hoj/util/Constants.class | Bin 0 -> 1374 bytes .../classes/top/hcode/hoj/util/IpUtils.class | Bin 0 -> 3273 bytes .../top/hcode/hoj/util/JsoupUtils.class | Bin 0 -> 3195 bytes .../top/hcode/hoj/util/RedisUtils.class | Bin 0 -> 12235 bytes .../hoj/JudgeServerApplicationTests.class | Bin 0 -> 1920 bytes .../task/Impl/CodeForcesJudgeTest.class | Bin 0 -> 867 bytes .../remoteJudge/task/Impl/HduJudgeTest.class | Bin 0 -> 3532 bytes .../hcode/hoj/pojo/entity/Announcement.class | Bin 0 -> 4900 bytes .../top/hcode/hoj/pojo/entity/Auth.class | Bin 0 -> 4583 bytes .../top/hcode/hoj/pojo/entity/Comment.class | Bin 0 -> 5810 bytes .../hcode/hoj/pojo/entity/CompileSpj.class | Bin 0 -> 2788 bytes .../top/hcode/hoj/pojo/entity/Contest.class | Bin 0 -> 10458 bytes .../hoj/pojo/entity/ContestAnnouncement.class | Bin 0 -> 3974 bytes .../hoj/pojo/entity/ContestExplanation.class | Bin 0 -> 4565 bytes .../hoj/pojo/entity/ContestProblem.class | Bin 0 -> 5075 bytes .../hcode/hoj/pojo/entity/ContestRecord.class | Bin 0 -> 10393 bytes .../hoj/pojo/entity/ContestRegister.class | Bin 0 -> 4633 bytes .../hcode/hoj/pojo/entity/ContestScore.class | Bin 0 -> 4943 bytes .../top/hcode/hoj/pojo/entity/File.class | Bin 0 -> 6512 bytes .../top/hcode/hoj/pojo/entity/Judge.class | Bin 0 -> 13139 bytes .../top/hcode/hoj/pojo/entity/JudgeCase.class | Bin 0 -> 8676 bytes .../hcode/hoj/pojo/entity/JudgeServer.class | Bin 0 -> 8246 bytes .../top/hcode/hoj/pojo/entity/Language.class | Bin 0 -> 6598 bytes .../top/hcode/hoj/pojo/entity/Problem.class | Bin 0 -> 15338 bytes .../hcode/hoj/pojo/entity/ProblemCase.class | Bin 0 -> 5436 bytes .../hcode/hoj/pojo/entity/ProblemCount.class | Bin 0 -> 8199 bytes .../hoj/pojo/entity/ProblemLanguage.class | Bin 0 -> 3818 bytes .../hcode/hoj/pojo/entity/ProblemTag.class | Bin 0 -> 3783 bytes .../top/hcode/hoj/pojo/entity/Role.class | Bin 0 -> 4620 bytes .../top/hcode/hoj/pojo/entity/RoleAuth.class | Bin 0 -> 3311 bytes .../top/hcode/hoj/pojo/entity/Session.class | Bin 0 -> 4284 bytes .../top/hcode/hoj/pojo/entity/Tag.class | Bin 0 -> 3966 bytes .../top/hcode/hoj/pojo/entity/ToJudge.class | Bin 0 -> 4585 bytes .../hcode/hoj/pojo/entity/UserAcproblem.class | Bin 0 -> 4496 bytes .../top/hcode/hoj/pojo/entity/UserInfo.class | Bin 0 -> 9809 bytes .../hcode/hoj/pojo/entity/UserRecord.class | Bin 0 -> 5656 bytes .../top/hcode/hoj/pojo/entity/UserRole.class | Bin 0 -> 3370 bytes .../src/views/admin/general/SystemConfig.vue | 32 +- .../src/views/oj/status/SubmissionList.vue | 3 +- sqlAndsetting/hoj-data-backup-prod.yml | 1 + 145 files changed, 1293 insertions(+), 694 deletions(-) create mode 100644 docs/README.md create mode 100644 hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/common/exception/SubmitError.java create mode 100644 hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/Compiler.java create mode 100644 hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/JudgeRun.java create mode 100644 hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/ProblemTestCaseUtils.java create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/JudgeServerApplication.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/common/CommonResult.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/common/exception/CompileError.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/common/exception/RuntimeError.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/common/exception/SubmitError.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/common/exception/SystemError.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/config/AsyncTaskConfig.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/config/MyMetaObjectConfig.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/config/MybatisPlusConfig.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/config/NacosConfig.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/config/RedisConfig.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/config/RestTemplateConfig.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/config/StartupRunner.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/controller/JudgeController.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/controller/SystemConfigController.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/ContestMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/ContestRecordMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/JudgeCaseMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/JudgeMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/JudgeServerMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/ProblemCaseMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/ProblemCountMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/ProblemMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/UserAcproblemMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/dao/UserRecordMapper.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/judge/Compiler.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/judge/JudgeRun$1.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/judge/JudgeRun$2.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/judge/JudgeRun.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/judge/JudgeStrategy.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/judge/ProblemTestCaseUtils.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/judge/SandboxRun.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/RemoteJudgeGetResult$1.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/RemoteJudgeGetResult.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/RemoteJudgeToSubmit.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/task/Impl/CodeForcesJudge$1.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/task/Impl/CodeForcesJudge$CodeForcesToken.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/task/Impl/CodeForcesJudge.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/task/Impl/HduJudge$1.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/task/Impl/HduJudge.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/task/RemoteJudgeFactory$1.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/task/RemoteJudgeFactory.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/remoteJudge/task/RemoteJudgeStrategy.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/ContestRecordService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/ContestService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/JudgeCaseService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/JudgeServerService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/JudgeService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/ProblemCaseService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/ProblemCountService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/ProblemService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/SystemConfigService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/UserAcproblemService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/UserRecordService.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/ContestRecordServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/ContestServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/JudgeCaseServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/JudgeServerServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/JudgeServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/ProblemCaseServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/ProblemCountServiceImpl$1.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/ProblemCountServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/ProblemServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/SystemConfigServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/UserAcproblemServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/service/impl/UserRecordServiceImpl.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/Constants$CompileConfig.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/Constants$Contest.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/Constants$Judge.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/Constants$JudgeDir.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/Constants$RemoteJudge.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/Constants$RunConfig.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/Constants.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/IpUtils.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/JsoupUtils.class create mode 100644 hoj-springboot/JudgeServer/target/classes/top/hcode/hoj/util/RedisUtils.class create mode 100644 hoj-springboot/JudgeServer/target/test-classes/top/hcode/hoj/JudgeServerApplicationTests.class create mode 100644 hoj-springboot/JudgeServer/target/test-classes/top/hcode/hoj/remoteJudge/task/Impl/CodeForcesJudgeTest.class create mode 100644 hoj-springboot/JudgeServer/target/test-classes/top/hcode/hoj/remoteJudge/task/Impl/HduJudgeTest.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Announcement.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Auth.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Comment.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/CompileSpj.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Contest.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ContestAnnouncement.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ContestExplanation.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ContestProblem.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ContestRecord.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ContestRegister.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ContestScore.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/File.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Judge.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/JudgeCase.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/JudgeServer.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Language.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Problem.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ProblemCase.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ProblemCount.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ProblemLanguage.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ProblemTag.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Role.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/RoleAuth.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Session.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/Tag.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/ToJudge.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/UserAcproblem.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/UserInfo.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/UserRecord.class create mode 100644 hoj-springboot/api/target/classes/top/hcode/hoj/pojo/entity/UserRole.class diff --git a/README.md b/README.md index d7b150b8..886291bd 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,18 @@ > 上线日记 -| 时间 | 内容 | 更新者 | -| ---------- | ----------------------- | -------- | -| 2020-10-26 | 正式开发 | Himit_ZH | -| 2021-04-10 | 首次上线测试 | Himit_ZH | -| 2021-04-15 | 判题调度2.0解决并发问题 | Himit_ZH | +| 时间 | 内容 | 更新者 | +| ---------- | ----------------------------------------- | -------- | +| 2020-10-26 | 正式开发 | Himit_ZH | +| 2021-04-10 | 首次上线测试 | Himit_ZH | +| 2021-04-15 | 判题调度2.0解决并发问题 | Himit_ZH | +| 2021-04-16 | 重构解耦JudgeServer判题逻辑,添加部署文档 | Himit_ZH | + +# 二、部署 + +**注意:比较适用于熟悉springboot,docker的开发人员打包部署** + +部署文档:[https://gitee.com/himitzh0730/hoj/tree/master/docs](https://gitee.com/himitzh0730/hoj/tree/master/docs) > 简略介绍 diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..faaf0c71 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,428 @@ +### 1. 后端部署 + +**linux下安装下载docker,自行百度** + +#### 1.1 安装MySQL + +1. 创建自定义网络(用于容器通讯) + + ```shell + docker network create hoj-network + ``` + +2. 查看网络 + + ```shell + docker network ls + ``` + +3. 创建挂载文件夹 + + ```shell + //mysql配置文件 + mkdir -p /data/mysql/conf + //mysql数据文件路径 + mkdir –p /data/mysql/data + //日志文件路径 + mkdir -p /data/mysql/logs + ``` + +4. 启动mysql + + ```shell + docker run -p 3306:3306 --name mysql -d \ + --restart=always \ + --network hoj-network \ + -v /data/mysql/conf:/etc/mysql/conf.d \ + -v /data/mysql/logs:/logs \ + -v /data/mysql/data:/data \ + -e MYSQL_ROOT_PASSWORD=admin \ + mysql:5.7 + ``` + +5. 启动成功后 使用docker ps 可查看 如果正常则进行数据库创建操作 + +6. 创建名字叫hoj的数据库,执行脚本在sqlAndSetting文件夹里面或者 [hoj.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj.sql)、[hoj-data.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/hoj-data.sql) + +7. 创建名字叫nacos的数据库,执行脚本在sqlAndSetting文件夹里面或者 [nacos.sql](https://gitee.com/himitzh0730/hoj/blob/master/sqlAndsetting/nacos-mysql.sql) + +#### 1.2 注册中心与配置中心naco + +1. 执行docker命令,拉取nacos镜像。 + + ```shell + //查询nacos镜像 + docker search nacos + //拉取镜像 + docker pull nacos/nacos-server + //查看镜像 + docker images + ``` + +2. 启动nacos + + ```shell + docker run --env MODE=standalone --network hoj-network --name nacos -d -p 8848:8848 nacos/nacos-server + ``` + +3. 查看自定义网络中各容器ip,一般该network的ip应该是**172.18.0.2或172.19.0.2** + + ```shell + //查看网络 + docker network ls + //查看网络容器 + docker network inspect hoj-network + ``` + +4. 进入nacos容器修改配置 + + ```shell + // 进入容器 + docker exec -it nacos bash + // 修改容器配置 + cd conf + vi application.properties + ``` + + ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200411202402562.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3hpZXFpbmdfeHE=,size_16,color_FFFFFF,t_70) + +5. 重启容器 + + ```shell + docker restart nacos + ``` + +6. 连上nacos,将后端服务需要的配置添加进去 + + ```she + http://ip:8848/nacos/index.html + nacos/nacos(用户名和密码) + ``` + + **登陆后,点击添加** + + ![在这里插入图片描述](https://img-blog.csdnimg.cn/20210416154428657.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70) + + **依次添加后台服务的配置文件和判题服务的配置文件** + + ![在这里插入图片描述](https://img-blog.csdnimg.cn/20210416154647434.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70) + +7. hoj-data-backup-prod.yml的配置如下,请自行修改 + + ```yaml + hoj: + jwt: + # 加密秘钥 + secret: zsc-acm-hoj + # token有效时长,24小时,单位秒 + expire: 86400 + # 6小时内还有请求,可进行刷新 + checkRefreshExpire: 21600 + header: token + judge: + # 调用判题服务器的token + token: zsc-acm-hoj-judge-server + db: # mysql数据库服务配置 + host: your_mysql_host + port: your_mysql_port + name: your_mysql_database_name # 默认hoj + username: your_mysql_username + password: your_mysql_password + mail: # 邮箱服务配置 + ssl: true + username: your_email_username + password: your_email_password + host: your_email_host + port: your_email_port + background-img: https://cdn.jsdelivr.net/gh/HimitZH/CDN/images/HCODE.png # 邮箱系统发送邮件模板的背景图片地址 + redis: # redis服务配置 + host: your_redis_host + port: 6371 + password: your_redis_password + web-config: + base-url: http://www.hcode.top # 后端服务地址 + name: zsc-acm-hoj # 后端服务地址 + short-name: hoj # oj简写 + register: true + footer: # 网站页面底部footer配置 + record: + name: 浙ICP备20009096号-1 # 网站备案 + url: http://www.hcode.top # 网站域名 + project: # 项目 + name: HOJ # 项目名字 + url: https://gitee.com/himitzh0730/hoj # 项目地址 + hdu: + account: + username: hdu账号1用户名,hdu账号2用户名,... + password: hdu账号1密码,hdu账号2密码,... + cf: + account: + username: cf账号1用户名,cf账号2用户名,... + password: cf账号1密码,cf账号2密码,... + ``` + +8. 添加好后点击发布,再次添加hoj-judge-server-prod.yml,流程一样 + + ```yaml + hoj: + judge: + db: + username: your_mysql_username + password: your_mysql_password + host: your_mysql_host + port: your_mysql_port + name: your_mysql_database_name # 数据库名字默认hoj + # 调用判题服务器的token,与数据服务后台必须一致! + token: zsc-acm-hoj-judge-server + redis: + host: your_redis_host + port: your_redis_port + password: your_redis_password + ``` + +#### 1.3 Redis部署 + +依旧使用docker部署 ,**mypassword是redis的密码,请使用上面配置文件中redis的password,必须一致!** + +```shell +//查询目前可用的reids镜像 +docker search redis + +//选择拉取官网的镜像 +docker pull redis + +//查看本地是否有redis镜像 +docker images + +//运行redis并设置密码 +docker run -d --name redis -p 6379:6379 redis --requirepass "mypassword" --restart=always +``` + +#### 1.4 DataBackup数据后台部署 + +1. 修改该路径**/hoj-springboot/DataBackup/src/main/resources/bootstrap.yml**的相关配置 + + ```yaml + hoj-backstage: + port: 6688 + nacos-url: 172.18.0.2:8848 # nacos地址,如果使用了docker network 可用使用network的ip 否则请使用服务器ip + ``` + +2. 使用cmd打开当前JudgeServer文件夹路径,然后使用mvn命令进行打包成jar包 + + ```powershell + mvn clean package -Dmaven.test.skip=true + ``` + +3. 上传到服务器,**使用apt安装JDK8,请自行百度**,然后在当前文件夹同时创建名叫`Dockerfile`的文件,编写内容如下: + + ```dockerfile + FROM java:8 + + COPY *.jar /app.jar + + CMD ["--server.port=6688"] + + EXPOSE 6688 + + ENV TZ=Asia/Shanghai + + RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + + ENTRYPOINT ["java","-Xmx512m","-Xms512m","-Xmn256m","-Djava.security.egd=file:/dev/./urandom","-jar", "/app.jar"] + ``` + +4. 在当前文件夹使用命令打包成docker镜像 + + ```shell + // 使用dockerfile打包成镜像 + docker build -t hoj . + // 查看hoj镜像是否存在 + docker images + ``` + +5. 启动容器 + + ```shell + docker run -d -p 6688:6688 --name hoj --network hoj-network hoj + ``` + +6. 查看是否成功 + + ```shell + docker ps + ``` + +#### 1.5 JudgeServer判题服务部署 + +> 注意:判题服务可以部署多台云服务器,步骤一样 + +1. 下载本项目,git clone或者download zip + +2. 修改该路径**/hoj-springboot/JudgeServer/src/main/resources/bootstrap.yml**的相关配置 + + ```yaml + hoj-judge-server: + max-task-num: -1 # -1表示最大并行任务数为cpu核心数*2 + ip: 127.0.0.1 # -1表示使用默认本地ipv4,若是部署其它服务器,务必使用公网ip + port: 8088 # 端口号 + name: hoj-judger-1 # 判题机名字 唯一不可重复!!! + nacos-url: 127.0.0.1:8848 # nacos地址 + remote-judge: + open: true # 当前判题服务器是否开启远程虚拟判题功能 + max-task-num: -1 # -1表示最大并行任务数为(cpu核心数*2)*2 + ``` + +3. 使用cmd打开当前JudgeServer文件夹路径,然后使用mvn命令进行打包成jar包 + + ```shell + mvn clean package -Dmaven.test.skip=true + ``` + +4. 打包成功后在路径**/hoj-springboot/JudgeServer/target/** 文件夹内找到类似JudgeServer.jar的jar包,然后将该jar包与**/judger**文件夹内的Judger-SandBox文件(go打包的linux系统下可执行文件)一起上传到云服务器的同一个文件夹内,同时在该文件夹内创建一个JudgeServer.json的文件,JVM的配置可以直接配置,内容如下: + + ```json + { + "apps" : { + "name":"hoj-judgeServer", + "script":"java", + "args":[ + "-XX:+UseG1GC", + "-jar", + "JudgeServer.jar", // 注意为jar包名字 + ], + "error_file":"./log/err.log", + "out_file":"./log/out.log", + "merge_logs":true, + "log_date_format":"YYYY/MM/DD HH:mm:ss", + "min_uptime": "60s", + "max_restarts": 30, + "autorestart": true, + "restart_delay": "60" + } + } + ``` + +5. 使用apt安装JDK8,请自行百度。**下面的操作都使用root权限,才不会出错。** + +6. 接下来使用pm2启动管理Judger-SandBox和JudgeServer,当然可用别的方式启动jar包,nohup之类的都可以,记住Judger-SandBox默认占用5050端口,JudgeServer占用8088端口,请确认不会被其它进程占用!本次介绍使用pm2管理启动: + + - 更新`apt-get` + + ```shell + sudo apt-get update + ``` + + - 安装`nodeJs` + + ```shell + sudo apt-get install nodejs + ``` + + - 安装`npm` + + ```shell + sudo apt-get install npm + ``` + + - 安装`pm2` + + ```shell + sudo npm install -g pm2 + ``` + + - 查看帮助,看到提示就说明成功了 + + ```sehll + pm2 --help + ``` + +7. 使用了第5步的就可以启动判题服务和判题安全沙盒了,操作如下: + + - 启动沙盒,确保不要出错,不然无法进行自身题目判题(远程虚拟判题vj无影响),Judger-SandBox为文件名,即是刚刚上传的。 + + ```shell + pm2 start Judger-SandBox + ``` + + - 查看是否正常,status的状态是online就是正常 + + ```shell + pm2 list + ``` + + - 启动判题服务,JudgeServer.json是我们在第四步配置创建放在与jar包同个文件夹里面的json文件,启动后也使用`pm2 list`查看 + + ```shell + pm2 start JudgeServer.json + ``` + + - 如果两者pm2 list里面的status都是online则说明此次判题服务部署成功。 + +8. 最后一步,下载对应编译语言的编译器,HOJ默认支持 GCC,G++,Python2,Python3,Java,Golang,C#编程语言,请自行百度下载对应的编译器。 + + + +### 2. 前端部署 + +1. 下载本项目,git clone或者download zip + +2. 前提是本地有vue-cli4,请自行百度下载 + +3. 进入/hoj-vue文件夹,修改生产环境下的后端服务地址 + + ![在这里插入图片描述](https://img-blog.csdnimg.cn/2021041616214988.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80Mzg1MzA5Nw==,size_16,color_FFFFFF,t_70) + +4. 然后在当前路径运行打包命令 + + ```powershell + npm run build + ``` + +5. 打包成功会在src同文件夹内有个dist文件夹,复制里面的html和css等静态文件,上传到服务器的指定文件夹内/hoj/www/html内 + +6. 配置nginx,在安装好nginx后,修改nginx.conf配置 + + ```shell + sudo vi /etc/nginx/nginx.conf + ``` + +7. 将下面的内容复制进去 + + ```json + server{ + listen 80; + server_name www.hcode.top; # 此处填写你的域名或IP + root /hoj/www/htm; # 此处填写你的网页根目录 + location /api{ + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://localhost:6688; # 填写你的后端地址和端口 + } + location ~ .*\.(js|json|css)$ { + gzip on; + gzip_static on; # gzip_static是nginx对于静态文件的处理模块,该模块可以读取预先压缩的gz文件,这样可以减少每次请求进行gzip压缩的CPU资源消耗。 + gzip_min_length 1k; + gzip_http_version 1.1; + gzip_comp_level 9; + gzip_types text/css application/javascript application/json; + root /hoj/www/html; # 此处填写你的网页根目录 + } + location / { # 路由重定向以适应Vue中的路由 + index index.html; + try_files $uri $uri/ /index.html; + } + } + ``` + +8. 修改后保存,然后重启或者热重载nginx,不出意外应该可用访问前端页面了。 + + ```shell + sudo systemctl restart nginx + 或 + sudo nginx -s reload + ``` + + \ No newline at end of file diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/DataBackupApplication.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/DataBackupApplication.java index 17f9447b..bd58b160 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/DataBackupApplication.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/DataBackupApplication.java @@ -15,7 +15,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; @EnableScheduling // 开启定时任务 @EnableDiscoveryClient // 开启注册发现 @SpringBootApplication -@EnableFeignClients // 开启feign @EnableAsync(proxyTargetClass=true) //开启异步注解 public class DataBackupApplication { public static void main(String[] args) { diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminContestController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminContestController.java index 4cd17fd4..15771749 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminContestController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminContestController.java @@ -61,6 +61,7 @@ public class AdminContestController { QueryWrapper queryWrapper = new QueryWrapper<>(); if (!StringUtils.isEmpty(keyword)) { + keyword = keyword.trim(); queryWrapper .like("title", keyword).or() .like("id", keyword); diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminProblemController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminProblemController.java index 1b6ca823..cad03b6b 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminProblemController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminProblemController.java @@ -63,6 +63,7 @@ public class AdminProblemController { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.orderByDesc("gmt_create"); if (!StringUtils.isEmpty(keyword)) { + keyword = keyword.trim(); queryWrapper .like("title", keyword).or() .like("author", keyword).or() diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminUserController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminUserController.java index 924e0e07..d951e20c 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminUserController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminUserController.java @@ -49,12 +49,15 @@ public class AdminUserController { @RequiresRoles("root") // 只有超级管理员能操作 public CommonResult getUserList(@RequestParam(value = "limit", required = false) Integer limit, @RequestParam(value = "currentPage", required = false) Integer currentPage, - @RequestParam(value = "keyword", required = false) String keyword){ + @RequestParam(value = "keyword", required = false) String keyword) { if (currentPage == null || currentPage < 1) currentPage = 1; if (limit == null || limit < 1) limit = 10; + if (keyword != null) { + keyword = keyword.trim(); + } IPage userList = userRoleService.getUserList(limit, currentPage, keyword); if (userList.getTotal() == 0) { // 未查询到一条数据 - return CommonResult.successResponse(userList,"暂无数据"); + return CommonResult.successResponse(userList, "暂无数据"); } else { return CommonResult.successResponse(userList, "获取成功"); } @@ -65,7 +68,7 @@ public class AdminUserController { @RequiresRoles("root") // 只有超级管理员能操作 @RequiresAuthentication @Transactional - public CommonResult editUser(@RequestBody Map params){ + public CommonResult editUser(@RequestBody Map params) { String username = (String) params.get("username"); String uid = (String) params.get("uid"); String realname = (String) params.get("realname"); @@ -80,7 +83,7 @@ public class AdminUserController { .set("username", username) .set("realname", realname) .set("email", email) - .set(setNewPwd,"password", SecureUtil.md5(password)) + .set(setNewPwd, "password", SecureUtil.md5(password)) .set("status", status); boolean result1 = userInfoService.update(updateWrapper1); @@ -88,8 +91,8 @@ public class AdminUserController { updateWrapper2.eq("uid", uid).set("role_id", type); boolean result2 = userRoleService.update(updateWrapper2); - if (result1&&result2){ - return CommonResult.successResponse(null,"修改成功!"); + if (result1 && result2) { + return CommonResult.successResponse(null, "修改成功!"); } return CommonResult.errorResponse("修改失败!"); } @@ -97,12 +100,12 @@ public class AdminUserController { @DeleteMapping("/delete-user") @RequiresRoles("root") // 只有超级管理员能操作 @RequiresAuthentication - public CommonResult deleteUser(@RequestBody Map params){ + public CommonResult deleteUser(@RequestBody Map params) { List deleteUserIds = (List) params.get("ids"); boolean result = userInfoService.removeByIds(deleteUserIds); - if (result){ + if (result) { return CommonResult.successResponse(null, "删除成功!"); - }else{ + } else { return CommonResult.errorResponse("删除失败!"); } } @@ -111,12 +114,12 @@ public class AdminUserController { @RequiresRoles("root") // 只有超级管理员能操作 @RequiresAuthentication @Transactional - public CommonResult insertBatchUser(@RequestBody Map params){ + public CommonResult insertBatchUser(@RequestBody Map params) { List> users = (List>) params.get("users"); List userInfoList = new LinkedList<>(); List userRoleList = new LinkedList<>(); List userRecordList = new LinkedList<>(); - if (users!=null) { + if (users != null) { for (List user : users) { String uuid = IdUtil.simpleUUID(); userInfoList.add(new UserInfo() @@ -137,7 +140,7 @@ public class AdminUserController { } else { return CommonResult.errorResponse("删除失败"); } - }else{ + } else { return CommonResult.errorResponse("插入的用户数据不能为空!"); } } @@ -146,27 +149,27 @@ public class AdminUserController { @RequiresRoles("root") // 只有超级管理员能操作 @RequiresAuthentication @Transactional - public CommonResult generateUser(@RequestBody Map params){ - String prefix = (String) params.getOrDefault("prefix",""); - String suffix = (String) params.getOrDefault("suffix",""); - int numberFrom = (int) params.getOrDefault("number_from",1); - int numberTo = (int) params.getOrDefault("number_to",10); - int passwordLength = (int) params.getOrDefault("password_length",6); + public CommonResult generateUser(@RequestBody Map params) { + String prefix = (String) params.getOrDefault("prefix", ""); + String suffix = (String) params.getOrDefault("suffix", ""); + int numberFrom = (int) params.getOrDefault("number_from", 1); + int numberTo = (int) params.getOrDefault("number_to", 10); + int passwordLength = (int) params.getOrDefault("password_length", 6); List userInfoList = new LinkedList<>(); List userRoleList = new LinkedList<>(); List userRecordList = new LinkedList<>(); - HashMap userInfo = new HashMap<>(); // 存储账号密码放入redis中,等待导出excel - for(int num=numberFrom;num<=numberTo;num++){ + HashMap userInfo = new HashMap<>(); // 存储账号密码放入redis中,等待导出excel + for (int num = numberFrom; num <= numberTo; num++) { String uuid = IdUtil.simpleUUID(); String password = RandomUtil.randomString(passwordLength); - String username = prefix+num+suffix; + String username = prefix + num + suffix; userInfoList.add(new UserInfo() .setUuid(uuid) .setUsername(username) .setPassword(SecureUtil.md5(password))); - userInfo.put(username,password); + userInfo.put(username, password); userRoleList.add(new UserRole() .setRoleId(1002L) .setUid(uuid)); @@ -177,10 +180,10 @@ public class AdminUserController { boolean result3 = userRecordService.saveBatch(userRecordList); if (result1 && result2 && result3) { String key = IdUtil.simpleUUID(); - redisUtils.hmset(key,userInfo,1800); // 存储半小时 + redisUtils.hmset(key, userInfo, 1800); // 存储半小时 return CommonResult.successResponse(MapUtil.builder() - .put("key",key).map(), "生成指定用户成功!"); - }else { + .put("key", key).map(), "生成指定用户成功!"); + } else { return CommonResult.errorResponse("生成指定用户失败!"); } } diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/ConfigController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/ConfigController.java index 9177d255..d6b73087 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/ConfigController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/ConfigController.java @@ -89,11 +89,12 @@ public class ConfigController { @RequestMapping("/get-email-config") public CommonResult getEmailConfig() { return CommonResult.successResponse( - MapUtil.builder().put("username", configVo.getEmailUsername()) - .put("password", configVo.getEmailPassword()) - .put("host", configVo.getEmailHost()) - .put("port", configVo.getEmailPort()) - .put("ssl", configVo.getEmailSsl()).map() + MapUtil.builder().put("emailUsername", configVo.getEmailUsername()) + .put("emailPassword", configVo.getEmailPassword()) + .put("emailHost", configVo.getEmailHost()) + .put("emailPort", configVo.getEmailPort()) + .put("emailBGImg", configVo.getEmailBGImg()) + .put("emailSsl", configVo.getEmailSsl()).map() ); } 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 fa5687d0..eb88271d 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 @@ -480,7 +480,6 @@ public class ContestController { if (currentPage == null || currentPage < 1) currentPage = 1; if (limit == null || limit < 1) limit = 30; - // 获取当前比赛的,状态为ac,未被校验的排在签名 IPage contestRecords = contestRecordService.getACInfo(currentPage, limit, Constants.Contest.RECORD_AC.getCode(), cid); 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 7a970c1e..81dc3aaf 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 @@ -105,7 +105,7 @@ public class JudgeController { */ @RequiresAuthentication @RequestMapping(value = "/submit-problem-judge", method = RequestMethod.POST) - @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED) + @Transactional(rollbackFor = Exception.class, isolation = Isolation.REPEATABLE_READ) public CommonResult submitProblemJudge(@RequestBody ToJudgeDto judgeDto, HttpServletRequest request) { // 需要获取一下该token对应用户的数据 @@ -239,6 +239,7 @@ public class JudgeController { */ @RequiresAuthentication @GetMapping(value = "/resubmit") + @Transactional public CommonResult resubmit(@RequestParam("submitId") Long submitId, HttpServletRequest request) { @@ -407,6 +408,12 @@ public class JudgeController { } uid = userRolesVo.getUid(); } + if (searchPid != null) { + searchPid = searchPid.trim(); + } + if (searchUsername != null) { + searchUsername = searchUsername.trim(); + } IPage commonJudgeList = judgeService.getCommonJudgeList(limit, currentPage, searchPid, searchStatus, searchUsername, uid); 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 5234cd3b..8581481f 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 @@ -78,6 +78,7 @@ public class ProblemController { // 关键词查询不为空 Long pid = null; if (!StringUtils.isEmpty(keyword)) { + keyword = keyword.trim(); Pattern pattern = Pattern.compile("[0-9]*"); Matcher isNum = pattern.matcher(keyword); if (isNum.matches()) { // 利用正则表达式判断keyword是否为纯数字 diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/ContestRecordMapper.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/ContestRecordMapper.java index 4983ba44..c84438e7 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/ContestRecordMapper.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/ContestRecordMapper.java @@ -4,10 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; -import top.hcode.hoj.pojo.vo.ContestRecordVo; import top.hcode.hoj.pojo.entity.ContestRecord; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import top.hcode.hoj.pojo.vo.JudgeVo; import java.util.Date; import java.util.List; @@ -23,7 +21,7 @@ import java.util.List; @Mapper @Repository public interface ContestRecordMapper extends BaseMapper { - IPage getACInfo(IPage iPage, @Param("status") Integer status, @Param("cid") Long cid); + List getACInfo(IPage iPage, @Param("status") Integer status, @Param("cid") Long cid); List getOIContestRecord(@Param("cid") Long cid, @Param("isOpenSealRank") Boolean isOpenSealRank, @Param("sealTime") Date sealTime, @Param("endTime") Date endTime); diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/ContestRecordMapper.xml b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/ContestRecordMapper.xml index e235937d..c47be7e8 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/ContestRecordMapper.xml +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/ContestRecordMapper.xml @@ -3,14 +3,21 @@ - SELECT id,uid,username,display_id,cid,realname,pid,time,status, + SELECT id,uid,username,display_id,cid,realname,pid,time,status,checked, MIN(submit_id) AS submit_id, MIN(submit_time) AS submit_time, - MAX(first_blood) AS first_blood, - checked FROM contest_record - WHERE status=#{status} and cid = #{cid} + MAX(first_blood) AS first_blood + FROM contest_record + + + status=#{status} + + + and cid = #{cid} + + GROUP BY status,uid,pid,cpid - ORDER BY checked DESC,submit_time DESC + ORDER BY checked ASC,submit_time DESC