1.文件上传增加后缀名校验
2.token拦截器撤销注释
This commit is contained in:
parent
fe9fbd8992
commit
18aff440ee
@ -1,18 +1,19 @@
|
||||
package com.xqopen.kehui.conf;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.xqopen.kehui.interceptor.PermissionInterceptor;
|
||||
import com.xqopen.kehui.util.Constants;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@Configuration
|
||||
public class WebMVCConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
@ -45,14 +46,14 @@ public class WebMVCConfig extends WebMvcConfigurerAdapter {
|
||||
return lci;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void addInterceptors(InterceptorRegistry registry) {
|
||||
// //国际化过滤器
|
||||
// registry.addInterceptor(localeChangeInterceptor());
|
||||
// //自定义拦截器
|
||||
// registry.addInterceptor(new PermissionInterceptor()).addPathPatterns("/**");
|
||||
// super.addInterceptors(registry);
|
||||
// }
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
//国际化过滤器
|
||||
registry.addInterceptor(localeChangeInterceptor());
|
||||
//自定义拦截器
|
||||
registry.addInterceptor(new PermissionInterceptor()).addPathPatterns("/**");
|
||||
super.addInterceptors(registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* 静态文件处理
|
||||
|
@ -1,18 +1,16 @@
|
||||
package com.xqopen.kehui.util;
|
||||
|
||||
import static com.xqopen.kehui.util.Constants.LINE_SEPARATOR;
|
||||
import com.xqopen.kehui.common.dto.FileItem;
|
||||
import com.xqopen.kehui.exception.ErrorCode;
|
||||
import com.xqopen.kehui.exception.XQException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.xqopen.kehui.common.dto.FileItem;
|
||||
import com.xqopen.kehui.exception.ErrorCode;
|
||||
import com.xqopen.kehui.exception.XQException;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import static com.xqopen.kehui.util.Constants.LINE_SEPARATOR;
|
||||
|
||||
@Slf4j
|
||||
public class FileUploadUtil {
|
||||
@ -22,6 +20,11 @@ public class FileUploadUtil {
|
||||
if (file.isEmpty()) {
|
||||
throw new XQException(ErrorCode.UPLOAD_FILE_EMPTY, null);
|
||||
}
|
||||
String filename = file.getOriginalFilename();
|
||||
//后缀名固定
|
||||
if(!(filename.endsWith(".jpg")||filename.endsWith(".png")||filename.endsWith(".jpeg")||filename.endsWith(".pdf")||filename.endsWith(".docx")||filename.endsWith(".doc"))){
|
||||
throw new XQException(ErrorCode.UPLOAD_FILE_ERORR, null);
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
String originalFileName = file.getOriginalFilename();
|
||||
|
@ -4,7 +4,13 @@ spring:
|
||||
# url: jdbc:postgresql://ali4.xqopen.com:30390/kehui
|
||||
url: jdbc:postgresql://localhost:5432/kehui
|
||||
username: postgres
|
||||
password: admin
|
||||
password: 123456
|
||||
# url: jdbc:postgresql://8.131.55.216/kehui
|
||||
# username: postgres
|
||||
# password: 8zysGtJGDCPdkXya
|
||||
# url: jdbc:postgresql://localhost:5432/kehui
|
||||
# username: postgres
|
||||
# password: admin
|
||||
|
||||
#自定义系统属性
|
||||
attach:
|
||||
|
Loading…
x
Reference in New Issue
Block a user