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

com.didiglobal.logi.security.interceptor.LogiSecurityInterceptor Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.didiglobal.logi.security.interceptor;

import com.didiglobal.logi.security.util.HttpRequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
@Component("logiSecurityInterceptor")
public class LogiSecurityInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        log.info(request.getRequestURL().toString());
        Integer operatorId = HttpRequestUtil.getOperatorId(request);
        // 没登录
        return !StringUtils.isEmpty(operatorId);
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response,
                           Object handler, ModelAndView modelAndView) {
        // Do nothing
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
                                Object handler, Exception ex) {
        // Do nothing
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy