|
|
@@ -2,11 +2,14 @@ package cn.seecoder.ojserver.service.impl;
|
|
|
|
|
|
import cn.seecoder.codejudge.client.JudgeDTO;
|
|
|
import cn.seecoder.codejudge.client.JudgeResult;
|
|
|
+import cn.seecoder.ojserver.dao.CommitDAO;
|
|
|
+import cn.seecoder.ojserver.dao.entity.Commit;
|
|
|
import cn.seecoder.ojserver.dao.entity.Problem;
|
|
|
import cn.seecoder.ojserver.dao.entity.TestCase;
|
|
|
import cn.seecoder.ojserver.exception.ThirdPartyServiceException;
|
|
|
import cn.seecoder.ojserver.manager.JudgeManager;
|
|
|
import cn.seecoder.ojserver.manager.QuestionManager;
|
|
|
+import cn.seecoder.ojserver.model.dto.CodeJudgeDTO;
|
|
|
import cn.seecoder.ojserver.model.vo.CodeJudgeVO;
|
|
|
import cn.seecoder.ojserver.service.JudgeService;
|
|
|
|
|
|
@@ -14,8 +17,10 @@ import com.nju.edu.paasMonitorClient.MonitorClient;
|
|
|
import com.nju.edu.paasMonitorClient.entity.Call;
|
|
|
import com.nju.edu.paasMonitorCommon.enums.SeecSystem;
|
|
|
import okhttp3.*;
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -25,8 +30,10 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
private final QuestionManager questionManager;
|
|
|
private final JudgeManager judgeManager;
|
|
|
private final OkHttpClient client;
|
|
|
+ private final RabbitTemplate rabbitTemplate;
|
|
|
+ private final CommitDAO commitDAO;
|
|
|
|
|
|
- public JudgeServiceImpl(QuestionManager questionManager, JudgeManager judgeManager) {
|
|
|
+ public JudgeServiceImpl(QuestionManager questionManager, JudgeManager judgeManager, RabbitTemplate rabbitTemplate, CommitDAO commitDAO) {
|
|
|
this.questionManager = questionManager;
|
|
|
this.judgeManager = judgeManager;
|
|
|
this.client = new OkHttpClient()
|
|
|
@@ -34,6 +41,9 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
.connectTimeout(60000, TimeUnit.MILLISECONDS)
|
|
|
.readTimeout(60000, TimeUnit.MILLISECONDS)
|
|
|
.build();
|
|
|
+ this.rabbitTemplate = rabbitTemplate;
|
|
|
+ this.commitDAO = commitDAO;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -60,5 +70,19 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public JudgeResult asyncJudgeCode(Integer questionId, CodeJudgeVO codeJudgeVO) {
|
|
|
+ Commit commit = new Commit();
|
|
|
+ commit.setUserId(0);
|
|
|
+ commit.setProblemId(questionId);
|
|
|
+ commit.setCode(codeJudgeVO.getCode());
|
|
|
+ commit.setLanguage(codeJudgeVO.getLanguage());
|
|
|
+ commit.setCommitTime(new Date());
|
|
|
+ commitDAO.save(commit);
|
|
|
+ CodeJudgeDTO codeJudgeDTO = new CodeJudgeDTO(commit.getId(),questionId,codeJudgeVO);
|
|
|
+ rabbitTemplate.convertAndSend("notice_queue",codeJudgeDTO);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|