weiwenhai 6 rokov pred
rodič
commit
3fb341155c

+ 21 - 0
src/main/java/cn/com/qmth/examcloud/app/controller/PracticeExamRestController.java

@@ -10,6 +10,7 @@ package cn.com.qmth.examcloud.app.controller;
 import cn.com.qmth.examcloud.app.model.Result;
 import cn.com.qmth.examcloud.app.service.ExamAdminService;
 import cn.com.qmth.examcloud.app.service.NetExamService;
+import cn.com.qmth.examcloud.app.service.QuestionPoolService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -31,6 +32,8 @@ public class PracticeExamRestController {
     private ExamAdminService examAdminService;
     @Autowired
     private NetExamService netExamService;
+    @Autowired
+    private QuestionPoolService questionPoolService;
 
     @ApiOperation(value = "获取某考生的“考试批次”列表接口")
     @RequestMapping(value = "/exam/practice/list", method = {RequestMethod.GET, RequestMethod.POST})
@@ -139,5 +142,23 @@ public class PracticeExamRestController {
     public Result getBeforeExamRemark(@RequestHeader String key, @RequestHeader String token, @PathVariable Long examId, @PathVariable String type) throws Exception {
         return examAdminService.getBeforeExamRemark(key, token, examId, type);
     }
+    
+    @ApiOperation(value = "查询练习记录配置信息")
+    @RequestMapping(value = "/exam/practice/end/findExamRecordDataEntity/{examRecordDataId}", method = {RequestMethod.GET, RequestMethod.POST})
+    public Result findExamRecordDataEntity(@RequestHeader String key, @RequestHeader String token, @PathVariable Long examRecordDataId) throws Exception {
+        return netExamService.findExamRecordDataEntity(key, token, examRecordDataId);
+    }
+    
+    @ApiOperation(value = "查询练习记录试题列表")
+    @RequestMapping(value = "/exam/practice/end/findExamRecordDataEntity/{examRecordDataId}", method = {RequestMethod.GET, RequestMethod.POST})
+    public Result getExamRecordQuestions(@RequestHeader String key, @RequestHeader String token, @PathVariable Long examRecordDataId) throws Exception {
+        return netExamService.getExamRecordQuestions(key, token, examRecordDataId);
+    }
 
+    @ApiOperation(value = "查询某个试题内容")
+    @RequestMapping(value = "/exam/practice/end/question", method = {RequestMethod.GET, RequestMethod.POST})
+    public Result getQuestion(@RequestHeader String key, @RequestHeader String token, @RequestParam String courseCode, 
+    		@RequestParam Long examId, @RequestParam String groupCode, @RequestParam String questionId) throws Exception {
+        return questionPoolService.getQuestion(key, token, courseCode, examId, groupCode, questionId);
+    }
 }

+ 23 - 1
src/main/java/cn/com/qmth/examcloud/app/service/NetExamService.java

@@ -228,5 +228,27 @@ public interface NetExamService {
      * @throws Exception
      */
     Result updateExamRecordQuestionAudioPlayTimes(String key, String token, String questionId, String mediaName) throws Exception;
-
+    
+    /**
+     * 练习记录配置信息
+     * 
+     * @param key
+     * @param token
+     * @param examId
+     * @param examRecordDataId
+     * @return
+     * @throws Exception
+     */
+    Result findExamRecordDataEntity(String key, String token, Long examRecordDataId) throws Exception;
+    
+    /**
+     * 练习记录试题列表
+     * 
+     * @param key
+     * @param token
+     * @param examRecordDataId
+     * @return
+     * @throws Exception
+     */
+    Result getExamRecordQuestions(String key, String token, Long examRecordDataId) throws Exception;
 }

+ 10 - 0
src/main/java/cn/com/qmth/examcloud/app/service/QuestionPoolService.java

@@ -37,5 +37,15 @@ public interface QuestionPoolService {
      * @throws Exception
      */
     Result getPaperDetail(String key, String token, String paperId) throws Exception;
+    
+    /**
+     * 获取某个试题的详细信息
+     * 
+     * @param key
+     * @param token
+     * @return
+     * @throws Exception
+     */
+    Result getQuestion(String key, String token, String courseCode, Long examId, String groupCode, String questionId) throws Exception;
 
 }

+ 23 - 0
src/main/java/cn/com/qmth/examcloud/app/service/impl/NetExamServiceImpl.java

@@ -206,4 +206,27 @@ public class NetExamServiceImpl implements NetExamService {
         return HttpUtils.doPost(requestUrl, formBody, key, token);
     }
 
+    @Override
+	public Result findExamRecordDataEntity(String key, String token, Long examRecordDataId) throws Exception {
+		//封装请求参数
+        final String requestUrl = String.format("%s/api/ecs_oe_admin/exam/record/data/findExamRecordDataEntity?examRecordDataId=%s", propertyService.getNetExamUrl(), examRecordDataId);
+        Result<String> result = HttpUtils.doGet(requestUrl, key, token);
+        if (result.isSuccess()) {
+            //过滤掉为空的属性
+            result.setData(HttpUtils.filterNullAttributes(result.getData()));
+        }
+        return result;
+	}
+    
+    @Override
+	public Result getExamRecordQuestions(String key, String token, Long examRecordDataId) throws Exception {
+		//封装请求参数
+        final String requestUrl = String.format("%s/api/ecs_oe_admin/examRecordQuestions/getExamRecordQuestions?examRecordDataId=%s", propertyService.getNetExamUrl(), examRecordDataId);
+        Result<String> result = HttpUtils.doGet(requestUrl, key, token);
+        if (result.isSuccess()) {
+            //过滤掉为空的属性
+            result.setData(HttpUtils.filterNullAttributes(result.getData()));
+        }
+        return result;
+	}
 }

