Explorar o código

在线考试接口

xiatian %!s(int64=5) %!d(string=hai) anos
pai
achega
af8941a4a5

+ 25 - 1
src/main/java/cn/com/qmth/examcloud/app/controller/ExamController.java

@@ -3,13 +3,18 @@ package cn.com.qmth.examcloud.app.controller;
 import static cn.com.qmth.examcloud.app.model.Constants.PARAM_APP_KEY;
 import static cn.com.qmth.examcloud.app.model.Constants.PARAM_APP_TOKEN;
 
+import javax.validation.Valid;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import cn.com.qmth.examcloud.app.model.GetYunSignatureReq;
 import cn.com.qmth.examcloud.app.model.Result;
 import cn.com.qmth.examcloud.app.service.CoreOeService;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
@@ -30,6 +35,25 @@ public class ExamController extends ControllerSupport {
 			@PathVariable String keys) throws Exception{
 	    return oeService.getExamPropertyFromCacheByStudentSession(key, token, examId, keys);
 	}
-
+	/**
+     * 获取云存储上传签名(微信小程序调用)
+     */
+    @ApiOperation(value = "获取文件上传签名")
+    @PostMapping("/yunSignature")
+    public Result getYunSignature(@RequestHeader(name = PARAM_APP_KEY) String key, @RequestHeader(name = PARAM_APP_TOKEN) String token,@ModelAttribute @Valid GetYunSignatureReq req) throws Exception{
+        return oeService.getYunSignature(key, token, req);
+    }
+    
+    @ApiOperation(value = "获取在线考试待考列表")
+    @GetMapping("/queryExamList")
+    public Result queryExamList(@RequestHeader(name = PARAM_APP_KEY) String key, @RequestHeader(name = PARAM_APP_TOKEN) String token) throws Exception{
+        return oeService.queryExamList(key, token);
+    }
+    
+    @ApiOperation(value = "获取考试记录信息")
+    @GetMapping("/getEndExamInfo/{examRecordDataId}")
+    public Result getEndExamInfo(@RequestHeader(name = PARAM_APP_KEY) String key, @RequestHeader(name = PARAM_APP_TOKEN) String token,@PathVariable Long examRecordDataId) throws Exception{
+        return oeService.getEndExamInfo(key, token,examRecordDataId);
+    }
 
 }

+ 68 - 0
src/main/java/cn/com/qmth/examcloud/app/model/GetYunSignatureReq.java

@@ -0,0 +1,68 @@
+package cn.com.qmth.examcloud.app.model;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+
+public class GetYunSignatureReq implements JsonSerializable {
+	/**
+     * 
+     */
+    private static final long serialVersionUID = 4523536593807014828L;
+    @NotNull(message = "考试记录DataID不能为空")
+    @ApiModelProperty(required = true, value = "考试记录DataID")
+    private String examRecordDataId;
+    @NotNull(message = "题号不能为空")
+    @ApiModelProperty(required = true, value = "考试试题号")
+    private String order;
+    @NotNull(message = "文件MD5不能为空")
+    @ApiModelProperty(required = true, value = "文件MD5")
+    private String fileMd5;
+    @NotNull(message = "文件后缀不能为空")
+    @ApiModelProperty(required = true, value = "文件后缀")
+    private String fileSuffix;
+    @ApiModelProperty(value = "文件名自定义参数")
+    private String ext;
+
+    public String getExamRecordDataId() {
+        return examRecordDataId;
+    }
+
+    public void setExamRecordDataId(String examRecordDataId) {
+        this.examRecordDataId = examRecordDataId;
+    }
+
+    public String getOrder() {
+        return order;
+    }
+
+    public void setOrder(String order) {
+        this.order = order;
+    }
+
+    public String getFileMd5() {
+        return fileMd5;
+    }
+
+    public void setFileMd5(String fileMd5) {
+        this.fileMd5 = fileMd5;
+    }
+
+    public String getFileSuffix() {
+        return fileSuffix;
+    }
+
+    public void setFileSuffix(String fileSuffix) {
+        this.fileSuffix = fileSuffix;
+    }
+
+    public String getExt() {
+        return ext;
+    }
+
+    public void setExt(String ext) {
+        this.ext = ext;
+    }
+
+}

