From 71aa59310bf02d02e108b809c1ba038e877d75f5 Mon Sep 17 00:00:00 2001 From: Himit_ZH <372347736@qq.com> Date: Sun, 19 Dec 2021 10:55:02 +0800 Subject: [PATCH] delete judge.tid --- .../hoj/controller/oj/JudgeController.java | 5 +- .../hoj/controller/oj/TrainingController.java | 2 + .../java/top/hcode/hoj/dao/JudgeMapper.java | 1 - .../top/hcode/hoj/dao/xml/JudgeMapper.xml | 3 - .../hcode/hoj/service/judge/JudgeService.java | 1 - .../service/judge/impl/JudgeServiceImpl.java | 5 +- .../impl/TrainingRecordServiceImpl.java | 2 +- .../hcode/hoj/pojo/entity/judge/Judge.java | 3 - hoj-vue/src/views/oj/problem/Problem.vue | 2 +- .../src/views/oj/training/TrainingList.vue | 33 ++++++++-- sqlAndsetting/hoj-update.sql | 65 +++++++++++++++++++ sqlAndsetting/hoj.sql | 7 +- 12 files changed, 104 insertions(+), 25 deletions(-) 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 ea90a9fd..f3504d30 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 @@ -113,7 +113,7 @@ public class JudgeController { boolean isContestSubmission = judgeDto.getCid() != 0; - boolean isTrainingSubmission = judgeDto.getTid() != null; + boolean isTrainingSubmission = judgeDto.getTid() != null && judgeDto.getTid() != 0; if (!isContestSubmission) { // 非比赛提交限制8秒提交一次 String lockKey = Constants.Account.SUBMIT_NON_CONTEST_LOCK.getCode() + userRolesVo.getUid(); @@ -134,7 +134,6 @@ public class JudgeController { judge.setShare(false) // 默认设置代码为单独自己可见 .setCode(judgeDto.getCode()) .setCid(judgeDto.getCid()) - .setTid(judgeDto.getTid()) .setLanguage(judgeDto.getLanguage()) .setLength(judgeDto.getCode().length()) .setUid(userRolesVo.getUid()) @@ -392,7 +391,6 @@ public class JudgeController { @RequestParam(value = "currentPage", required = false) Integer currentPage, @RequestParam(value = "onlyMine", required = false) Boolean onlyMine, @RequestParam(value = "problemID", required = false) String searchPid, - @RequestParam(value = "tid", required = false) Long tid, @RequestParam(value = "status", required = false) Integer searchStatus, @RequestParam(value = "username", required = false) String searchUsername, @RequestParam(value = "completeProblemID", defaultValue = "false") Boolean completeProblemID, @@ -426,7 +424,6 @@ public class JudgeController { searchStatus, searchUsername, uid, - tid, completeProblemID); if (commonJudgeList.getTotal() == 0) { // 未查询到一条数据 diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/TrainingController.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/TrainingController.java index 65b63386..bf7b9c38 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/TrainingController.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/oj/TrainingController.java @@ -82,6 +82,7 @@ public class TrainingController { * @Since 2021/11/20 */ @GetMapping("/get-training-detail") + @RequiresAuthentication public CommonResult getTraining(@RequestParam(value = "tid") Long tid, HttpServletRequest request) { Training training = trainingService.getById(tid); @@ -121,6 +122,7 @@ public class TrainingController { * @Since 2021/11/20 */ @GetMapping("/get-training-problem-list") + @RequiresAuthentication public CommonResult getTrainingProblemList(@RequestParam(value = "tid") Long tid, HttpServletRequest request) { Training training = trainingService.getById(tid); diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/JudgeMapper.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/JudgeMapper.java index 5cff82b0..40001b45 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/JudgeMapper.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/JudgeMapper.java @@ -30,7 +30,6 @@ public interface JudgeMapper extends BaseMapper { @Param("status") Integer status, @Param("username") String username, @Param("uid") String uid, - @Param("tid") Long tid, @Param("completeProblemID") Boolean completeProblemID); IPage getContestJudgeList(Page page, diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/JudgeMapper.xml b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/JudgeMapper.xml index 4e9e2988..c91483fa 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/JudgeMapper.xml +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/JudgeMapper.xml @@ -24,9 +24,6 @@ AND j.uid = #{uid} - - AND j.tid = #{tid} - order by j.submit_time DESC,j.submit_id DESC diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/judge/JudgeService.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/judge/JudgeService.java index fd1163b6..6946f1b6 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/judge/JudgeService.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/judge/JudgeService.java @@ -32,7 +32,6 @@ public interface JudgeService extends IService { Integer status, String username, String uid, - Long tid, Boolean completeProblemID); IPage getContestJudgeList(Integer limit, diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/judge/impl/JudgeServiceImpl.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/judge/impl/JudgeServiceImpl.java index a2cd10ec..73f9dbeb 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/judge/impl/JudgeServiceImpl.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/judge/impl/JudgeServiceImpl.java @@ -50,7 +50,7 @@ public class JudgeServiceImpl extends ServiceImpl implements QueryWrapper problemQueryWrapper = new QueryWrapper<>(); problemQueryWrapper.eq("problem_id", judgeDto.getPid()); - Problem problem = problemService.getOne(problemQueryWrapper,false); + Problem problem = problemService.getOne(problemQueryWrapper, false); if (problem.getAuth() == 2) { return CommonResult.errorResponse("错误!当前题目不可提交!", CommonResult.STATUS_FORBIDDEN); @@ -70,12 +70,11 @@ public class JudgeServiceImpl extends ServiceImpl implements Integer status, String username, String uid, - Long tid, Boolean completeProblemID) { //新建分页 Page page = new Page<>(currentPage, limit); - return judgeMapper.getCommonJudgeList(page, searchPid, status, username, uid, tid, completeProblemID); + return judgeMapper.getCommonJudgeList(page, searchPid, status, username, uid, completeProblemID); } @Override diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/training/impl/TrainingRecordServiceImpl.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/training/impl/TrainingRecordServiceImpl.java index a7c2b4fd..5b3e1176 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/training/impl/TrainingRecordServiceImpl.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/service/training/impl/TrainingRecordServiceImpl.java @@ -98,7 +98,7 @@ public class TrainingRecordServiceImpl extends ServiceImpl {{ $t('m.Training_Category') }}
+ {{ $t('m.All') }} import('@/components/oj/common/Pagination'); export default { name: 'TrainingList', @@ -209,10 +218,15 @@ export default { }, toTraining(trainingID) { - this.$router.push({ - name: 'TrainingDetails', - params: { trainingID: trainingID }, - }); + if (!this.isAuthenticated) { + myMessage.warning(this.$i18n.t('m.Please_login_first')); + this.$store.dispatch('changeModalStatus', { visible: true }); + } else { + this.$router.push({ + name: 'TrainingDetails', + params: { trainingID: trainingID }, + }); + } }, goUserHome(username) { this.$router.push({ @@ -222,6 +236,14 @@ export default { }, getCategoryBlockColor(category) { + if (category == null) { + if (!this.query.categoryId) { + return 'color: #fff;background-color: #409EFF;background-color: #409EFF'; + } else { + return 'background-color: #fff;color: #409EFF;border-color: #409EFF'; + } + } + if (category.id == this.query.categoryId) { return ( 'color: #fff;background-color: ' + @@ -241,6 +263,9 @@ export default { } }, }, + computed: { + ...mapGetters(['isAuthenticated']), + }, watch: { $route(newVal, oldVal) { if (newVal !== oldVal) { diff --git a/sqlAndsetting/hoj-update.sql b/sqlAndsetting/hoj-update.sql index 51aa6c4c..d84d03ba 100644 --- a/sqlAndsetting/hoj-update.sql +++ b/sqlAndsetting/hoj-update.sql @@ -524,3 +524,68 @@ DELIMITER ; CALL contest_Add_auto_real_rank; DROP PROCEDURE contest_Add_auto_real_rank; + + + + +/* +* 2021.12.07 contest增加打星账号列表、是否开放榜单 + +*/ +DROP PROCEDURE +IF EXISTS contest_Add_star_account_And_open_rank; +DELIMITER $$ + +CREATE PROCEDURE contest_Add_star_account_And_open_rank () +BEGIN + +IF NOT EXISTS ( + SELECT + 1 + FROM + information_schema.`COLUMNS` + WHERE + table_name = 'contest' + AND column_name = 'star_account' +) THEN + ALTER TABLE `hoj`.`contest` ADD COLUMN `star_account` mediumtext COMMENT '打星用户列表'; + ALTER TABLE `hoj`.`contest` ADD COLUMN `open_rank` BOOLEAN DEFAULT 0 NULL COMMENT '是否开放比赛榜单'; +END +IF ; END$$ + +DELIMITER ; +CALL contest_Add_star_account_And_open_rank ; + +DROP PROCEDURE contest_Add_star_account_And_open_rank; + + + +/* +* 2021.12.19 judge表删除tid + +*/ +DROP PROCEDURE +IF EXISTS judge_Delete_tid; +DELIMITER $$ + +CREATE PROCEDURE judge_Delete_tid () +BEGIN + +IF EXISTS ( + SELECT + 1 + FROM + information_schema.`COLUMNS` + WHERE + table_name = 'judge' + AND column_name = 'tid' +) THEN + ALTER TABLE `hoj`.`judge` DROP foreign key `judge_ibfk_4`; + ALTER TABLE `hoj`.`judge` DROP COLUMN `tid`; +END +IF ; END$$ + +DELIMITER ; +CALL judge_Delete_tid ; + +DROP PROCEDURE judge_Delete_tid; diff --git a/sqlAndsetting/hoj.sql b/sqlAndsetting/hoj.sql index 0ee75603..81c7ed8a 100644 --- a/sqlAndsetting/hoj.sql +++ b/sqlAndsetting/hoj.sql @@ -149,6 +149,8 @@ CREATE TABLE `contest` ( `open_account_limit` tinyint(1) DEFAULT '0' COMMENT '是否开启账号限制', `account_limit_rule` mediumtext COMMENT '账号限制规则', `rank_show_name` varchar(20) DEFAULT 'username' COMMENT '排行榜显示(username、nickname、realname)', + `open_rank` tinyint(1) DEFAULT '0' COMMENT '是否开放比赛榜单', + `star_account` mediumtext COMMENT '打星用户列表', `gmt_create` datetime DEFAULT CURRENT_TIMESTAMP, `gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`,`uid`), @@ -414,7 +416,6 @@ CREATE TABLE `judge` ( `language` varchar(30) DEFAULT NULL COMMENT '代码语言', `cid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '比赛id,非比赛题目默认为0', `cpid` bigint(20) unsigned DEFAULT '0' COMMENT '比赛中题目排序id,非比赛题目默认为0', - `tid` bigint unsigned DEFAULT NULL, `judger` varchar(20) DEFAULT NULL COMMENT '判题机ip', `ip` varchar(20) DEFAULT NULL COMMENT '提交者所在ip', `version` int(11) NOT NULL DEFAULT '0' COMMENT '乐观锁', @@ -428,11 +429,9 @@ CREATE TABLE `judge` ( KEY `pid` (`pid`), KEY `uid` (`uid`), KEY `username` (`username`), - KEY `tid` (`tid`), CONSTRAINT `judge_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `judge_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `user_info` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `judge_ibfk_3` FOREIGN KEY (`username`) REFERENCES `user_info` (`username`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `judge_ibfk_4` FOREIGN KEY (`tid`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `judge_ibfk_3` FOREIGN KEY (`username`) REFERENCES `user_info` (`username`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; /*Table structure for table `judge_case` */