|
@@ -0,0 +1,56 @@
|
|
|
+package cn.com.qmth.examcloud.exchange.outer.api.provider;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+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.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.common.support.ControllerSupport;
|
|
|
+import cn.com.qmth.examcloud.common.support.exception.StatusException;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.ExamReq;
|
|
|
+import cn.com.qmth.examcloud.exchange.outer.service.ExamService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author chenken
|
|
|
+ * @date 2018年5月2日 下午3:49:31
|
|
|
+ * @company QMTH
|
|
|
+ * @description ExamProcider.java
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("${outer.url.prefix}/exam")
|
|
|
+public class ExamProvider extends ControllerSupport{
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ExamService examService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "创建考试", notes = "创建考试")
|
|
|
+ @PostMapping
|
|
|
+ public Map<String,String> createExam(@RequestBody ExamReq exam) {
|
|
|
+ Map<String,String> returnMsg = new HashMap<String, String>();
|
|
|
+ try{
|
|
|
+ examService.createExam(exam);
|
|
|
+ returnMsg.put("errorMsg", null);
|
|
|
+ returnMsg.put("successMsg", "创建考试成功");
|
|
|
+ }catch(Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ if(e instanceof StatusException){
|
|
|
+ if(((StatusException) e).getCode().equals("EXAMWORK-EXAMEXSTED")){
|
|
|
+ returnMsg.put("errorMsg", "考试名称已经存在");
|
|
|
+ }else{
|
|
|
+ returnMsg.put("errorMsg", "创建考试失败");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ returnMsg.put("errorMsg", "创建考试失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return returnMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|