package com.jeeplus.common.filter;

import org.springframework.web.multipart.commons.CommonsMultipartResolver;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

public class JeeplusMultipartResolver extends CommonsMultipartResolver {

    /**
     * 不使用CommonsMultipartResolver的url
     */
    private List<String> excludeUrls = new ArrayList<String>();

    @Override
    public boolean isMultipart(HttpServletRequest request) {
        if (excludeUrls!=null&&!excludeUrls.isEmpty()){
            for (String s : excludeUrls) {
                if (request.getRequestURI().contains(s)){
                    return false;
                }
            }
        }
        return super.isMultipart(request);
    }

    public List<String> getExcludeUrls() {
        return excludeUrls;
    }

    public void setExcludeUrls(List<String> excludeUrls) {
        this.excludeUrls = excludeUrls;
    }
}
