deason 7 年 前
コミット
9200b4949f

+ 0 - 14
src/main/java/cn/com/qmth/examcloud/app/SwaggerConfig.java

@@ -24,28 +24,14 @@ public class SwaggerConfig {
 
     @Bean
     public Docket buildDocket() {
-        //定义要生成API文档的基础包
-        String basePackage = "cn.com.qmth.examcloud.app.controller";
-        //全局参数
-        /*
-        List<Parameter> parameters = Lists.newArrayList();
-        ParameterBuilder key = new ParameterBuilder();
-        key.name("key").modelRef(new ModelRef("String")).parameterType("header").build();
-        parameters.add(key.build());
-        ParameterBuilder token = new ParameterBuilder();
-        token.name("token").modelRef(new ModelRef("String")).parameterType("header").build();
-        parameters.add(token.build());
-        */
         return new Docket(DocumentationType.SWAGGER_2)
                 .groupName("Version 1.0")
                 .apiInfo(buildApiInfo())
                 .useDefaultResponseMessages(false)
                 .select()
-                //.apis(RequestHandlerSelectors.basePackage(basePackage))
                 .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                 .paths(PathSelectors.any())
                 .build();
-        //.build().globalOperationParameters(parameters);
     }
 
     public ApiInfo buildApiInfo() {

+ 1 - 0
src/main/java/cn/com/qmth/examcloud/app/controller/v1/OfflineExamRestController.java

@@ -67,6 +67,7 @@ public class OfflineExamRestController {
     @ApiOperation(value = "获取某份试卷的详细信息接口")
     @RequestMapping(value = "/paper/detail", method = {RequestMethod.GET, RequestMethod.POST})
     public Result getPaperDetail(@RequestHeader String key, @RequestHeader String token, @RequestParam String paperId) throws Exception {
+        //todo format result
         return questionPoolService.getPaperDetail(key, token, paperId);
     }
 

+ 2 - 1
src/main/java/cn/com/qmth/examcloud/app/controller/v1/PracticeExamRestController.java

@@ -32,6 +32,7 @@ public class PracticeExamRestController {
     @ApiOperation(value = "获取某考生的“考试批次”列表接口")
     @RequestMapping(value = "/exam/practice/list", method = {RequestMethod.GET, RequestMethod.POST})
     public Result getPracticeExamList(@RequestHeader String key, @RequestHeader String token, @RequestParam String studentId) throws Exception {
+        //todo format result
         return examAdminService.getPracticeExamList(key, token, studentId);
     }
 
@@ -56,7 +57,7 @@ public class PracticeExamRestController {
     @ApiOperation(value = "获取当前练习的试卷大题结构信息接口")
     @RequestMapping(value = "/exam/record/paper/struct/list", method = {RequestMethod.GET, RequestMethod.POST})
     public Result getExamRecordPaperStructList(@RequestHeader String key, @RequestHeader String token, @RequestParam String examRecordId) throws Exception {
-        return netExamService.getExamRecordPaperStructList(key, token, examRecordId);
+        return netExamService.getExamRecordPaperStructList(key, token, examRecordId);//todo
     }
 
     @ApiOperation(value = "获取当前练习的考试基本信息接口")

+ 1 - 0
src/main/java/cn/com/qmth/examcloud/app/model/Constants.java

@@ -22,6 +22,7 @@ public interface Constants {
     String DEFAULT_ACCOUNT_TYPE = "COMMON_LOGIN_NAME";
 
     /* 常用状态码 */
+    String CODE_0 = "0";//错误
     String CODE_200 = "200";//成功
     String CODE_500 = "500";//失败
     String CODE_403 = "403";//认证失败

+ 18 - 0
src/main/java/cn/com/qmth/examcloud/app/model/ResBody.java

@@ -13,6 +13,8 @@ public class ResBody implements Serializable {
     private static final long serialVersionUID = 1L;
     private String code;//状态码
     private String desc;//描述信息
+    private String errorMsg;
+    private String content;
 
     public String getCode() {
         return code;
@@ -30,4 +32,20 @@ public class ResBody implements Serializable {
         this.desc = desc;
     }
 
+    public String getErrorMsg() {
+        return errorMsg;
+    }
+
+    public void setErrorMsg(String errorMsg) {
+        this.errorMsg = errorMsg;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
 }

+ 2 - 2
src/main/java/cn/com/qmth/examcloud/app/model/Result.java

@@ -20,8 +20,8 @@ public class Result<T> implements Serializable {
 
     public static String DESC_200 = "请求成功!";
     public static String DESC_500 = "请求失败!";
-    public static String DESC_403 = "无效Token,请先登录!";
-    public static String DESC_404 = "请求地址不存在!";
+    public static String DESC_403 = "无效认证信息,请先登录!";
+    public static String DESC_404 = "请求地址或参数错误!";
 
     public Result() {
 

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

@@ -28,7 +28,7 @@ public class ExamAdminService {
     private PropertyService propertyService;
 
     public Result getPracticeExamList(String key, String token, String studentId) throws Exception {
-        final String requestUrl = String.format(propertyService.getUserAuthUrl() + "/api/ecs_core/user/password?userId=%s", studentId);
+        final String requestUrl = String.format(propertyService.getExamAdminUrl() + "/api/ecs_exam_work/exam_student/query?student_id=%s", studentId);
         //封装请求参数
         Request request = new Request.Builder()
                 .url(requestUrl)

+ 30 - 3
src/main/java/cn/com/qmth/examcloud/app/service/NetExamService.java

@@ -104,15 +104,42 @@ public class NetExamService {
     }
 
     public Result getPracticeExamCourseList(String key, String token, String examId) throws Exception {
-        return null;
+        final String requestUrl = String.format(propertyService.getNetExamUrl() + "/api/practice_course?examId=%s", examId);
+        //封装请求参数
+        Request request = new Request.Builder()
+                .url(requestUrl)
+                .get()
+                .addHeader(PARAM_KEY, key)
+                .addHeader(PARAM_TOKEN, token)
+                .build();
+        //执行请求
+        return HttpUtils.call(request);
     }
 
     public Result getExamRecordHeartbeat(String key, String token, String examRecordId) throws Exception {
-        return null;
+        final String requestUrl = String.format(propertyService.getNetExamUrl() + "/api/exam_control/heartbeat?examRecordId=%s", examRecordId);
+        //封装请求参数
+        Request request = new Request.Builder()
+                .url(requestUrl)
+                .get()
+                .addHeader(PARAM_KEY, key)
+                .addHeader(PARAM_TOKEN, token)
+                .build();
+        //执行请求
+        return HttpUtils.call(request);
     }
 
     public Result startPracticeExamRecord(String key, String token, String examStudentId) throws Exception {
-        return null;
+        final String requestUrl = String.format(propertyService.getNetExamUrl() + "/api/exam_control/start?stu_exam_info_id=%s", examStudentId);
+        //封装请求参数
+        Request request = new Request.Builder()
+                .url(requestUrl)
+                .get()
+                .addHeader(PARAM_KEY, key)
+                .addHeader(PARAM_TOKEN, token)
+                .build();
+        //执行请求
+        return HttpUtils.call(request);
     }
 
     public Result getExamRecordPaperStructList(String key, String token, String examRecordId) throws Exception {

+ 3 - 0
src/main/java/cn/com/qmth/examcloud/app/utils/HttpUtils.java

@@ -33,6 +33,9 @@ public class HttpUtils {
                 if (Constants.CODE_404.equals(body.getCode())) {
                     return new Result().noFoundError();
                 }
+                if (Constants.CODE_0.equals(body.getCode())) {
+                    return new Result().error(body.getErrorMsg());
+                }
                 return new Result().error(body.getDesc());
             }
             return new Result().error(bodyStr);