|
@@ -1,9 +1,5 @@
|
|
|
package cn.com.qmth.examcloud.core.basic.api.provider;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -15,11 +11,12 @@ import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.request.CourseReq;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.Course;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.impl.CourseService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
@RestController
|
|
|
-@RequestMapping("${url.prefix}/course")
|
|
|
+@RequestMapping("${$rmp}" + "course")
|
|
|
public class CourseCloudServiceProvider implements CourseCloudService {
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
CourseService courseService;
|
|
|
|
|
@@ -27,29 +24,30 @@ public class CourseCloudServiceProvider implements CourseCloudService {
|
|
|
@PostMapping
|
|
|
@Override
|
|
|
public void saveCourse(CourseReq courseReq) throws Exception {
|
|
|
- Course course = courseService.findByOrgIdAndCode(courseReq.getOrgId(), courseReq.getCourseCode());
|
|
|
- if(course == null){
|
|
|
+ Course course = courseService.findByOrgIdAndCode(courseReq.getOrgId(),
|
|
|
+ courseReq.getCourseCode());
|
|
|
+ if (course == null) {
|
|
|
course = new Course();
|
|
|
- course.setOrgId(courseReq.getOrgId());
|
|
|
- course.setName(courseReq.getCourseName());
|
|
|
- course.setCode(courseReq.getCourseCode());
|
|
|
- course.setLevel(getCourseLevelByCName(courseReq.getCourseLevel()));
|
|
|
- courseService.save(course);
|
|
|
+ course.setOrgId(courseReq.getOrgId());
|
|
|
+ course.setName(courseReq.getCourseName());
|
|
|
+ course.setCode(courseReq.getCourseCode());
|
|
|
+ course.setLevel(getCourseLevelByCName(courseReq.getCourseLevel()));
|
|
|
+ courseService.save(course);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private CourseLevel getCourseLevelByCName(String cname) {
|
|
|
+ CourseLevel courseLevel = null;
|
|
|
+ for (CourseLevel level : CourseLevel.values()) {
|
|
|
+ if (cname.equals(level.getName())) {
|
|
|
+ courseLevel = level;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (courseLevel == null) {
|
|
|
+ throw new StatusException("CORE-BASIC-courseLevel not exists", "课程层次不存在");
|
|
|
+ } else {
|
|
|
+ return courseLevel;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private CourseLevel getCourseLevelByCName(String cname){
|
|
|
- CourseLevel courseLevel = null;
|
|
|
- for(CourseLevel level:CourseLevel.values()){
|
|
|
- if(cname.equals(level.getName())){
|
|
|
- courseLevel = level;
|
|
|
- }
|
|
|
- }
|
|
|
- if(courseLevel==null){
|
|
|
- throw new StatusException("CORE-BASIC-courseLevel not exists","课程层次不存在");
|
|
|
- }else{
|
|
|
- return courseLevel;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
}
|