mirror of https://gitee.com/maxjhandsome/pig
增加网关统一异常处理,不在ControllerAOP处理
This commit is contained in:
parent
85c50241c6
commit
0d362d2584
|
@ -2,27 +2,28 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.github.pig.admin.mapper.SysLogMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.github.pig.common.entity.SysLog">
|
||||
<id column="id" property="id" />
|
||||
<result column="type" property="type" />
|
||||
<result column="title" property="title" />
|
||||
<result column="create_by" property="createBy" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="remote_addr" property="remoteAddr" />
|
||||
<result column="user_agent" property="userAgent" />
|
||||
<result column="request_uri" property="requestUri" />
|
||||
<result column="method" property="method" />
|
||||
<result column="params" property="params" />
|
||||
<result column="time" property="time" />
|
||||
<result column="del_flag" property="delFlag" />
|
||||
<result column="exception" property="exception" />
|
||||
</resultMap>
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.github.pig.common.entity.SysLog">
|
||||
<id column="id" property="id"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="service_id" property="serviceId"/>
|
||||
<result column="create_by" property="createBy"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="remote_addr" property="remoteAddr"/>
|
||||
<result column="user_agent" property="userAgent"/>
|
||||
<result column="request_uri" property="requestUri"/>
|
||||
<result column="method" property="method"/>
|
||||
<result column="params" property="params"/>
|
||||
<result column="time" property="time"/>
|
||||
<result column="del_flag" property="delFlag"/>
|
||||
<result column="exception" property="exception"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, type, title, create_by AS createBy, create_time AS createTime , update_time AS updateTime, remote_addr AS remoteAddr, user_agent AS userAgent, request_uri AS requestUri, method, params, `time`, del_flag AS delFlag
|
||||
id, type, title, create_by AS createBy, create_time AS createTime, update_time AS updateTime, remote_addr AS remoteAddr, user_agent AS userAgent, request_uri AS requestUri, method, params, `time`, del_flag AS delFlag
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -74,6 +74,11 @@ public class SysLog implements Serializable {
|
|||
*/
|
||||
private String exception;
|
||||
|
||||
/**
|
||||
* 服务ID
|
||||
*/
|
||||
private String serviceId;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -186,6 +191,14 @@ public class SysLog implements Serializable {
|
|||
this.exception = exception;
|
||||
}
|
||||
|
||||
public String getServiceId() {
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
public void setServiceId(String serviceId) {
|
||||
this.serviceId = serviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SysLog{" +
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.io.InputStream;
|
|||
*/
|
||||
@Component
|
||||
public class LogSendServiceImpl implements LogSendService {
|
||||
private static final String SERVICE_ID = "serviceId";
|
||||
private Logger logger = LoggerFactory.getLogger(LogSendServiceImpl.class);
|
||||
@Autowired
|
||||
private AmqpTemplate rabbitTemplate;
|
||||
|
@ -58,6 +59,9 @@ public class LogSendServiceImpl implements LogSendService {
|
|||
log.setCreateBy(UserUtils.getUserName(request));
|
||||
Long startTime = (Long) requestContext.get("startTime");
|
||||
log.setTime(System.currentTimeMillis() - startTime);
|
||||
if (requestContext.get(SERVICE_ID) != null) {
|
||||
log.setServiceId(requestContext.get(SERVICE_ID).toString());
|
||||
}
|
||||
|
||||
//正常发送服务异常解析
|
||||
if (requestContext.getResponseStatusCode() != HttpStatus.SC_OK) {
|
||||
|
|
Loading…
Reference in New Issue