瀏覽代碼

试卷结构课程id

xiatian 4 年之前
父節點
當前提交
577e5fdc28

+ 11 - 0
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/PaperStruct.java

@@ -35,6 +35,8 @@ public class PaperStruct extends IdBase {
 
     private String orgId;// 机构ID
 
+    private Long courseId;
+    
     private String courseNo;
 
     private String courseName;
@@ -199,4 +201,13 @@ public class PaperStruct extends IdBase {
         this.courseName = courseName;
     }
 
+	public Long getCourseId() {
+		return courseId;
+	}
+
+	public void setCourseId(Long courseId) {
+		this.courseId = courseId;
+	}
+
+    
 }

+ 13 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperStructService.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.questions.service;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
 import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
 import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
@@ -174,6 +175,18 @@ public class PaperStructService {
      * @return
      */
     public PaperStruct save(PaperStruct paperStruct, User user) {
+    	if (StringUtils.isNotBlank(paperStruct.getCourseNo())) {
+    		GetCourseReq req = new GetCourseReq();
+            req.setRootOrgId(Long.valueOf(paperStruct.getOrgId()));
+            req.setCode(paperStruct.getCourseNo());
+            GetCourseResp resp = courseCloudService.getCourse(req);
+			if (resp.getCourseBean() == null) {
+				throw new StatusException("500","课程不存在");
+			}
+			paperStruct.setCourseId(resp.getCourseBean().getId());
+		} else {
+			paperStruct.setCourseId(null);
+		}
         if (StringUtils.isNotBlank(paperStruct.getId())) {
             PaperStruct oldPaperStruct = Model.of(paperStructRepo.findById(paperStruct.getId()));
             PaperStruct rps = null;