mirror of https://gitee.com/xiaonuobase/snowy
【更新】druid监控页面去除广告,操作日志柱状图只查询必要字段,否则会很慢
parent
df6b216c7e
commit
9cd56c69cf
|
@ -144,7 +144,10 @@ public class DevLogServiceImpl extends ServiceImpl<DevLogMapper, DevLog> impleme
|
||||||
public List<DevLogOpBarChartDataResult> opLogBarChartData() {
|
public List<DevLogOpBarChartDataResult> opLogBarChartData() {
|
||||||
DateTime lastWeek = DateUtil.lastWeek();
|
DateTime lastWeek = DateUtil.lastWeek();
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
Map<String, List<JSONObject>> listMap = this.list(new LambdaQueryWrapper<DevLog>().in(DevLog::getCategory, DevLogCategoryEnum.OPERATE.getValue(),
|
Map<String, List<JSONObject>> listMap = this.list(new LambdaQueryWrapper<DevLog>().select(DevLog::getId,
|
||||||
|
DevLog::getName,DevLog::getOpIp, DevLog::getOpAddress, DevLog::getCategory, DevLog::getClassName,
|
||||||
|
DevLog::getMethodName, DevLog::getOpTime, DevLog::getOpUser)
|
||||||
|
.in(DevLog::getCategory, DevLogCategoryEnum.OPERATE.getValue(),
|
||||||
DevLogCategoryEnum.EXCEPTION.getValue()).between(DevLog::getOpTime, lastWeek, now).orderByAsc(DevLog::getOpTime))
|
DevLogCategoryEnum.EXCEPTION.getValue()).between(DevLog::getOpTime, lastWeek, now).orderByAsc(DevLog::getOpTime))
|
||||||
.stream().map(devLog -> JSONUtil.parseObj(devLog).set("date", DateUtil.formatDate(devLog.getOpTime())))
|
.stream().map(devLog -> JSONUtil.parseObj(devLog).set("date", DateUtil.formatDate(devLog.getOpTime())))
|
||||||
.collect(Collectors.groupingBy(jsonObject -> jsonObject.getStr("date")));
|
.collect(Collectors.groupingBy(jsonObject -> jsonObject.getStr("date")));
|
||||||
|
|
|
@ -12,7 +12,12 @@
|
||||||
*/
|
*/
|
||||||
package vip.xiaonuo.core.config;
|
package vip.xiaonuo.core.config;
|
||||||
|
|
||||||
|
import com.alibaba.druid.spring.boot3.autoconfigure.properties.DruidStatProperties;
|
||||||
|
import com.alibaba.druid.util.Utils;
|
||||||
|
import jakarta.servlet.Filter;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,16 +27,15 @@ import org.springframework.context.annotation.Configuration;
|
||||||
* @date 2023/06/30
|
* @date 2023/06/30
|
||||||
**/
|
**/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnProperty(name = "spring.datasource.druid.web-stat-filter.enabled", havingValue = "true")
|
@ConditionalOnProperty(name = "spring.datasource.druid.stat-view-servlet.enabled", havingValue = "true")
|
||||||
public class DruidConfigure {
|
public class DruidConfigure {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 去除druid监控页面广告
|
* 去除druid监控页面广告
|
||||||
*/
|
*/
|
||||||
/*@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
@Bean
|
@Bean
|
||||||
public FilterRegistrationBean removeDruidAdFilterRegistrationBean(DruidStatProperties properties)
|
public FilterRegistrationBean removeDruidAdFilterRegistrationBean(DruidStatProperties properties) {
|
||||||
{
|
|
||||||
// 获取web监控页面的参数
|
// 获取web监控页面的参数
|
||||||
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
|
DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
|
||||||
// 提取common.js的配置路径
|
// 提取common.js的配置路径
|
||||||
|
@ -39,34 +43,20 @@ public class DruidConfigure {
|
||||||
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
|
String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
|
||||||
final String filePath = "support/http/resources/js/common.js";
|
final String filePath = "support/http/resources/js/common.js";
|
||||||
// 创建filter进行过滤
|
// 创建filter进行过滤
|
||||||
Filter filter = new Filter()
|
Filter filter = (request, response, chain) -> {
|
||||||
{
|
chain.doFilter(request, response);
|
||||||
@Override
|
// 重置缓冲区,响应头不会被重置
|
||||||
public void init(FilterConfig filterConfig) throws ServletException
|
response.resetBuffer();
|
||||||
{
|
// 获取common.js
|
||||||
}
|
String text = Utils.readFromResource(filePath);
|
||||||
@Override
|
// 正则替换banner, 除去底部的广告信息
|
||||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
text = text.replaceAll("<a.*?banner\"></a><br/>", "");
|
||||||
throws IOException, ServletException
|
text = text.replaceAll("powered.*?shrek.wang</a>", "");
|
||||||
{
|
response.getWriter().write(text);
|
||||||
chain.doFilter(request, response);
|
|
||||||
// 重置缓冲区,响应头不会被重置
|
|
||||||
response.resetBuffer();
|
|
||||||
// 获取common.js
|
|
||||||
String text = Utils.readFromResource(filePath);
|
|
||||||
// 正则替换banner, 除去底部的广告信息
|
|
||||||
text = text.replaceAll("<a.*?banner\"></a><br/>", "");
|
|
||||||
text = text.replaceAll("powered.*?shrek.wang</a>", "");
|
|
||||||
response.getWriter().write(text);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void destroy()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
|
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
|
||||||
registrationBean.setFilter(filter);
|
registrationBean.setFilter(filter);
|
||||||
registrationBean.addUrlPatterns(commonJsPattern);
|
registrationBean.addUrlPatterns(commonJsPattern);
|
||||||
return registrationBean;
|
return registrationBean;
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue