新增日志配置,分页新增sql方法
This commit is contained in:
Binary file not shown.
@@ -54,4 +54,8 @@ public class WebPageInfo implements Serializable {
|
|||||||
public static boolean hasSort(WebPageInfo webPageInfo) {
|
public static boolean hasSort(WebPageInfo webPageInfo) {
|
||||||
return !StringUtils.isBlank(webPageInfo.getSortField());
|
return !StringUtils.isBlank(webPageInfo.getSortField());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSortSql() {
|
||||||
|
return this.sortField + " " + this.order;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.aspectj.lang.annotation.Before;
|
|||||||
import org.aspectj.lang.annotation.Pointcut;
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
@@ -21,16 +22,21 @@ import java.util.Enumeration;
|
|||||||
@Component
|
@Component
|
||||||
public class WebPatternlLog {
|
public class WebPatternlLog {
|
||||||
|
|
||||||
|
@Value("${show-controller-log}")
|
||||||
|
public boolean flag;
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(WebPatternlLog.class);
|
private final static Logger logger = LoggerFactory.getLogger(WebPatternlLog.class);
|
||||||
|
|
||||||
//这个切点的表达式需要根据自己的项目来写
|
//这个切点的表达式需要根据自己的项目来写
|
||||||
@Pointcut("execution(public * com.common.base.controller..*(..))")
|
@Pointcut("execution(public * com..*.controller..*(..))")
|
||||||
public void log() {
|
public void log() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before("log()")
|
@Before("log()")
|
||||||
public void doBefore(JoinPoint joinPoint) {
|
public void doBefore(JoinPoint joinPoint) {
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
//logger.info("aop doBefore..");
|
//logger.info("aop doBefore..");
|
||||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
HttpServletRequest request = attributes.getRequest();
|
HttpServletRequest request = attributes.getRequest();
|
||||||
@@ -53,7 +59,7 @@ public class WebPatternlLog {
|
|||||||
String str = (String) paramter.nextElement();
|
String str = (String) paramter.nextElement();
|
||||||
logger.info(str + "={}", request.getParameter(str));
|
logger.info(str + "={}", request.getParameter(str));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@After("log()")
|
@After("log()")
|
||||||
|
|||||||
Reference in New Issue
Block a user