+ 48 - 14
src/main/java/cn/com/qmth/examcloud/app/service/CoreOeService.java

@@ -1,12 +1,12 @@
 /*
- * *************************************************
- * Copyright (c) 2018 QMTH. All Rights Reserved.
- * Created by Deason on 2018-07-31 17:31:34.
+ * ************************************************* Copyright (c) 2018 QMTH.
+ * All Rights Reserved. Created by Deason on 2018-07-31 17:31:34.
  * *************************************************
  */
 
 package cn.com.qmth.examcloud.app.service;
 
+import cn.com.qmth.examcloud.app.model.GetYunSignatureReq;
 import cn.com.qmth.examcloud.app.model.Result;
 
 /**
@@ -60,7 +60,8 @@ public interface CoreOeService {
      * @return
      * @throws Exception
      */
-    Result uploadPaperAnswer(String key, String token, String examRecordId, byte[] fileBytes, String fileName, String md5) throws Exception;
+    Result uploadPaperAnswer(String key, String token, String examRecordId, byte[] fileBytes, String fileName,
+            String md5) throws Exception;
 
     /**
      * 获取某考试批次下的课程列表
@@ -103,7 +104,9 @@ public interface CoreOeService {
      * @return
      * @throws Exception
      */
-    Result getAdminExamPaperStructList(String key, String token, String examRecordId,String fromCache) throws Exception;
+    Result getAdminExamPaperStructList(String key, String token, String examRecordId, String fromCache)
+            throws Exception;
+
     /**
      * 获取当前练习的试卷大题结构信息
      *
@@ -134,7 +137,8 @@ public interface CoreOeService {
      * @return
      * @throws Exception
      */
-    Result getExamRecordPaperQuestionDetail(String key, String token, String questionId, String examRecordId) throws Exception;
+    Result getExamRecordPaperQuestionDetail(String key, String token, String questionId, String examRecordId)
+            throws Exception;
 
     /**
      * 保存或更新考生作答的某个试题答案
@@ -145,7 +149,8 @@ public interface CoreOeService {
      * @return
      * @throws Exception
      */
-    Result updateExamRecordPaperQuestionAnswer(String key, String token, Integer order, String studentAnswer) throws Exception;
+    Result updateExamRecordPaperQuestionAnswer(String key, String token, Integer order, String studentAnswer)
+            throws Exception;
 
     /**
      * 当前练习的交卷
@@ -187,7 +192,7 @@ public interface CoreOeService {
      * @return
      * @throws Exception
      */
-    Result getExamRecordTotalInfo(String key, String token, String examRecordId,String fromCache) throws Exception;
+    Result getExamRecordTotalInfo(String key, String token, String examRecordId, String fromCache) throws Exception;
 
     /**
      * 获取作答的题列表
@@ -221,7 +226,8 @@ public interface CoreOeService {
      * @return
      * @throws Exception
      */
-    Result updateExamRecordQuestionAudioPlayTimes(String key, String token, String questionId, String mediaName) throws Exception;
+    Result updateExamRecordQuestionAudioPlayTimes(String key, String token, String questionId, String mediaName)
+            throws Exception;
 
     /**
      * 练习记录配置信息
@@ -232,7 +238,7 @@ public interface CoreOeService {
      * @return
      * @throws Exception
      */
-    Result findExamRecordDataEntity(String key, String token, Long examRecordDataId,String fromCache) throws Exception;
+    Result findExamRecordDataEntity(String key, String token, Long examRecordDataId, String fromCache) throws Exception;
 
     /**
      * 练习记录试题列表
@@ -243,9 +249,11 @@ public interface CoreOeService {
      * @return
      * @throws Exception
      */
-    Result getExamRecordQuestions(String key, String token, Long examRecordDataId,String fromCache) throws Exception;
+    Result getExamRecordQuestions(String key, String token, Long examRecordDataId, String fromCache) throws Exception;
 
-    /**查询考生的考试批次属性集
+    /**
+     * 查询考生的考试批次属性集
+     * 
      * @param key
      * @param token
      * @param examId
@@ -256,12 +264,38 @@ public interface CoreOeService {
     Result getExamPropertyFromCacheByStudentSession(String key, String token, Long examId, String keys)
             throws Exception;
 
-    /**根据Id获取试卷
+    /**
+     * 根据Id获取试卷
+     * 
      * @param key
      * @param token
      * @param paperId
      * @return
      */
-    Result getPaperById(String key, String token, String paperId) throws Exception ;
+    Result getPaperById(String key, String token, String paperId) throws Exception;
+
+    /**获取文件上传签名
+     * @param key
+     * @param token
+     * @param req
+     * @return
+     * @throws Exception
+     */
+    Result getYunSignature(String key, String token, GetYunSignatureReq req) throws Exception;
+
+    /**获取在线考试待考列表
+     * @param key
+     * @param token
+     * @return
+     */
+    Result queryExamList(String key, String token) throws Exception;
+
+    /**获取考试记录信息
+     * @param key
+     * @param token
+     * @param examRecordDataId
+     * @return
+     */
+    Result getEndExamInfo(String key, String token, Long examRecordDataId) throws Exception;
 
 }

+ 28 - 0
src/main/java/cn/com/qmth/examcloud/app/service/impl/CoreOeServiceImpl.java

@@ -12,6 +12,7 @@ import cn.com.qmth.examcloud.app.core.utils.DateUtils;
 import cn.com.qmth.examcloud.app.core.utils.HttpUtils;
 import cn.com.qmth.examcloud.app.core.utils.JsonMapper;
 import cn.com.qmth.examcloud.app.model.Constants;
+import cn.com.qmth.examcloud.app.model.GetYunSignatureReq;
 import cn.com.qmth.examcloud.app.model.Result;
 import cn.com.qmth.examcloud.app.service.CoreOeService;
 import cn.com.qmth.examcloud.app.core.SysProperty;
@@ -266,4 +267,31 @@ public class CoreOeServiceImpl implements CoreOeService {
         Result<String> result = HttpUtils.doGet(requestUrl, key, token);
         return result;
     }
+    
+    @Override
+    public Result getYunSignature(String key, String token, GetYunSignatureReq req) throws Exception {
+        //封装请求参数
+        final String requestUrl = String.format("%s/api/examControl/yunSignature", sysProperty.getCoreOeStudentUrl());
+        RequestBody formBody = new FormBody.Builder()
+                .add("examRecordDataId", req.getExamRecordDataId())
+                .add("order", req.getOrder())
+                .add("fileMd5", req.getFileMd5())
+                .add("fileSuffix", req.getFileSuffix())
+                .add("ext", req.getExt())
+                .build();
+        return HttpUtils.doPost(requestUrl, formBody, key, token);
+    }
+
+    @Override
+    public Result queryExamList(String key, String token) throws Exception {
+        final String requestUrl = String.format("%s/api/examControl/queryExamList", sysProperty.getCoreOeAdminUrl());
+        return HttpUtils.doGet(requestUrl, key, token);
+    }
+
+    @Override
+    public Result getEndExamInfo(String key, String token, Long examRecordDataId) throws Exception {
+        final String requestUrl = String.format("%s/api/examControl/getEndExamInfo?examRecordDataId="+examRecordDataId, sysProperty.getCoreOeStudentUrl());
+        return HttpUtils.doGet(requestUrl, key, token);
+    }
+
 }