+ 40 - 0
src/main/java/cn/com/qmth/examcloud/app/service/impl/QuestionPoolServiceImpl.java

@@ -8,15 +8,24 @@
 package cn.com.qmth.examcloud.app.service.impl;
 
 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.ResBody;
 import cn.com.qmth.examcloud.app.model.Result;
 import cn.com.qmth.examcloud.app.service.PropertyService;
 import cn.com.qmth.examcloud.app.service.QuestionPoolService;
+import okhttp3.FormBody;
+import okhttp3.MediaType;
+import okhttp3.RequestBody;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * 题库业务服务接口
@@ -49,4 +58,35 @@ public class QuestionPoolServiceImpl implements QuestionPoolService {
         return result;
     }
 
+	@Override
+	public Result getQuestion(String key, String token, String courseCode, Long examId, String groupCode, String questionId) throws Exception {
+		//封装请求参数
+        final String requestUrl = String.format("%s/api/ecs_ques/default_question/question", propertyService.getQuestionPoolUrl());
+        Map<String, Object> params = new HashMap<>();
+        params.put("courseCode", courseCode);
+        params.put("examId", examId);
+        params.put("groupCode", groupCode);
+        params.put("questionId", questionId);
+        String json = new JsonMapper().toJson(params);
+        RequestBody formBody = FormBody.create(MediaType.parse(Constants.CHARSET_JSON_UTF8), json);
+        //发送短信
+        Result<String> result = HttpUtils.doPost(requestUrl, formBody, key, token);
+        return this.parseResult(result);
+	}
+	
+	private Result<String> parseResult(Result<String> result) {
+        if (!result.isSuccess()) {
+            return result;
+        }
+        ResBody body = new JsonMapper().fromJson(result.getData(), ResBody.class);
+        if (body != null && body.getSuccess() != null) {
+            if (body.getSuccess() == true) {
+                return new Result().success();
+            } else {
+                return new Result().error(body.getReturnMsg());
+            }
+        }
+        return result;
+    }
+
 }