com.fastchar.systemtool.interceptor.FastSystemToolAfterInterceptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fastchar-systemtool Show documentation
Show all versions of fastchar-systemtool Show documentation
FastChar-SystemTool is a FastChar-ExtJs plugin.
package com.fastchar.systemtool.interceptor;
import com.fastchar.core.FastAction;
import com.fastchar.core.FastChar;
import com.fastchar.interfaces.IFastInterceptor;
import com.fastchar.systemtool.FastSystemToolConfig;
import com.fastchar.systemtool.entity.FinalLogActionRequestEntity;
/**
* @author 沈建(Janesen)
* @date 2021/6/3 16:08
*/
public class FastSystemToolAfterInterceptor implements IFastInterceptor {
@Override
public void onInterceptor(FastAction fastAction) throws Exception {
try {
FinalLogActionRequestEntity requestEntity = FinalLogActionRequestEntity.newInstance();
requestEntity.set("remoteUrl", fastAction.getRemoteIp());
requestEntity.set("remoteClient", fastAction.getUserAgent());
requestEntity.set("actionClass", fastAction.getClass().getName());
requestEntity.set("requestUrl", fastAction.getFastRoute().getRoute());
requestEntity.set("requestData", FastChar.getJson().toJson(fastAction.getParamToMap()));
if (fastAction.getFastOut() != null && fastAction.getFastOut().getData() != null) {
requestEntity.set("responseData", FastChar.getJson().toJson(fastAction.getFastOut().getData()));
}
if (requestEntity.save()) {
requestEntity.clearData(FastChar.getConfig(FastSystemToolConfig.class).getLogActionRequestMaxKeepDay());
}
} catch (Exception ignored) {
}
fastAction.invoke();
}
}