wangwei 6 vuotta sitten
vanhempi
commit
2cb3af308a

+ 32 - 1
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/HandleSyncCloudServiceProvider.java

@@ -1,5 +1,6 @@
 package cn.com.qmth.examcloud.core.examwork.api.provider;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -20,6 +21,7 @@ import cn.com.qmth.examcloud.commons.api.response.SyncExamStudentResp;
 import cn.com.qmth.examcloud.commons.api.response.SyncOrgResp;
 import cn.com.qmth.examcloud.commons.api.response.SyncSpecialtyResp;
 import cn.com.qmth.examcloud.commons.api.response.SyncStudentResp;
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
 import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
 import io.swagger.annotations.ApiOperation;
@@ -47,7 +49,28 @@ public class HandleSyncCloudServiceProvider extends ControllerSupport
 	@PostMapping("syncCourse")
 	@Override
 	public SyncCourseResp syncCourse(@RequestBody SyncCourseReq req) {
-		return null;
+		String courseName = req.getName();
+		Long courseId = req.getId();
+		String courseLevel = req.getLevel();
+		Long rootOrgId = req.getRootOrgId();
+
+		if (StringUtils.isBlank(courseName)) {
+			throw new StatusException("B-100001", "courseName is null");
+		}
+		if (null == courseId) {
+			throw new StatusException("B-100002", "courseId is null");
+		}
+		if (StringUtils.isBlank(courseLevel)) {
+			throw new StatusException("B-100003", "courseLevel is null");
+		}
+		if (null == rootOrgId) {
+			throw new StatusException("B-100004", "rootOrgId is null");
+		}
+
+		examStudentRepo.updateCourse(courseName, courseLevel, rootOrgId, courseId);
+
+		SyncCourseResp resp = new SyncCourseResp();
+		return resp;
 	}
 
 	@ApiOperation(value = "同步机构")
@@ -63,6 +86,14 @@ public class HandleSyncCloudServiceProvider extends ControllerSupport
 	public SyncStudentResp syncStudent(@RequestBody SyncStudentReq req) {
 		String name = req.getName();
 		Long id = req.getId();
+
+		if (StringUtils.isBlank(name)) {
+			throw new StatusException("B-100001", "name is null");
+		}
+		if (null == id) {
+			throw new StatusException("B-100002", "id is null");
+		}
+
 		examStudentRepo.updateStudent(name, id);
 		return null;
 	}

+ 5 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/ExamStudentRepo.java

@@ -30,4 +30,9 @@ public interface ExamStudentRepo
 	@Modifying
 	@Query("update ExamStudentEntity s set s.name = ?1  where s.studentId = ?2")
 	void updateStudent(String name, Long studentId);
+
+	@Modifying
+	@Query("update ExamStudentEntity s set s.courseName = ?1, s.courseLevel  = ?2  where s.rootOrgId = ?3 and s.courseId=?4")
+	void updateCourse(String courseName, String courseLevel, Long rootOrgId, Long courseId);
+
 }