Search in sources :

Example 1 with RepeatSubmit

use of com.ruoyi.common.annotation.RepeatSubmit in project wumei-smart by kerwincui.

the class RepeatSubmitInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Method method = handlerMethod.getMethod();
        RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
        if (annotation != null) {
            if (this.isRepeatSubmit(request, annotation)) {
                AjaxResult ajaxResult = AjaxResult.error(annotation.message());
                ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult));
                return false;
            }
        }
        return true;
    } else {
        return true;
    }
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) HandlerMethod(org.springframework.web.method.HandlerMethod) Method(java.lang.reflect.Method) RepeatSubmit(com.ruoyi.common.annotation.RepeatSubmit) HandlerMethod(org.springframework.web.method.HandlerMethod)

Example 2 with RepeatSubmit

use of com.ruoyi.common.annotation.RepeatSubmit in project RuoYi-Vue by yangzongzhuan.

the class RepeatSubmitInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Method method = handlerMethod.getMethod();
        RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
        if (annotation != null) {
            if (this.isRepeatSubmit(request, annotation)) {
                AjaxResult ajaxResult = AjaxResult.error(annotation.message());
                ServletUtils.renderString(response, JSON.toJSONString(ajaxResult));
                return false;
            }
        }
        return true;
    } else {
        return true;
    }
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) HandlerMethod(org.springframework.web.method.HandlerMethod) Method(java.lang.reflect.Method) RepeatSubmit(com.ruoyi.common.annotation.RepeatSubmit) HandlerMethod(org.springframework.web.method.HandlerMethod)

Example 3 with RepeatSubmit

use of com.ruoyi.common.annotation.RepeatSubmit in project hocassian-media-matrix by hokaso.

the class RepeatSubmitInterceptor method preHandle.

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    if (handler instanceof HandlerMethod) {
        HandlerMethod handlerMethod = (HandlerMethod) handler;
        Method method = handlerMethod.getMethod();
        RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
        if (annotation != null) {
            if (this.isRepeatSubmit(request)) {
                AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试");
                ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult));
                return false;
            }
        }
        return true;
    } else {
        return super.preHandle(request, response, handler);
    }
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) HandlerMethod(org.springframework.web.method.HandlerMethod) Method(java.lang.reflect.Method) RepeatSubmit(com.ruoyi.common.annotation.RepeatSubmit) HandlerMethod(org.springframework.web.method.HandlerMethod)

Aggregations

RepeatSubmit (com.ruoyi.common.annotation.RepeatSubmit)3 AjaxResult (com.ruoyi.common.core.domain.AjaxResult)3 Method (java.lang.reflect.Method)3 HandlerMethod (org.springframework.web.method.HandlerMethod)3