浏览代码

Merge branch 'wheng' of wuheng/eas-system into master

wuheng 1 年之前
父节点
当前提交
4b1ef7905a

+ 6 - 3
controller/src/main/java/com/koobietech/eas/ControllerApplication.java

@@ -4,12 +4,15 @@ import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.FilterType;
 
 
 @SpringBootApplication
 @SpringBootApplication
 @MapperScan(basePackages = {"com.koobietech.eas.mbg.mapper"})
 @MapperScan(basePackages = {"com.koobietech.eas.mbg.mapper"})
-@ComponentScan(basePackages = {
-        "com.koobietech.eas.controller", "com.koobietech.eas.security",
-        "com.koobietech.eas.service", "com.koobietech.eas.common"})
+@ComponentScan(basePackages = {"com.koobietech.eas"}, excludeFilters = {
+        @ComponentScan.Filter(type = FilterType.REGEX, pattern  = {
+                "com.koobietech.eas.mbg.+"
+        })
+})
 public class ControllerApplication {
 public class ControllerApplication {
 
 
     public static void main(String[] args) {
     public static void main(String[] args) {

+ 42 - 11
controller/src/main/java/com/koobietech/eas/config/SwaggerConfiguration.java

@@ -1,28 +1,59 @@
 package com.koobietech.eas.config;
 package com.koobietech.eas.config;
 
 
+import io.swagger.v3.oas.models.Components;
 import io.swagger.v3.oas.models.OpenAPI;
 import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Contact;
 import io.swagger.v3.oas.models.info.Info;
 import io.swagger.v3.oas.models.info.Info;
 import io.swagger.v3.oas.models.info.License;
 import io.swagger.v3.oas.models.info.License;
+import io.swagger.v3.oas.models.security.*;
 import org.springdoc.core.GroupedOpenApi;
 import org.springdoc.core.GroupedOpenApi;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+import java.util.Arrays;
+import java.util.HashMap;
 
 
 @Configuration
 @Configuration
+@Profile("dev")
 public class SwaggerConfiguration {
 public class SwaggerConfiguration {
+
     @Bean
     @Bean
-    public GroupedOpenApi baseRestApi() {
-        return GroupedOpenApi.builder()
-                .group("爱扣钉教务系统接口文档")
-                .packagesToScan("com.koobietech.eas").build();
+    public OpenAPI baseApi(@Value("${springdoc.version}") String appVersion){
+        OpenAPI openAPI = new OpenAPI();
+        //基本信息
+        Info info = new Info().title("爱扣钉教务接口")
+            .description("爱扣钉教务接口API文档,openapi3.0 接口,用于前端对接")
+            .version(appVersion)
+            .contact(new Contact().name("王雁"))
+            .license(new License().name("使用请遵守 Apache 2.0 授权协议")
+            .url("http://edu.koobietech.com"));
+        openAPI.info(info);
+        //授权信息
+        SecurityScheme securityToken = new SecurityScheme()
+                .type(SecurityScheme.Type.HTTP)
+                .scheme("bearer")
+                .bearerFormat("JWT")
+                .in(SecurityScheme.In.HEADER)
+                .name("Authorization");
+        openAPI.components(new Components().securitySchemes(new HashMap<>(){{
+            put("Authorization", securityToken);
+        }}));
+        openAPI.addSecurityItem(new SecurityRequirement().addList("Authorization"));
+        return openAPI;
     }
     }
 
 
-
     @Bean
     @Bean
-    public OpenAPI springShopOpenApi() {
-        return new OpenAPI()
-                .info(new Info().title("爱扣钉教务接口文档")
-                        .description("爱扣钉教务接口文档,openapi3.0 接口,用于前端对接")
-                        .version("v0.0.1")
-                        .license(new License().name("使用请遵守APACHE2.0授权协议").url("http://edu.koobietech.com")));
+    public GroupedOpenApi baseRestApi() {
+        return GroupedOpenApi.builder()
+            .group("爱扣钉学员接口")
+            .pathsToMatch("/**")
+            .packagesToScan(new String[]{
+                    "com.koobietech.eas.controller", "com.koobietech.eas.dao",
+                    "com.koobietech.eas.mbg"
+                }
+            )
+            .build();
     }
     }
 }
 }

+ 0 - 2
controller/src/main/java/com/koobietech/eas/controller/EasUserController.java

@@ -1,8 +1,6 @@
 package com.koobietech.eas.controller;
 package com.koobietech.eas.controller;
 
 
 import com.koobietech.eas.dao.dto.TestDto;
 import com.koobietech.eas.dao.dto.TestDto;
-import com.koobietech.eas.mbg.mapper.EasSysPermissionMapper;
-import com.koobietech.eas.mbg.model.EasSysPermission;
 import com.koobietech.eas.mbg.model.EasSysStudent;
 import com.koobietech.eas.mbg.model.EasSysStudent;
 import com.koobietech.eas.service.DemoService;
 import com.koobietech.eas.service.DemoService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Operation;

+ 11 - 2
controller/src/main/resources/application-dev.yaml

@@ -1,5 +1,5 @@
 server:
 server:
-  port: 8081
+  port: 8080
 spring:
 spring:
   datasource:
   datasource:
     url: jdbc:mysql://39.105.160.25:10992/eas?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true&tinyInt1isBit=false
     url: jdbc:mysql://39.105.160.25:10992/eas?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=true&tinyInt1isBit=false
@@ -11,8 +11,17 @@ spring:
     database: 9
     database: 9
     password:
     password:
     port: 26379
     port: 26379
-
   security:
   security:
     user:
     user:
       name: admin
       name: admin
       password: 123456
       password: 123456
+springdoc:
+  version: v0.0.1
+  api-docs:
+    enabled: true
+  swagger-ui:
+    enabled: true
+knife4j:
+  enable: true
+  setting:
+    language: zh_cn

+ 10 - 10
controller/src/main/resources/application.yaml

@@ -3,34 +3,34 @@ server:
 spring:
 spring:
   profiles:
   profiles:
     active: dev
     active: dev
-  configuration:
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-    call-setters-on-nulls: true
-    map-underscore-to-camel-case: true
-
+  main:
+    allow-circular-references: true
   servlet:
   servlet:
     multipart:
     multipart:
       max-file-size: 100MB
       max-file-size: 100MB
       max-request-size: 100MB
       max-request-size: 100MB
       enabled: true
       enabled: true
-
   jackson:
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss
     date-format: yyyy-MM-dd HH:mm:ss
     time-zone: GMT+8
     time-zone: GMT+8
-
   redis:
   redis:
     host: localhost
     host: localhost
     database: 0
     database: 0
     password:
     password:
     port: 6379
     port: 6379
-
+springdoc:
+  api-docs:
+    enabled: false
+  swagger-ui:
+    enabled: false
+  version: v0.0.1
+knife4j:
+  enable: false
 security:
 security:
   url:
   url:
     ignored:
     ignored:
       - /**
       - /**
-
 eas:
 eas:
   jwt-secret-key: 123456
   jwt-secret-key: 123456
   jwt-expires-date: 1
   jwt-expires-date: 1
   password-sign-key: eas-key-password
   password-sign-key: eas-key-password
-

+ 7 - 3
pom.xml

@@ -32,15 +32,19 @@
         <javax.servlet-api.version>4.0.1</javax.servlet-api.version>
         <javax.servlet-api.version>4.0.1</javax.servlet-api.version>
         <spring-data-redis.version>2.7.3</spring-data-redis.version>
         <spring-data-redis.version>2.7.3</spring-data-redis.version>
         <knife4j.version>4.1.0</knife4j.version>
         <knife4j.version>4.1.0</knife4j.version>
+        <pagehelper.starter.version>1.3.1</pagehelper.starter.version>
     </properties>
     </properties>
     <dependencyManagement>
     <dependencyManagement>
         <dependencies>
         <dependencies>
+            <dependency>
+                <groupId>com.github.pagehelper</groupId>
+                <artifactId>pagehelper-spring-boot-starter</artifactId>
+                <version>${pagehelper.starter.version}</version>
+            </dependency>
             <dependency>
             <dependency>
                 <groupId>com.github.xiaoymin</groupId>
                 <groupId>com.github.xiaoymin</groupId>
-                <artifactId>knife4j-dependencies</artifactId>
+                <artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
                 <version>${knife4j.version}</version>
                 <version>${knife4j.version}</version>
-                <type>pom</type>
-                <scope>import</scope>
             </dependency>
             </dependency>
             <dependency>
             <dependency>
                 <groupId>org.springframework.boot</groupId>
                 <groupId>org.springframework.boot</groupId>

+ 4 - 0
service/pom.xml

@@ -8,6 +8,10 @@
     <description>service</description>
     <description>service</description>
 
 
     <dependencies>
     <dependencies>
+        <dependency>
+            <groupId>com.github.pagehelper</groupId>
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+        </dependency>
         <dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <groupId>org.springframework</groupId>
             <artifactId>spring-beans</artifactId>
             <artifactId>spring-beans</artifactId>