Commit 3e1aa57b authored by AfirSraftGarrier's avatar AfirSraftGarrier

文档说明

parent c039d96e
...@@ -24,8 +24,6 @@ public class CorsConfig implements WebMvcConfigurer { ...@@ -24,8 +24,6 @@ public class CorsConfig implements WebMvcConfigurer {
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
} }
@Override @Override
......
package iot.sixiang.license.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
/**
* Created by m33 on 2022/6/13 20:04
*/
@Configuration
@EnableSwagger2WebMvc
@EnableKnife4j
//@Import(BeanValidatorPluginsConfiguration.class)
public class Knife4jConfig {
@Bean
public Docket docket() {
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
.description("实名制服务器接口文档")
.termsOfServiceUrl("http://web.license.srthinker.com/")
.version("1.0")
.build())
//分组名称
.groupName("iot_license")
.select()
//这里指定Controller扫描包路径
.apis(RequestHandlerSelectors.basePackage("iot.sixiang.license.controller"))
.paths(PathSelectors.any())
.build();
return docket;
}
}
...@@ -20,16 +20,12 @@ public class JwtFilter implements Filter { ...@@ -20,16 +20,12 @@ public class JwtFilter implements Filter {
private static final String url2 = "/resource"; private static final String url2 = "/resource";
private static final String url3 = "/doc.html"; private static final String url3 = "/doc.html";
private static final String url4 = "/v3/swagger-login"; private static final String url4 = "/v2/api-docs";
private static final String url5 = "/swagger-ui.html";
private static final String url6 = "/static";
private static final String url7 = "/swagger-resources"; private static final String url7 = "/swagger-resources";
private static final String url8 = "/webjars/"; private static final String url8 = "/webjars/";
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
} }
@Override @Override
...@@ -46,7 +42,7 @@ public class JwtFilter implements Filter { ...@@ -46,7 +42,7 @@ public class JwtFilter implements Filter {
String token = request.getHeader("authorization"); String token = request.getHeader("authorization");
boolean check = true; boolean check = true;
String uri = request.getRequestURI(); String uri = request.getRequestURI();
if (uri.contains(url1) || uri.contains(url2) || uri.contains(url3) || uri.contains(url4) || uri.contains(url5) || uri.contains(url6) || uri.contains(url7) || uri.contains(url8)) { if (uri.contains(url1) || uri.contains(url2) || uri.contains(url3) || uri.contains(url4) || uri.contains(url7) || uri.contains(url8)) {
check = false; check = false;
} }
if (!check) { if (!check) {
...@@ -74,9 +70,9 @@ public class JwtFilter implements Filter { ...@@ -74,9 +70,9 @@ public class JwtFilter implements Filter {
String userId = userData.get("userId").asString(); String userId = userData.get("userId").asString();
String userName = userData.get("userName").asString(); String userName = userData.get("userName").asString();
String password = userData.get("password").asString(); String password = userData.get("password").asString();
// //拦截器 拿到用户信息,放到request中 // //拦截器 拿到用户信息,放到request中
// request.setAttribute("userName", userName); // request.setAttribute("userName", userName);
// request.setAttribute("password", password); // request.setAttribute("password", password);
LoginUser loginUser = new LoginUser(userId, userName, password); LoginUser loginUser = new LoginUser(userId, userName, password);
UserUtils.setLoginUser(loginUser); UserUtils.setLoginUser(loginUser);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment