wangwei 7 年之前
父節點
當前提交
a552eaa85c

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

@@ -156,7 +156,38 @@ public class CourseCloudServiceProvider implements CourseCloudService {
 	@PostMapping("getCourse")
 	@Override
 	public GetCourseResp getCourse(@RequestBody GetCourseReq req) {
-		return null;
+		GetCourseResp resp = new GetCourseResp();
+		Long rootOrgId = req.getRootOrgId();
+		String code = req.getCode();
+		Long id = req.getId();
+
+		if (null == rootOrgId) {
+			throw new StatusException("B-160000", "rootOrgId is null");
+		}
+		Course c = null;
+		if (null != id) {
+			c = courseRepo.findOne(id);
+
+		} else if (StringUtils.isNotBlank(code)) {
+			c = courseRepo.findByOrgIdAndCode(rootOrgId, code);
+		} else {
+			throw new StatusException("B-160002", "code is blank");
+		}
+
+		if (null == c) {
+			throw new StatusException("B-160003", "课程不存在");
+		}
+
+		CourseBean courseBean = new CourseBean();
+		courseBean.setId(c.getId());
+		courseBean.setCode(c.getCode());
+		courseBean.setLevel(c.getLevel().name());
+		courseBean.setName(c.getName());
+		courseBean.setRootOrgId(c.getOrgId());
+
+		resp.setCourseBean(courseBean);
+
+		return resp;
 	}
 
 }