Browse Source

bug修改

wangjun 3 years ago
parent
commit
21ce4af6a5

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseExceptionDictDO.java

@ -18,6 +18,16 @@ public class BaseExceptionDictDO extends UuidIdentityEntity {
    private String exceptionType;
    private String exceptionTypeName;
    private String remindContent;
    private String exceptionInfo;
    @Column(name = "exception_info")
    public String getExceptionInfo() {
        return exceptionInfo;
    }
    public void setExceptionInfo(String exceptionInfo) {
        this.exceptionInfo = exceptionInfo;
    }
    @Column(name = "remind_content")
    public String getRemindContent() {
        return remindContent;

+ 18 - 3
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/DidiFilterProcessor.java

@ -5,16 +5,22 @@ import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import com.yihu.jw.entity.base.dict.BaseExceptionLogDO;
import com.yihu.jw.gateway.AesEncryptUtils;
import com.yihu.jw.gateway.methlog.BaseExceptionService;
import com.yihu.jw.gateway.methlog.dao.BaseExceptionDictDao;
import com.yihu.jw.gateway.methlog.dao.BaseExceptionLogDao;
import com.yihu.jw.gateway.methlog.dao.BaseExceptionServerDictDao;
import com.yihu.jw.gateway.security.BeanUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
import org.springframework.util.StringUtils;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -57,14 +63,23 @@ public class DidiFilterProcessor extends FilterProcessor {
                    responseCode=serviceId+list.get(0).get("code").toString();
                    exceptionType = list.get(0).get("exceptionType").toString();
                }
                ZuulException e1 = new ZuulException(message, StringUtils.isEmpty(responseCode)?99999999:Integer.valueOf(responseCode),cause);
                ZuulException e1 = new ZuulException(message, StringUtils.isEmpty(responseCode)?99999999:Integer.parseInt(responseCode),cause);
                BaseExceptionLogDO baseExceptionLogDO = new BaseExceptionLogDO();
                baseExceptionLogDO.setCreateTime(new Date());
                baseExceptionLogDO.setExceptionType(exceptionType);
                baseExceptionLogDO.setServiceCode(serviceId);
                baseExceptionLogDO.setExceptionCode(responseCode);
                baseExceptionLogDO.setRequest(ctx.getRequest().toString());
                baseExceptionLogDO.setResponse(ctx.toString());
                try {
                    String  in = ctx.getRequest().getParameter("object");
                    String jsonobject = AesEncryptUtils.decrypt(in);
                    baseExceptionLogDO.setRequest(jsonobject);
                    InputStream stream = RequestContext.getCurrentContext().getResponseDataStream();
                    byte[] bytes = StreamUtils.copyToByteArray(stream);
                    String resp = new String(bytes,"UTF8");
                    baseExceptionLogDO.setResponse(resp);
                }catch (Exception s){
                    s.printStackTrace();
                }
                baseExceptionLogDao.save(baseExceptionLogDO);
                ctx.set("failed.exception", e1);
                ctx.set("failed.filter", filter);