wangjun 4 лет назад
Родитель
Сommit
763d82646e

+ 13 - 21
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/PostFilter.java

@ -86,31 +86,23 @@ public class PostFilter extends ZuulFilter {
            jsonObject.put("status",serviceId+status);
            BaseExceptionLogDO baseExceptionLogDO = new BaseExceptionLogDO();
            baseExceptionLogDO.setCreateTime(new Date());
            List<Map<String,Object>> list = baseExceptionService.findExceptionDict("","110001","","1");
            List<Map<String,Object>> serviceList=baseExceptionService.findExceptionService("","","1","");
            for (Map<String,Object> map:serviceList){
                if (ctx.getRequest().getServletPath().contains(map.get("pathUrl").toString())){
                    serviceId=map.get("id").toString();
                    break;
                }
            }
            List<Map<String,Object>> list = baseExceptionService.findExceptionDict("",status,"","1");
            if (list!=null&&list.size()>0){
                responseCode=serviceId+list.get(0).get("code").toString();
                exceptionType = list.get(0).get("exceptionType").toString();
                baseExceptionLogDO.setExceptionType(exceptionType);
                baseExceptionLogDO.setServiceCode(serviceId);
                baseExceptionLogDO.setExceptionCode(responseCode);
                try {
                    String  in = ctx.getRequest().getParameter("object");
                    String jsonobject = AesEncryptUtils.decrypt(in);
                    baseExceptionLogDO.setRequest(jsonobject);
                    baseExceptionLogDO.setResponse(jsonObject.toString());
                    baseExceptionLogDao.save(baseExceptionLogDO);
                }catch (Exception s){
                    s.printStackTrace();
                }
            }
            baseExceptionLogDO.setExceptionType(exceptionType);
            baseExceptionLogDO.setServiceCode(serviceId);
            baseExceptionLogDO.setExceptionCode(responseCode);
            try {
                String  in = ctx.getRequest().getParameter("object");
                String jsonobject = AesEncryptUtils.decrypt(in);
                baseExceptionLogDO.setRequest(jsonobject);
                baseExceptionLogDO.setResponse(jsonObject.toString());
                baseExceptionLogDao.save(baseExceptionLogDO);
            }catch (Exception s){
                s.printStackTrace();
            }
        }
        JSONObject object = new JSONObject();
        object.put("status","200");

+ 1 - 18
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/methlog/BaseExceptionService.java

@ -1,10 +1,7 @@
package com.yihu.jw.gateway.methlog;
import com.yihu.jw.entity.base.dict.BaseExceptionServerDictDO;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@ -15,22 +12,8 @@ import java.util.Map;
@Component
public class BaseExceptionService {
    @Autowired
    private BaseExceptionDictDao baseExceptionDictDao;
    @Autowired
    private BaseExceptionLogDao baseExceptionLogDao;
    @Autowired
    private BaseExceptionServerDictDao baseExceptionServerDictDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public String findServiceByPath(String path){
        BaseExceptionServerDictDO baseExceptionServerDictDO = baseExceptionServerDictDao.findServiceByPath(path);
        String id ="";
        if (baseExceptionServerDictDO !=null){
            id = baseExceptionServerDictDO.getId();
        }
        return id;
    }
    public List<Map<String,Object>> findExceptionDict(String id,String code,String exceptionType,String isDel){
        String sql = "select t.id as \"id\"," +
                " t.code as \"code\"," +