功能开发,加入了昨晚失眠到2点想到的功能,文档大一统指日可待~

This commit is contained in:
暮光:城中城
2018-12-16 22:20:30 +08:00
parent 204ba15e11
commit 3a5702c676
18 changed files with 821 additions and 517 deletions

View File

@@ -33,14 +33,17 @@ public class Application extends SpringBootServletInitializer {
contextPath = (contextPath.length() <= 0 || contextPath.endsWith("/")) ? contextPath : contextPath + "/";
String hostAddress = InetAddress.getLocalHost().getHostAddress();
String serverPort = env.getProperty("server.port");
String urlCtx = hostAddress + ":" + serverPort + "/" + contextPath;
// 三个UI的名字长度惊人的一致肯定是知道我有强迫症
logger.info("\n----------------------------------------------------------\n\t" +
"\t\t地址列表\n\t" +
"文档地址http://{}:{}/{}document.html\n\t" +
//"数据库地址http://{}:{}/{}document.html\n " +
"管理地址http://{}:{}/{}statics/manage/home.html\n" +
"zyplayer-doc-swaggerhttp://{}document.html\n\t" +
"swagger-bootstrap-uihttp://{}doc.html\n\t" +
"springfox-swagger-uihttp://{}swagger-ui.html\n\t" +
//"数据库地址http://{}document.html\n " +
"管理地址http://{}statics/manage/home.html\n" +
"----------------------------------------------------------",
hostAddress, serverPort, contextPath,
hostAddress, serverPort, contextPath
urlCtx, urlCtx, urlCtx, urlCtx
);
}
}

View File

@@ -23,9 +23,9 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
* @since 2018年11月11日
*/
@Configuration
@EnableSwagger2
//@EnableSwagger2
@EnableSwaggerMgUi(
selfDoc = true,// 是否开启自身的文档
selfDoc = false,// 是否开启自身的文档
defaultResources = {// 启动后第一次访问没有数据情况下需要加载进来的swagger-resources地址
//"http://localhost:8080/swagger-resources"
}

View File

@@ -39,7 +39,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
*/
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/statics/lib/**", "/css/**", "/js/**", "/img/**", "/swagger-resources", "/v2/api-docs");
web.ignoring().antMatchers("/statics/lib/**", "/css/**", "/js/**", "/img/**");
}
@Override
@@ -47,7 +47,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
String loginPage = "/statics/manage/login.html";
http.authorizeRequests().antMatchers("/login/**").permitAll()//为了测试其他功能,设置“ /** ”允许所有请求
.antMatchers("/document.html").hasAuthority("DOC_ALL")
.antMatchers("/document.html", "/doc.html").hasAuthority("DOC_ALL")
// 其他地址的访问均需登录
.anyRequest().authenticated().and()
// 添加验证码验证

View File

@@ -15,32 +15,30 @@ import javax.servlet.http.HttpServletResponse;
@Component
public class RequestInfoInterceptor implements HandlerInterceptor {
private static final Logger logger = LoggerFactory.getLogger(RequestInfoInterceptor.class);
private ThreadLocal<Long> startTimeThreadLocal = new ThreadLocal<>();
/**
* 把当前请求记录到下来
*/
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3)
throws Exception {
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3) {
long startTime = startTimeThreadLocal.get();
long totalTime = System.currentTimeMillis() - startTime;// 结束时间
logger.error("总耗时:{}ms URI{}", totalTime, request.getRequestURI());
logger.error("总耗时:{}msURI{}", totalTime, request.getRequestURI());
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object haddler,
ModelAndView modelAndView) throws Exception {
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object haddler, ModelAndView modelAndView) {
}
/**
* 记录请求信息
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) {
startTimeThreadLocal.set(System.currentTimeMillis());
return true;
}
}