package com.persagy.adm.server.custom.interceptor;

import com.persagy.dmp.common.constant.ResponseCode;
import com.persagy.dmp.common.exception.BusinessException;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

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

@Component
public class AppContextInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String groupCode = request.getParameter("groupCode");
        String projectId = request.getParameter("projectId");
        if(StringUtils.isBlank(groupCode) || StringUtils.isBlank(projectId)){
            throw new BusinessException(ResponseCode.A0402.getCode(),"groupCode或者projectId为null");
        }
        return true;
    }
}
