All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fastchar.systemtool.interceptor.FastSystemToolAfterInterceptor Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy