|
@@ -0,0 +1,55 @@
|
|
|
+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;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.common.dto.core.enums.CourseLevel;
|
|
|
+import cn.com.qmth.examcloud.common.support.exception.StatusException;
|
|
|
+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;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("${url.prefix}/course")
|
|
|
+public class CourseCloudServiceProvider implements CourseCloudService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CourseService courseService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "保存课程", notes = "保存课程")
|
|
|
+ @PostMapping
|
|
|
+ @Override
|
|
|
+ public void saveCourse(CourseReq courseReq) throws Exception {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|