add submit code max length 65535

This commit is contained in:
Himit_ZH 2022-01-14 16:56:53 +08:00
parent 66d6eabb5b
commit 1ace6d3ae0
2 changed files with 8 additions and 4 deletions

View File

@ -107,6 +107,14 @@ public class JudgeController {
@Transactional(rollbackFor = Exception.class)
public CommonResult submitProblemJudge(@RequestBody ToJudgeDto judgeDto, HttpServletRequest request) {
if (judgeDto.getCode().length() < 50 && !judgeDto.getLanguage().contains("Py")) {
return CommonResult.errorResponse("提交的代码是无效的代码字符长度请不要低于50", CommonResult.STATUS_FORBIDDEN);
}
if (judgeDto.getCode().length() > 65535) {
return CommonResult.errorResponse("提交的代码是无效的代码字符长度请不要超过65535", CommonResult.STATUS_FORBIDDEN);
}
// 需要获取一下该token对应用户的数据
HttpSession session = request.getSession();
UserRolesVo userRolesVo = (UserRolesVo) session.getAttribute("userInfo");
@ -131,10 +139,6 @@ public class JudgeController {
redisUtils.expire(lockKey, 3);
}
if (judgeDto.getCode().length() < 50 && !judgeDto.getLanguage().contains("Py")) {
return CommonResult.errorResponse("提交的代码是无效的代码长度请不要低于50", CommonResult.STATUS_FORBIDDEN);
}
// 将提交先写入数据库准备调用判题服务器
Judge judge = new Judge();