style: 修改部分代码格式

This commit is contained in:
禾几海
2020-08-30 14:17:34 +08:00
parent b55a50d548
commit c17b56b436
3 changed files with 16 additions and 17 deletions

View File

@@ -31,9 +31,7 @@ public class RedisConfig extends CachingConfigurerSupport {
@Override @Override
@Bean @Bean
public KeyGenerator keyGenerator() { public KeyGenerator keyGenerator() {
return new KeyGenerator() { return (target, method, params) -> {
@Override
public Object generate(Object target, Method method, Object... params) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String name = target.getClass().getName(); String name = target.getClass().getName();
sb.append(name.substring(name.lastIndexOf(".") + 1)); sb.append(name.substring(name.lastIndexOf(".") + 1));
@@ -43,7 +41,6 @@ public class RedisConfig extends CachingConfigurerSupport {
sb.append("-").append(obj.toString()); sb.append("-").append(obj.toString());
} }
return sb.toString(); return sb.toString();
}
}; };
} }

View File

@@ -25,7 +25,6 @@ public class SessionListener implements HttpSessionListener {
@Override @Override
public void sessionCreated(HttpSessionEvent se) { public void sessionCreated(HttpSessionEvent se) {
// TODO : can move 'visit' api to here
se.getSession().setAttribute("visitDetail", new HashMap<String, Integer>()); se.getSession().setAttribute("visitDetail", new HashMap<String, Integer>());
// 10s for debug // 10s for debug
// se.getSession().setMaxInactiveInterval(10); // se.getSession().setMaxInactiveInterval(10);
@@ -44,9 +43,7 @@ public class SessionListener implements HttpSessionListener {
sb.append("\t登录情况 => "); sb.append("\t登录情况 => ");
String email = (String) se.getSession().getAttribute("email"); String email = (String) se.getSession().getAttribute("email");
sb.append(email == null ? "游客访问" : email); sb.append(email == null ? "游客访问" : email);
visitDetail.forEach((s, integer) -> { visitDetail.forEach((s, integer) -> sb.append("\n").append("Method:[").append(s.split(":")[1]).append("]\tTimes:[").append(integer).append("]\tPath:[").append(s.split(":")[0]).append("]"));
sb.append("\n").append("Method:[").append(s.split(":")[1]).append("]\tTimes:[").append(integer).append("]\tPath:[").append(s.split(":")[0]).append("]");
});
log.info(sb.toString()); log.info(sb.toString());
} }
} }

View File

@@ -83,7 +83,12 @@ public class ExceptionHandle {
simpleMailMessage.setTo("a@celess.cn"); simpleMailMessage.setTo("a@celess.cn");
simpleMailMessage.setSubject("服务器出现了错误"); simpleMailMessage.setSubject("服务器出现了错误");
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
msg.append("requirePath:\n").append(request.getRequestURL().toString()).append("?").append(request.getQueryString()).append("\n\n\n"); String queryString = request.getQueryString();
msg.append("requirePath:\n").append(request.getRequestURL().toString());
if (queryString != null) {
msg.append("?").append(queryString);
}
msg.append("\n\n\n");
msg.append("msg:\n").append(e.getMessage()).append("\n\n\n"); msg.append("msg:\n").append(e.getMessage()).append("\n\n\n");
msg.append("date:\n").append(DateFormatUtil.getNow()).append("\n\n\n"); msg.append("date:\n").append(DateFormatUtil.getNow()).append("\n\n\n");
msg.append("from:\n").append(request.getHeader("User-Agent")).append("\n\n\n"); msg.append("from:\n").append(request.getHeader("User-Agent")).append("\n\n\n");