mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-06-04 08:38:26 +08:00
增加: 接入Swagger3 [未完成]
This commit is contained in:
@@ -48,15 +48,15 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
||||
@NotNull Object handler) throws Exception {
|
||||
|
||||
// 请求方法类型
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
String reqUri = request.getRequestURI();
|
||||
if (!(handler instanceof HandlerMethod) || !reqUri.startsWith("/api")) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
// 登录权限校验
|
||||
try {
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
Method method = this.obtainAop(handler);
|
||||
String reqUri = request.getRequestURI();
|
||||
this.checkLogin(method, reqUri);
|
||||
} catch (LoginException e) {
|
||||
AjaxResult<Object> result = AjaxResult.failed(e.getCode(), e.getMsg());
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.mdd.admin.config;
|
||||
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
@Configuration
|
||||
@EnableOpenApi
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi(){
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
.apiInfo(apiInfo())
|
||||
.enable(true)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.mdd.admin.controller"))
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo(){
|
||||
return new ApiInfoBuilder()
|
||||
.title("LikeAdmin【后台】接口文档")
|
||||
.description("likeadmin快速开发管理后台")
|
||||
.version(GlobalConfig.version)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,8 @@ spring:
|
||||
mvc:
|
||||
static-path-pattern: /api/static/**
|
||||
throw-exception-if-no-handler-found: true
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher
|
||||
# 数据源配置
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/likeadmin?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
|
||||
|
||||
Reference in New Issue
Block a user