deason 7 жил өмнө
parent
commit
3754602484

+ 15 - 0
pom.xml

@@ -60,6 +60,21 @@
             <artifactId>java-sdk</artifactId>
             <version>4.0.1</version>
         </dependency>
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>2.9.2</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>swagger-bootstrap-ui</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <!--<dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>2.9.2</version>
+        </dependency>-->
     </dependencies>
 
     <build>

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

@@ -0,0 +1,60 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-07-17 09:24:41.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.app;
+
+import com.google.common.collect.Lists;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.schema.ModelRef;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Parameter;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.List;
+
+@Configuration
+@EnableSwagger2
+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)
+                .apiInfo(buildApiInfo())
+                .useDefaultResponseMessages(false)
+                .select()
+                //.apis(RequestHandlerSelectors.basePackage(basePackage))
+                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
+                .paths(PathSelectors.any())
+                .build().globalOperationParameters(parameters);
+    }
+
+    public ApiInfo buildApiInfo() {
+        return new ApiInfoBuilder()
+                .title("考生端APP接口文档")
+                .version("1.0")
+                .build();
+    }
+
+}

+ 6 - 0
src/main/java/cn/com/qmth/examcloud/app/controller/v1/ExamAdminRestController.java

@@ -7,14 +7,20 @@
 
 package cn.com.qmth.examcloud.app.controller.v1;
 
+import cn.com.qmth.examcloud.app.service.ExamAdminService;
+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 {
+    @Autowired
+    private ExamAdminService examAdminService;
 
 }

+ 6 - 0
src/main/java/cn/com/qmth/examcloud/app/controller/v1/OnLineExamRestController.java

@@ -7,14 +7,20 @@
 
 package cn.com.qmth.examcloud.app.controller.v1;
 
+import cn.com.qmth.examcloud.app.service.OnLineExamService;
+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 {
+    @Autowired
+    private OnLineExamService onLineExamService;
 
 }

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

@@ -7,14 +7,20 @@
 
 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;
 
 }

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

@@ -7,14 +7,20 @@
 
 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;
 
 }

+ 17 - 0
src/main/java/cn/com/qmth/examcloud/app/controller/v1/UserAuthRestController.java

@@ -7,14 +7,31 @@
 
 package cn.com.qmth.examcloud.app.controller.v1;
 
+import cn.com.qmth.examcloud.app.model.Result;
+import cn.com.qmth.examcloud.app.service.UserAuthService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
  * 认证中心业务服务接口
+ *
+ * @Version v1.0
  */
 @RequestMapping("/api/v1")
 @RestController
+@Api(tags = "认证中心相关接口")
 public class UserAuthRestController {
+    @Autowired
+    private UserAuthService userAuthService;
+
+    @ApiOperation(value = "获取XXX列表")
+    @RequestMapping(value = "/list", method = {RequestMethod.GET, RequestMethod.POST})
+    public Result list() {
+        return new Result().error();
+    }
 
 }

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

@@ -10,6 +10,7 @@ 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;
 import org.springframework.stereotype.Service;
 
 /**
@@ -18,6 +19,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class ExamAdminService {
     private static Logger log = LoggerFactory.getLogger(ExamAdminService.class);
+    @Autowired
+    private PropertyService propertyService;
 
     public Result init() throws Exception {
         log.debug("init...");

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

@@ -10,6 +10,7 @@ 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;
 import org.springframework.stereotype.Service;
 
 /**
@@ -18,6 +19,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class OnLineExamService {
     private static Logger log = LoggerFactory.getLogger(OnLineExamService.class);
+    @Autowired
+    private PropertyService propertyService;
 
     public Result init() throws Exception {
         log.debug("init...");

+ 52 - 0
src/main/java/cn/com/qmth/examcloud/app/service/PropertyService.java

@@ -0,0 +1,52 @@
+/*
+ * *************************************************
+ * Copyright (c) 2018 QMTH. All Rights Reserved.
+ * Created by Deason on 2018-07-17 11:15:46.
+ * *************************************************
+ */
+
+package cn.com.qmth.examcloud.app.service;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * 属性配置服务类
+ */
+@Component
+public class PropertyService {
+    private static Logger log = LoggerFactory.getLogger(PropertyService.class);
+    @Value("{examcloud.exam.admin.url}")
+    private String examAdminUrl;
+    @Value("{examcloud.online.exam.url}")
+    private String onlineExamUrl;
+    @Value("{examcloud.question.pool.url}")
+    private String questionPoolUrl;
+    @Value("{examcloud.user.auth.url}")
+    private String userAuthUrl;
+    @Value("{examcloud.upyun.url}")
+    private String upYunUrl;
+
+    public String getExamAdminUrl() {
+        return examAdminUrl;
+    }
+
+    public String getOnlineExamUrl() {
+        return onlineExamUrl;
+    }
+
+    public String getQuestionPoolUrl() {
+        return questionPoolUrl;
+    }
+
+    public String getUserAuthUrl() {
+        return userAuthUrl;
+    }
+
+    public String getUpYunUrl() {
+        return upYunUrl;
+    }
+
+}

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

@@ -10,6 +10,7 @@ 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;
 import org.springframework.stereotype.Service;
 
 /**
@@ -18,6 +19,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class QuestionPoolService {
     private static Logger log = LoggerFactory.getLogger(QuestionPoolService.class);
+    @Autowired
+    private PropertyService propertyService;
 
     public Result init() throws Exception {
         log.debug("init...");

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

@@ -10,6 +10,7 @@ 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;
 import org.springframework.stereotype.Service;
 
 /**
@@ -18,6 +19,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class UpYunService {
     private static Logger log = LoggerFactory.getLogger(UpYunService.class);
+    @Autowired
+    private PropertyService propertyService;
 
     public Result init() throws Exception {
         log.debug("init...");

+ 3 - 0
src/main/java/cn/com/qmth/examcloud/app/service/UserAuthService.java

@@ -10,6 +10,7 @@ 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;
 import org.springframework.stereotype.Service;
 
 /**
@@ -18,6 +19,8 @@ import org.springframework.stereotype.Service;
 @Service
 public class UserAuthService {
     private static Logger log = LoggerFactory.getLogger(UserAuthService.class);
+    @Autowired
+    private PropertyService propertyService;
 
     public Result init() throws Exception {
         log.debug("init...");