|
|
@@ -1,17 +1,16 @@
|
|
|
package nju.seec.SEECdemo.logic.service.impl.assignment;
|
|
|
|
|
|
-import nju.seec.SEECdemo.data.dao.assignment.CodeDAO;
|
|
|
-import nju.seec.SEECdemo.data.dao.assignment.CodeResultDAO;
|
|
|
-import nju.seec.SEECdemo.data.entity.assignment.Code;
|
|
|
-import nju.seec.SEECdemo.data.entity.assignment.CodeResult;
|
|
|
-import nju.seec.SEECdemo.logic.api.GitlabApi;
|
|
|
-import nju.seec.SEECdemo.logic.service.CodeService;
|
|
|
-import nju.seec.SEECdemo.logic.service.InterCodeService;
|
|
|
+import nju.seec.SEECdemo.data.dao.assignment.CodeWorkDAO;
|
|
|
+import nju.seec.SEECdemo.data.dao.assignment.CodeWorkResultDAO;
|
|
|
+import nju.seec.SEECdemo.data.entity.assignment.CodeWork;
|
|
|
+import nju.seec.SEECdemo.data.entity.assignment.CodeWorkResult;
|
|
|
+import nju.seec.SEECdemo.logic.service.assignmentWork.CodeWorkService;
|
|
|
+import nju.seec.SEECdemo.logic.service.assignmentWork.external.ExternalCodeWorkService;
|
|
|
import nju.seec.SEECdemo.logic.service.impl.assignment.mock.MockGroup;
|
|
|
import nju.seec.SEECdemo.logic.service.impl.assignment.stub.CourseServiceStub;
|
|
|
import nju.seec.SEECdemo.logic.service.impl.assignment.stub.GroupServiceStub;
|
|
|
-import nju.seec.SEECdemo.logic.vo.CodeWorkVO;
|
|
|
-import nju.seec.SEECdemo.logic.vo.InterCodeAppInfoVO;
|
|
|
+import nju.seec.SEECdemo.logic.vo.assignmentWork.CodeWorkVO;
|
|
|
+import nju.seec.SEECdemo.logic.vo.assignmentWork.external.ExternalCodeInfoVO;
|
|
|
import nju.seec.SEECdemo.util.AsyncWrapper;
|
|
|
import nju.seec.SEECdemo.util.ToolKit;
|
|
|
import nju.seec.SEECdemo.util.enums.AssignmentStatus;
|
|
|
@@ -26,18 +25,18 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Component
|
|
|
-public class CodeServiceImpl implements CodeService, InterCodeService {
|
|
|
+public class CodeWorkServiceImpl implements CodeWorkService, ExternalCodeWorkService {
|
|
|
|
|
|
- private final CodeDAO codeDAO;
|
|
|
- private final CodeResultDAO codeResultDAO;
|
|
|
+ private final CodeWorkDAO codeDAO;
|
|
|
+ private final CodeWorkResultDAO codeResultDAO;
|
|
|
private final AssignmentPaperBuilder assignmentPaperBuilder;
|
|
|
private final AsyncWrapper asyncWrapper;
|
|
|
private final CourseServiceStub courseServiceStub;
|
|
|
private final GroupServiceStub groupServiceStub;
|
|
|
|
|
|
@Autowired
|
|
|
- public CodeServiceImpl(CodeDAO codeDAO, CodeResultDAO codeResultDAO, AssignmentPaperBuilder assignmentPaperBuilder,
|
|
|
- AsyncWrapper asyncWrapper, CourseServiceStub courseServiceStub, GroupServiceStub groupServiceStub){
|
|
|
+ public CodeWorkServiceImpl(CodeWorkDAO codeDAO, CodeWorkResultDAO codeResultDAO, AssignmentPaperBuilder assignmentPaperBuilder,
|
|
|
+ AsyncWrapper asyncWrapper, CourseServiceStub courseServiceStub, GroupServiceStub groupServiceStub){
|
|
|
this.codeDAO = codeDAO;
|
|
|
this.codeResultDAO = codeResultDAO;
|
|
|
this.assignmentPaperBuilder = assignmentPaperBuilder;
|
|
|
@@ -49,7 +48,7 @@ public class CodeServiceImpl implements CodeService, InterCodeService {
|
|
|
|
|
|
@Override
|
|
|
public CodeWorkVO createAssignment(int courseId, CodeWorkDTO codeWorkDTO) {
|
|
|
- Code codework = new Code();
|
|
|
+ CodeWork codework = new CodeWork();
|
|
|
codework.setName(codeWorkDTO.getName());
|
|
|
codework.setDescription(codeWorkDTO.getDescription());
|
|
|
codework.setQuestionId(codeWorkDTO.getQuestion());
|
|
|
@@ -75,8 +74,8 @@ public class CodeServiceImpl implements CodeService, InterCodeService {
|
|
|
*/
|
|
|
@Override
|
|
|
public String getJenkinsBuildJobName(int codeAssignmentId, int groupId) {
|
|
|
- Code code = codeDAO.findById(codeAssignmentId);
|
|
|
- CodeResult codeResult = codeResultDAO.findByCodeAndGroupId(code, groupId);
|
|
|
+ CodeWork code = codeDAO.findById(codeAssignmentId);
|
|
|
+ CodeWorkResult codeResult = codeResultDAO.findByCodeAndGroupId(code, groupId);
|
|
|
return codeResult!=null?codeResult.getBuildJob():null;
|
|
|
}
|
|
|
|
|
|
@@ -87,10 +86,10 @@ public class CodeServiceImpl implements CodeService, InterCodeService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public InterCodeAppInfoVO getInfo(int codeAssignmentId, int groupId) {
|
|
|
- Code code = codeDAO.findById(codeAssignmentId);
|
|
|
- CodeResult codeResult = codeResultDAO.findByCodeAndGroupId(code, groupId);
|
|
|
- InterCodeAppInfoVO codeAppInfoVO = new InterCodeAppInfoVO();
|
|
|
+ public ExternalCodeInfoVO getInfo(int codeAssignmentId, int groupId) {
|
|
|
+ CodeWork code = codeDAO.findById(codeAssignmentId);
|
|
|
+ CodeWorkResult codeResult = codeResultDAO.findByCodeAndGroupId(code, groupId);
|
|
|
+ ExternalCodeInfoVO codeAppInfoVO = new ExternalCodeInfoVO();
|
|
|
codeAppInfoVO.setId(codeResult.getId());
|
|
|
codeAppInfoVO.setProjectId(codeResult.getDeployNamespace());
|
|
|
codeAppInfoVO.setApplicationName(codeResult.getGroupId() + code.getUuid());
|
|
|
@@ -105,8 +104,8 @@ public class CodeServiceImpl implements CodeService, InterCodeService {
|
|
|
*/
|
|
|
@Override
|
|
|
public String getJenkinsTestJobName(int codeAssignmentId, int groupId) {
|
|
|
- Code code = codeDAO.findById(codeAssignmentId);
|
|
|
- CodeResult codeResult = codeResultDAO.findByCodeAndGroupId(code, groupId);
|
|
|
+ CodeWork code = codeDAO.findById(codeAssignmentId);
|
|
|
+ CodeWorkResult codeResult = codeResultDAO.findByCodeAndGroupId(code, groupId);
|
|
|
return codeResult!=null?codeResult.getTestJob():null;
|
|
|
}
|
|
|
|
|
|
@@ -118,12 +117,12 @@ public class CodeServiceImpl implements CodeService, InterCodeService {
|
|
|
add(AssignmentStatus.PREPARING);
|
|
|
}};
|
|
|
try {
|
|
|
- List<Code> codeList = codeDAO.findByCourseIdAndStatusIn(group.getCourseId(), statuses);
|
|
|
- List<Code> preparingList = new ArrayList<>();
|
|
|
+ List<CodeWork> codeList = codeDAO.findByCourseIdAndStatusIn(group.getCourseId(), statuses);
|
|
|
+ List<CodeWork> preparingList = new ArrayList<>();
|
|
|
// TODO
|
|
|
// 对于AVAILABLE的作业,直接将组加入;对于PREPARING的作业,需要等到其状态变更结束后(AVAILABLE或UNAVAILABLE),
|
|
|
// 再根据其状态判断:AVAILABLE,判断该组是否已经在作业中,不在则加入;UNAVAILABLE,则不做操作。
|
|
|
- for (Code code:codeList) {
|
|
|
+ for (CodeWork code:codeList) {
|
|
|
if (code.getStatus()==AssignmentStatus.AVAILABLE) {
|
|
|
assignmentPaperBuilder.addGroupToPaper(code, group);
|
|
|
} else {
|