更新backend
This commit is contained in:
parent
e3b0e44d65
commit
614afc950b
|
@ -20,6 +20,8 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.transaction.annotation.Isolation.READ_COMMITTED;
|
||||
|
||||
/**
|
||||
* @Author: Himit_ZH
|
||||
* @Date: 2021/5/24 17:30
|
||||
|
@ -108,14 +110,14 @@ public class ChooseUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class, isolation = READ_COMMITTED)
|
||||
public RemoteJudgeAccount chooseRemoteAccount(String remoteOJAccountType, String vjudgeUsername, Boolean isNeedAccountRejudge) {
|
||||
// 过滤出当前远程oj可用的账号列表
|
||||
QueryWrapper<RemoteJudgeAccount> remoteJudgeAccountQueryWrapper = new QueryWrapper<>();
|
||||
remoteJudgeAccountQueryWrapper
|
||||
.eq("status", true)
|
||||
.eq("oj", remoteOJAccountType)
|
||||
.last("for update"); // 开启悲观锁
|
||||
.last("for update");
|
||||
|
||||
List<RemoteJudgeAccount> remoteJudgeAccountList = remoteJudgeAccountService.list(remoteJudgeAccountQueryWrapper);
|
||||
|
||||
|
@ -127,7 +129,9 @@ public class ChooseUtils {
|
|||
if (isNeedAccountRejudge) {
|
||||
if (remoteJudgeAccount.getUsername().equals(vjudgeUsername)) {
|
||||
UpdateWrapper<RemoteJudgeAccount> remoteJudgeAccountUpdateWrapper = new UpdateWrapper<>();
|
||||
remoteJudgeAccountUpdateWrapper.eq("id", remoteJudgeAccount.getId())
|
||||
remoteJudgeAccountUpdateWrapper
|
||||
.eq("username", remoteJudgeAccount.getUsername())
|
||||
.eq("oj", remoteOJAccountType)
|
||||
.eq("status", true)
|
||||
.set("status", false);
|
||||
boolean isOk = remoteJudgeAccountService.update(remoteJudgeAccountUpdateWrapper);
|
||||
|
@ -138,7 +142,9 @@ public class ChooseUtils {
|
|||
}
|
||||
} else {
|
||||
UpdateWrapper<RemoteJudgeAccount> remoteJudgeAccountUpdateWrapper = new UpdateWrapper<>();
|
||||
remoteJudgeAccountUpdateWrapper.eq("id", remoteJudgeAccount.getId())
|
||||
remoteJudgeAccountUpdateWrapper
|
||||
.eq("username", remoteJudgeAccount.getUsername())
|
||||
.eq("oj", remoteOJAccountType)
|
||||
.eq("status", true)
|
||||
.set("status", false);
|
||||
boolean isOk = remoteJudgeAccountService.update(remoteJudgeAccountUpdateWrapper);
|
||||
|
|
|
@ -51,6 +51,8 @@ spring:
|
|||
mybatis-plus:
|
||||
mapper-locations: classpath*:top/hcode/hoj/dao/xml/**Mapper.xml
|
||||
type-aliases-package: top.hcode.hoj.pojo.entity
|
||||
configuration:
|
||||
cache-enabled: false
|
||||
|
||||
shiro-redis:
|
||||
enabled: true
|
||||
|
|
|
@ -60,7 +60,8 @@ spring:
|
|||
mybatis-plus:
|
||||
mapper-locations: classpath*:top/hcode/hoj/dao/xml/**Mapper.xml
|
||||
type-aliases-package: top.hcode.hoj.pojo.entity
|
||||
|
||||
configuration:
|
||||
cache-enabled: false
|
||||
shiro-redis:
|
||||
enabled: true
|
||||
redis-manager:
|
||||
|
|
|
@ -113,7 +113,7 @@ public class RemoteJudgeGetResult {
|
|||
}
|
||||
|
||||
scheduler.shutdown();
|
||||
}else {
|
||||
} else {
|
||||
|
||||
Judge judge = new Judge();
|
||||
judge.setSubmitId(submitId)
|
||||
|
@ -134,17 +134,20 @@ public class RemoteJudgeGetResult {
|
|||
}
|
||||
|
||||
public void changeAccountStatus(String remoteJudge, String username, String password) {
|
||||
// 由于POJ特殊 之前获取提交ID未释放账号,所以在此需要将账号变为可用
|
||||
if (remoteJudge.equals(Constants.RemoteJudge.POJ_JUDGE.getName())) {
|
||||
UpdateWrapper<RemoteJudgeAccount> remoteJudgeAccountUpdateWrapper = new UpdateWrapper<>();
|
||||
remoteJudgeAccountUpdateWrapper.set("status", true)
|
||||
.eq("oj", remoteJudge)
|
||||
.eq("username", username);
|
||||
boolean isOk = remoteJudgeAccountService.update(remoteJudgeAccountUpdateWrapper);
|
||||
if (!isOk) {
|
||||
log.error("远程判题:修正账号为可用状态失败----------->{}", "username:" + username + ",password:" + password);
|
||||
}
|
||||
UpdateWrapper<RemoteJudgeAccount> remoteJudgeAccountUpdateWrapper = new UpdateWrapper<>();
|
||||
remoteJudgeAccountUpdateWrapper.set("status", true)
|
||||
.eq("username", username);
|
||||
if (remoteJudge.equals("GYM")) {
|
||||
remoteJudgeAccountUpdateWrapper.eq("oj", "CF");
|
||||
} else {
|
||||
remoteJudgeAccountUpdateWrapper.eq("oj", remoteJudge);
|
||||
}
|
||||
boolean isOk = remoteJudgeAccountService.update(remoteJudgeAccountUpdateWrapper);
|
||||
if (!isOk) {
|
||||
log.error("远程判题:修正账号为可用状态失败----------->{}", "username:" + username + ",password:" + password);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -90,24 +90,26 @@ public class RemoteJudgeToSubmit {
|
|||
null);
|
||||
log.error("网络错误---------------->获取不到提交ID");
|
||||
return;
|
||||
} else {
|
||||
// 对POJ特殊 需要一直保持提交和获取结果时账号唯一,所以需要特别过滤
|
||||
if (!remoteJudge.equals(Constants.RemoteJudge.POJ_JUDGE.getName())) {
|
||||
UpdateWrapper<RemoteJudgeAccount> remoteJudgeAccountUpdateWrapper = new UpdateWrapper<>();
|
||||
remoteJudgeAccountUpdateWrapper.set("status", true)
|
||||
.eq("username", username)
|
||||
.eq("status", false);
|
||||
if (remoteJudge.equals("GYM")) {
|
||||
remoteJudgeAccountUpdateWrapper.eq("oj", "CF");
|
||||
} else {
|
||||
remoteJudgeAccountUpdateWrapper.eq("oj", remoteJudge);
|
||||
}
|
||||
boolean isOk = remoteJudgeAccountService.update(remoteJudgeAccountUpdateWrapper);
|
||||
if (!isOk) {
|
||||
log.error("远程判题:修正账号为可用状态失败----------->{}", "username:" + username + ",password:" + password);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 以下代码暂时废除。
|
||||
// } else {
|
||||
// // 对POJ特殊 需要一直保持提交和获取结果时账号唯一,所以需要特别过滤
|
||||
// if (!remoteJudge.equals(Constants.RemoteJudge.POJ_JUDGE.getName())) {
|
||||
// UpdateWrapper<RemoteJudgeAccount> remoteJudgeAccountUpdateWrapper = new UpdateWrapper<>();
|
||||
// remoteJudgeAccountUpdateWrapper.set("status", true)
|
||||
// .eq("username", username)
|
||||
// .eq("status", false);
|
||||
// if (remoteJudge.equals("GYM")) {
|
||||
// remoteJudgeAccountUpdateWrapper.eq("oj", "CF");
|
||||
// } else {
|
||||
// remoteJudgeAccountUpdateWrapper.eq("oj", remoteJudge);
|
||||
// }
|
||||
// boolean isOk = remoteJudgeAccountService.update(remoteJudgeAccountUpdateWrapper);
|
||||
// if (!isOk) {
|
||||
// log.error("远程判题:修正账号为可用状态失败----------->{}", "username:" + username + ",password:" + password);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Long vjudgeSubmitId = (Long) submitResult.get("runId");
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public class Judge implements Serializable {
|
|||
@ApiModelProperty(value = "提交者所在ip")
|
||||
private String ip;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@ApiModelProperty(value = "废弃")
|
||||
private Integer version;
|
||||
|
||||
@ApiModelProperty(value = "该题在OI排行榜的分数")
|
||||
|
|
Loading…
Reference in New Issue