Browse Source
Conflicts: epmet-module/gov-project/gov-project-server/deploy/docker-compose-dev.yml epmet-module/gov-project/gov-project-server/pom.xmldev_shibei_match
16 changed files with 80 additions and 14 deletions
@ -0,0 +1,5 @@ |
|||||
|
CREATE TABLE `demo_t` ( |
||||
|
`device_id` bigint(11) NOT NULL AUTO_INCREMENT, |
||||
|
`device_name` varchar(20) NOT NULL, |
||||
|
PRIMARY KEY (`device_id`) |
||||
|
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4; |
@ -0,0 +1,2 @@ |
|||||
|
INSERT INTO demo_t (device_name) VALUES ('a'); |
||||
|
INSERT INTO demo_t (device_name) VALUES ('b'); |
@ -0,0 +1,40 @@ |
|||||
|
package com.epmet.aspect; |
||||
|
|
||||
|
import com.epmet.commons.tools.aspect.BaseRequestLogAspect; |
||||
|
import org.aspectj.lang.ProceedingJoinPoint; |
||||
|
import org.aspectj.lang.annotation.Around; |
||||
|
import org.aspectj.lang.annotation.Aspect; |
||||
|
import org.springframework.core.annotation.Order; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.web.context.request.RequestAttributes; |
||||
|
import org.springframework.web.context.request.RequestContextHolder; |
||||
|
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
|
||||
|
import javax.servlet.http.HttpServletRequest; |
||||
|
|
||||
|
/** |
||||
|
* 日志/异常处理切面实现,调用父类方法完成日志记录和异常处理。 |
||||
|
*/ |
||||
|
@Aspect |
||||
|
@Component |
||||
|
@Order(0) |
||||
|
public class RequestLogAspect extends BaseRequestLogAspect { |
||||
|
|
||||
|
@Override |
||||
|
@Around(value = "execution(* com.epmet.controller.*Controller*.*(..)) ") |
||||
|
public Object proceed(ProceedingJoinPoint point) throws Throwable { |
||||
|
return super.proceed(point, getRequest()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取Request对象 |
||||
|
* |
||||
|
* @return |
||||
|
*/ |
||||
|
private HttpServletRequest getRequest() { |
||||
|
RequestAttributes ra = RequestContextHolder.getRequestAttributes(); |
||||
|
ServletRequestAttributes sra = (ServletRequestAttributes) ra; |
||||
|
return sra.getRequest(); |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue