更新修复
This commit is contained in:
parent
defa00035c
commit
98b84aefd5
|
@ -34,4 +34,3 @@ pnpm-debug.log*
|
|||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
|
|
|
@ -188,12 +188,6 @@
|
|||
<artifactId>jsoup</artifactId>
|
||||
<version>1.13.1</version>
|
||||
</dependency>
|
||||
<!--emoji表情格式转换-->
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>java-emoji-converter</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ import javax.validation.ConstraintViolation;
|
|||
import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.ValidationException;
|
||||
import java.io.IOException;
|
||||
import java.sql.BatchUpdateException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -194,8 +195,8 @@ public class GlobalExceptionHandler {
|
|||
*/
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(value = MessagingException.class)
|
||||
public CommonResult handler(MessagingException e) throws Exception {
|
||||
log.error("邮箱系统异常-------------->{}", e.getMessage());
|
||||
public CommonResult handler(MessagingException e){
|
||||
log.error("邮箱系统异常-------------->{}", getMessage(e));
|
||||
return CommonResult.errorResponse("服务器异常,请稍后尝试!", CommonResult.STATUS_ERROR);
|
||||
}
|
||||
|
||||
|
@ -205,7 +206,7 @@ public class GlobalExceptionHandler {
|
|||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(ServiceException.class)
|
||||
public CommonResult handleServiceException(ServiceException e) {
|
||||
log.error("业务逻辑异常-------------->{}", e.getMessage());
|
||||
log.error("业务逻辑异常-------------->{}", getMessage(e));
|
||||
return CommonResult.errorResponse("服务器异常,请稍后尝试!", CommonResult.STATUS_ERROR);
|
||||
}
|
||||
|
||||
|
@ -215,7 +216,7 @@ public class GlobalExceptionHandler {
|
|||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(DataIntegrityViolationException.class)
|
||||
public CommonResult handleDataIntegrityViolationException(DataIntegrityViolationException e) {
|
||||
log.error("操作数据库出现异常-------------->{}", e.getMessage());
|
||||
log.error("操作数据库出现异常-------------->{}", getMessage(e));
|
||||
return CommonResult.errorResponse("服务器异常,请稍后尝试!", CommonResult.STATUS_ERROR);
|
||||
}
|
||||
|
||||
|
@ -226,7 +227,7 @@ public class GlobalExceptionHandler {
|
|||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(SQLException.class)
|
||||
public CommonResult handleSQLException(SQLException e) {
|
||||
log.error("操作数据库出现异常-------------->{}", e.getMessage());
|
||||
log.error("操作数据库出现异常-------------->{}", getMessage(e));
|
||||
return CommonResult.errorResponse("操作失败!错误提示:" + e.getMessage(), CommonResult.STATUS_ERROR);
|
||||
}
|
||||
|
||||
|
@ -236,7 +237,7 @@ public class GlobalExceptionHandler {
|
|||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(PersistenceException.class)
|
||||
public CommonResult handleBatchUpdateException(PersistenceException e) {
|
||||
log.error("操作数据库出现异常-------------->{}", e.getMessage());
|
||||
log.error("操作数据库出现异常-------------->{}", getMessage(e));
|
||||
return CommonResult.errorResponse("操作失败!请检查数据是否准确!可能原因:数据重复冲突,外键冲突!", CommonResult.STATUS_ERROR);
|
||||
}
|
||||
|
||||
|
@ -246,7 +247,26 @@ public class GlobalExceptionHandler {
|
|||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(Exception.class)
|
||||
public CommonResult handleException(Exception e) {
|
||||
log.error("系统通用异常-------------->{}", e.getMessage());
|
||||
log.error("系统通用异常-------------->{}", getMessage(e));
|
||||
return CommonResult.errorResponse("服务器异常,请稍后尝试!", CommonResult.STATUS_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 打印异常信息
|
||||
*/
|
||||
public static String getMessage(Exception e) {
|
||||
String swStr = null;
|
||||
try (StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw)) {
|
||||
e.printStackTrace(pw);
|
||||
pw.flush();
|
||||
sw.flush();
|
||||
swStr = sw.toString();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
log.error(ex.getMessage());
|
||||
}
|
||||
return swStr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package top.hcode.hoj.controller.oj;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.extra.emoji.EmojiUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.binarywang.java.emoji.EmojiConverter;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresAuthentication;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
@ -45,7 +45,6 @@ public class CommentController {
|
|||
@Autowired
|
||||
private ReplyServiceImpl replyService;
|
||||
|
||||
private static EmojiConverter emojiConverter = EmojiConverter.getInstance();
|
||||
|
||||
@GetMapping("/comments")
|
||||
public CommonResult getComments(@RequestParam(value = "cid", required = false) Long cid,
|
||||
|
@ -113,7 +112,7 @@ public class CommentController {
|
|||
}
|
||||
|
||||
// 带有表情的字符串转换为编码
|
||||
comment.setContent(emojiConverter.toHtml(comment.getContent()));
|
||||
comment.setContent(EmojiUtil.toHtml(comment.getContent()));
|
||||
|
||||
boolean isOk = commentService.saveOrUpdate(comment);
|
||||
|
||||
|
@ -240,7 +239,7 @@ public class CommentController {
|
|||
reply.setFromRole("user");
|
||||
}
|
||||
// 带有表情的字符串转换为编码
|
||||
reply.setContent(emojiConverter.toHtml(reply.getContent()));
|
||||
reply.setContent(EmojiUtil.toHtml(reply.getContent()));
|
||||
|
||||
boolean isOk = replyService.saveOrUpdate(reply);
|
||||
|
||||
|
|
|
@ -35,10 +35,7 @@ import top.hcode.hoj.utils.Constants;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -260,7 +257,8 @@ public class ProblemServiceImpl extends ServiceImpl<ProblemMapper, Problem> impl
|
|||
!oldProblemCase.getOutput().equals(problemCase.getOutput())) {
|
||||
needUpdateProblemCaseList.add(problemCase);
|
||||
} else if (problem.getType().intValue() == Constants.Contest.TYPE_OI.getCode()) {
|
||||
if (oldProblemCase.getScore().intValue() != problemCase.getScore()) {
|
||||
// 分数变动
|
||||
if (!Objects.equals(oldProblemCase.getScore(), problemCase.getScore())) {
|
||||
needUpdateProblemCaseList.add(problemCase);
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +449,7 @@ public class ProblemServiceImpl extends ServiceImpl<ProblemMapper, Problem> impl
|
|||
jsonObject.set("inputName", problemCase.getInput());
|
||||
jsonObject.set("outputName", problemCase.getOutput());
|
||||
// 读取输出文件
|
||||
FileReader readFile = new FileReader(testCasesDir + File.separator + problemCase.getOutput(), CharsetUtil.UTF_8);
|
||||
FileReader readFile = new FileReader(testCasesDir + File.separator + problemCase.getOutput(), CharsetUtil.UTF_8);
|
||||
String output = readFile.readString().replaceAll("\r\n", "\n");
|
||||
|
||||
// spj是根据特判程序输出判断结果,所以无需初始化测试数据
|
||||
|
@ -485,7 +483,6 @@ public class ProblemServiceImpl extends ServiceImpl<ProblemMapper, Problem> impl
|
|||
List<ProblemCase> problemCaseList) {
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
System.out.println(isSpj);
|
||||
result.set("isSpj", isSpj);
|
||||
result.set("version", version);
|
||||
result.set("testCasesSize", problemCaseList.size());
|
||||
|
|
|
@ -84,7 +84,7 @@ public class ScheduleServiceImpl implements ScheduleService {
|
|||
}
|
||||
List<Long> idLists = new LinkedList<>();
|
||||
for (File file : files) {
|
||||
if(file.getDelete()) {
|
||||
if (file.getDelete()) {
|
||||
boolean delSuccess = FileUtil.del(file.getFilePath());
|
||||
if (delSuccess) {
|
||||
idLists.add(file.getId());
|
||||
|
@ -111,8 +111,8 @@ public class ScheduleServiceImpl implements ScheduleService {
|
|||
@Override
|
||||
public void deleteTestCase() {
|
||||
boolean result = FileUtil.del(Constants.File.TESTCASE_TMP_FOLDER.getPath());
|
||||
if (!result){
|
||||
log.error("每日定时任务异常------------------------>{}","清除本地的题目测试数据失败!");
|
||||
if (!result) {
|
||||
log.error("每日定时任务异常------------------------>{}", "清除本地的题目测试数据失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ public class ScheduleServiceImpl implements ScheduleService {
|
|||
// 用户信息存放在result列表中的第0个
|
||||
JSONObject cfUserInfo = resultObject.getJSONArray("result").getJSONObject(0);
|
||||
// 获取cf的分数
|
||||
int cfRating = cfUserInfo.getInt("rating");
|
||||
Integer cfRating = cfUserInfo.getInt("rating", null);
|
||||
UpdateWrapper<UserRecord> userRecordUpdateWrapper = new UpdateWrapper<>();
|
||||
// 将对应的cf分数修改
|
||||
userRecordUpdateWrapper.eq("uid", uuid).set("rating", cfRating);
|
||||
|
|
|
@ -57,8 +57,11 @@
|
|||
</el-row>
|
||||
</div>
|
||||
<div class="mundb-footer">
|
||||
<a style="color:#1E9FFF" :href="websiteConfig.recordUrl"
|
||||
>© 2020-2021</a
|
||||
<a
|
||||
style="color:#1E9FFF"
|
||||
:href="websiteConfig.recordUrl"
|
||||
target="_blank"
|
||||
>{{ websiteConfig.recordName }}</a
|
||||
>
|
||||
Powered by
|
||||
<a
|
||||
|
|
|
@ -382,6 +382,7 @@
|
|||
<el-radio-group
|
||||
v-model="problem.type"
|
||||
:disabled="disableRuleType || problem.isRemote"
|
||||
@change="problemTypeChange"
|
||||
>
|
||||
<el-radio :label="0">ACM</el-radio>
|
||||
<el-radio :label="1">OI</el-radio>
|
||||
|
@ -507,10 +508,7 @@
|
|||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col
|
||||
:span="24"
|
||||
v-show="problem.type == 1 && sample.score != null"
|
||||
>
|
||||
<el-col :span="24" v-show="problem.type == 1">
|
||||
<el-form-item :label="$t('m.Score')">
|
||||
<el-input
|
||||
type="number"
|
||||
|
@ -961,6 +959,17 @@ export default {
|
|||
closeTag(tag) {
|
||||
this.problemTags.splice(this.problemTags.indexOf(tag), 1);
|
||||
},
|
||||
|
||||
problemTypeChange(type) {
|
||||
if (type == 1) {
|
||||
let length = this.problemSamples.length;
|
||||
let aver = parseInt(100 / length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
this.problemSamples[i].score = aver;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 添加题目样例
|
||||
addExample() {
|
||||
this.problem.examples.push({ input: '', output: '', isOpen: true });
|
||||
|
@ -974,7 +983,7 @@ export default {
|
|||
this.problemSamples.push({
|
||||
input: '',
|
||||
output: '',
|
||||
score: 0,
|
||||
score: this.problem.type == 0 ? null : 0,
|
||||
pid: this.pid,
|
||||
isOpen: true,
|
||||
});
|
||||
|
@ -982,7 +991,7 @@ export default {
|
|||
this.problemSamples.push({
|
||||
input: '',
|
||||
output: '',
|
||||
score: null,
|
||||
score: this.problem.type == 0 ? null : 0,
|
||||
pid: this.pid,
|
||||
isOpen: true,
|
||||
});
|
||||
|
@ -1120,11 +1129,23 @@ export default {
|
|||
|
||||
// 同时是oi题目,则对应的每个测试样例的io得分不能为空或小于0
|
||||
if (this.problem.type == 1) {
|
||||
for (let item of this.problemSamples) {
|
||||
for (let i = 0; i < this.problemSamples.length; i++) {
|
||||
if (this.problemSamples[i].score == '') {
|
||||
myMessage.error(
|
||||
this.$i18n.t('m.Problem_Sample') +
|
||||
(i + 1) +
|
||||
' ' +
|
||||
this.$i18n.t('m.Score_must_be_an_integer')
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (parseInt(item.score) < 0) {
|
||||
if (parseInt(this.problemSamples[i].score) < 0) {
|
||||
myMessage.error(
|
||||
this.$i18n.t('m.Score_must_be_greater_than_or_equal_to_0')
|
||||
this.$i18n.t('m.Problem_Sample') +
|
||||
(i + 1) +
|
||||
' ' +
|
||||
this.$i18n.t('m.Score_must_be_greater_than_or_equal_to_0')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -1149,11 +1170,23 @@ export default {
|
|||
|
||||
// 如果是oi题目,需要检查上传的数据的得分
|
||||
if (this.problem.type == 1) {
|
||||
for (let item of this.problem.testCaseScore) {
|
||||
for (let i = 0; i < this.problemSamples.length; i++) {
|
||||
if (this.problemSamples[i].score == '') {
|
||||
myMessage.error(
|
||||
this.$i18n.t('m.Problem_Sample') +
|
||||
(i + 1) +
|
||||
' ' +
|
||||
this.$i18n.t('m.Score_must_be_an_integer')
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (parseInt(item.score) <= 0) {
|
||||
if (parseInt(this.problemSamples[i].score) < 0) {
|
||||
myMessage.error(
|
||||
this.$i18n.t('m.Score_must_be_greater_than_or_equal_to_0')
|
||||
this.$i18n.t('m.Problem_Sample') +
|
||||
(i + 1) +
|
||||
' ' +
|
||||
this.$i18n.t('m.Score_must_be_greater_than_or_equal_to_0')
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,10 @@
|
|||
<el-dropdown
|
||||
style="float:right;"
|
||||
class="hidden-xs-only"
|
||||
v-show="isAuthenticated"
|
||||
v-show="
|
||||
isAuthenticated &&
|
||||
(discussion.uid === userInfo.uid || isAdminRole)
|
||||
"
|
||||
@command="handleCommand"
|
||||
>
|
||||
<span class="el-dropdown-link">
|
||||
|
@ -167,7 +170,10 @@
|
|||
<div class="hidden-sm-and-up">
|
||||
<el-dropdown
|
||||
style="float:right;margin-top:10px; "
|
||||
v-show="isAuthenticated"
|
||||
v-show="
|
||||
isAuthenticated &&
|
||||
(discussion.uid === userInfo.uid || isAdminRole)
|
||||
"
|
||||
@command="handleCommand"
|
||||
>
|
||||
<span class="el-dropdown-link">
|
||||
|
|
Loading…
Reference in New Issue