deason 7 năm trước cách đây
mục cha
commit
ddb4729b4a

+ 0 - 10
src/main/java/cn/com/qmth/examcloud/app/controller/IndexController.java

@@ -7,12 +7,9 @@
 
 package cn.com.qmth.examcloud.app.controller;
 
-import cn.com.qmth.examcloud.app.exception.ApiException;
-import cn.com.qmth.examcloud.app.model.Result;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
 
 @Controller
 public class IndexController {
@@ -22,11 +19,4 @@ public class IndexController {
         return "index";
     }
 
-    @ResponseBody
-    @RequestMapping(value = "/test", method = {RequestMethod.GET, RequestMethod.POST})
-    public Result test() throws Exception {
-        throw new ApiException("error");
-        //return new Result().error();
-    }
-
 }

+ 14 - 3
src/main/java/cn/com/qmth/examcloud/app/controller/v1/OnLineExamRestController.java → src/main/java/cn/com/qmth/examcloud/app/controller/v1/OfflineExamRestController.java

@@ -7,20 +7,31 @@
 
 package cn.com.qmth.examcloud.app.controller.v1;
 
+import cn.com.qmth.examcloud.app.service.ExamAdminService;
 import cn.com.qmth.examcloud.app.service.OnLineExamService;
+import cn.com.qmth.examcloud.app.service.QuestionPoolService;
+import cn.com.qmth.examcloud.app.service.UpYunService;
+import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
- * 网考业务服务接口
+ * 离线考试相关接口
  *
  * @Version v1.0
  */
-@RequestMapping("/api/v1")
 @RestController
-public class OnLineExamRestController {
+@RequestMapping("/api/v1")
+@Api(tags = "离线考试相关接口")
+public class OfflineExamRestController {
+    @Autowired
+    private ExamAdminService examAdminService;
+    @Autowired
+    private QuestionPoolService questionPoolService;
     @Autowired
     private OnLineExamService onLineExamService;
+    @Autowired
+    private UpYunService upYunService;
 
 }

+ 15 - 3
src/main/java/cn/com/qmth/examcloud/app/controller/v1/ExamAdminRestController.java → src/main/java/cn/com/qmth/examcloud/app/controller/v1/PracticeExamRestController.java

@@ -8,19 +8,31 @@
 package cn.com.qmth.examcloud.app.controller.v1;
 
 import cn.com.qmth.examcloud.app.service.ExamAdminService;
+import cn.com.qmth.examcloud.app.service.OnLineExamService;
+import cn.com.qmth.examcloud.app.service.QuestionPoolService;
+import cn.com.qmth.examcloud.app.service.UpYunService;
+import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
- * 考务业务服务接口
+ * 在线练习相关接口
  *
  * @Version v1.0
  */
-@RequestMapping("/api/v1")
 @RestController
-public class ExamAdminRestController {
+@RequestMapping("/api/v1")
+@Api(tags = "在线练习相关接口")
+public class PracticeExamRestController {
     @Autowired
     private ExamAdminService examAdminService;
+    @Autowired
+    private QuestionPoolService questionPoolService;
+    @Autowired
+    private OnLineExamService onLineExamService;
+    @Autowired
+    private UpYunService upYunService;
+
 
 }

+ 0 - 26
src/main/java/cn/com/qmth/examcloud/app/controller/v1/QuestionPoolRestController.java

@@ -1,26 +0,0 @@
-/*
- * *************************************************
- * Copyright (c) 2018 QMTH. All Rights Reserved.
- * Created by Deason on 2018-07-16 17:53:04.
- * *************************************************
- */
-
-package cn.com.qmth.examcloud.app.controller.v1;
-
-import cn.com.qmth.examcloud.app.service.QuestionPoolService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * 题库业务服务接口
- *
- * @Version v1.0
- */
-@RequestMapping("/api/v1")
-@RestController
-public class QuestionPoolRestController {
-    @Autowired
-    private QuestionPoolService questionPoolService;
-
-}

+ 0 - 26
src/main/java/cn/com/qmth/examcloud/app/controller/v1/UpYunRestController.java

@@ -1,26 +0,0 @@
-/*
- * *************************************************
- * Copyright (c) 2018 QMTH. All Rights Reserved.
- * Created by Deason on 2018-07-16 17:54:13.
- * *************************************************
- */
-
-package cn.com.qmth.examcloud.app.controller.v1;
-
-import cn.com.qmth.examcloud.app.service.UpYunService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * 又拍云文件服务接口
- *
- * @Version v1.0
- */
-@RequestMapping("/api/v1")
-@RestController
-public class UpYunRestController {
-    @Autowired
-    private UpYunService upYunService;
-
-}

+ 16 - 4
src/main/java/cn/com/qmth/examcloud/app/controller/v1/UserAuthRestController.java

@@ -15,25 +15,37 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 /**
- * 认证中心业务服务接口
+ * 认证中心相关接口
  *
  * @Version v1.0
  */
-@RequestMapping("/api/v1")
 @RestController
+@RequestMapping("/api/v1")
 @Api(tags = "认证中心相关接口")
 public class UserAuthRestController {
     @Autowired
     private UserAuthService userAuthService;
 
     @ApiOperation(value = "登录接口")
-    @RequestMapping(value = "user/login", method = {RequestMethod.GET, RequestMethod.POST})
+    @RequestMapping(value = "/user/login", method = {RequestMethod.GET, RequestMethod.POST})
     public Result login(@RequestParam String account, @RequestParam String password, @RequestParam Long rootOrgId) throws Exception {
         return userAuthService.login(account, password, rootOrgId);
     }
 
+    @ApiOperation(value = "登出接口")
+    @RequestMapping(value = "/user/logout", method = {RequestMethod.GET, RequestMethod.POST})
+    public Result logout(@RequestHeader String key, @RequestHeader String token) throws Exception {
+        return userAuthService.logout(key, token);
+    }
+
+    @ApiOperation(value = "获取用户信息接口")
+    @RequestMapping(value = "/user/info", method = {RequestMethod.GET, RequestMethod.POST})
+    public Result getUserInfo(@RequestHeader String key, @RequestHeader String token) throws Exception {
+        return userAuthService.getUserInfo(key, token);
+    }
+
     @ApiOperation(value = "修改密码接口")
-    @RequestMapping(value = "user/update/password", method = {RequestMethod.GET, RequestMethod.POST})
+    @RequestMapping(value = "/user/update/password", method = {RequestMethod.GET, RequestMethod.POST})
     public Result updatePassword(@RequestHeader String key, @RequestHeader String token, @RequestParam Long userId, @RequestParam String password) throws Exception {
         return userAuthService.updatePassword(key, token, userId, password);
     }

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

@@ -8,11 +8,16 @@
 package cn.com.qmth.examcloud.app.service;
 
 import cn.com.qmth.examcloud.app.model.Result;
+import cn.com.qmth.examcloud.app.utils.HttpUtils;
+import okhttp3.Request;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import static cn.com.qmth.examcloud.app.model.Constants.PARAM_KEY;
+import static cn.com.qmth.examcloud.app.model.Constants.PARAM_TOKEN;
+
 /**
  * 考务业务服务接口
  */
@@ -22,9 +27,17 @@ public class ExamAdminService {
     @Autowired
     private PropertyService propertyService;
 
-    public Result init() throws Exception {
-        log.debug("init...");
-        return new Result().success();
+    public Result demo(String key, String token, String userId, String password) throws Exception {
+        final String requestUrl = String.format(propertyService.getUserAuthUrl() + "/api/ecs_core/user/password?userId=%s&password=%s", userId, password);
+        //封装请求参数
+        Request request = new Request.Builder()
+                .url(requestUrl)
+                .get()
+                .addHeader(PARAM_KEY, key)
+                .addHeader(PARAM_TOKEN, token)
+                .build();
+        //执行请求
+        return HttpUtils.call(request);
     }
 
 }

+ 0 - 5
src/main/java/cn/com/qmth/examcloud/app/service/OnLineExamService.java

@@ -7,7 +7,6 @@
 
 package cn.com.qmth.examcloud.app.service;
 
-import cn.com.qmth.examcloud.app.model.Result;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,9 +21,5 @@ public class OnLineExamService {
     @Autowired
     private PropertyService propertyService;
 
-    public Result init() throws Exception {
-        log.debug("init...");
-        return new Result().success();
-    }
 
 }

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

@@ -7,7 +7,6 @@
 
 package cn.com.qmth.examcloud.app.service;
 
-import cn.com.qmth.examcloud.app.model.Result;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,9 +21,4 @@ public class QuestionPoolService {
     @Autowired
     private PropertyService propertyService;
 
-    public Result init() throws Exception {
-        log.debug("init...");
-        return new Result().success();
-    }
-
 }

+ 0 - 6
src/main/java/cn/com/qmth/examcloud/app/service/UpYunService.java

@@ -7,7 +7,6 @@
 
 package cn.com.qmth.examcloud.app.service;
 
-import cn.com.qmth.examcloud.app.model.Result;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,9 +21,4 @@ public class UpYunService {
     @Autowired
     private PropertyService propertyService;
 
-    public Result init() throws Exception {
-        log.debug("init...");
-        return new Result().success();
-    }
-
 }

+ 22 - 10
src/main/java/cn/com/qmth/examcloud/app/service/UserAuthService.java

@@ -63,16 +63,24 @@ public class UserAuthService {
         }
     }
 
-    public Result updatePassword(String key, String token, Long userId, String password) throws Exception {
-        final String requestUrl = propertyService.getUserAuthUrl() + "/api/ecs_core/user/password";
-        //封装请求参数
-        RequestBody formBody = new FormBody.Builder()
-                .add("userId", String.valueOf(userId))
-                .add("password", password)
+    public Result logout(String key, String token) throws Exception {
+        final String requestUrl = propertyService.getUserAuthUrl() + "/api/ecs_core/auth/logout";
+        Request request = new Request.Builder()
+                .url(requestUrl)
+                .get()
+                .addHeader(PARAM_KEY, key)
+                .addHeader(PARAM_TOKEN, token)
                 .build();
+        //执行请求
+        return HttpUtils.call(request);
+    }
+
+
+    public Result getUserInfo(String key, String token) throws Exception {
+        final String requestUrl = propertyService.getUserAuthUrl() + "/api/ecs_core/auth/getLoginUser";
         Request request = new Request.Builder()
                 .url(requestUrl)
-                .put(formBody)
+                .get()
                 .addHeader(PARAM_KEY, key)
                 .addHeader(PARAM_TOKEN, token)
                 .build();
@@ -80,12 +88,16 @@ public class UserAuthService {
         return HttpUtils.call(request);
     }
 
-    public Result demo(String key, String token, String userId, String password) throws Exception {
-        final String requestUrl = String.format(propertyService.getUserAuthUrl() + "/api/ecs_core/user/password?userId=%s&password=%s", userId, password);
+    public Result updatePassword(String key, String token, Long userId, String password) throws Exception {
+        final String requestUrl = propertyService.getUserAuthUrl() + "/api/ecs_core/user/password";
         //封装请求参数
+        RequestBody formBody = new FormBody.Builder()
+                .add("userId", String.valueOf(userId))
+                .add("password", password)
+                .build();
         Request request = new Request.Builder()
                 .url(requestUrl)
-                .get()
+                .put(formBody)
                 .addHeader(PARAM_KEY, key)
                 .addHeader(PARAM_TOKEN, token)
                 .build();