mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
4.0.3
This commit is contained in:
@@ -181,10 +181,13 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver {
|
||||
* @param httpServletRequest
|
||||
*/
|
||||
protected void bindUploadFile(Object param, HttpServletRequest httpServletRequest) {
|
||||
if (httpServletRequest instanceof MyServletRequestWrapper) {
|
||||
httpServletRequest = (HttpServletRequest)((MyServletRequestWrapper) httpServletRequest).getRequest();
|
||||
}
|
||||
if (param == null) {
|
||||
return;
|
||||
}
|
||||
if (this.isMultipartRequest(httpServletRequest)) {
|
||||
if (OpenUtil.isMultipart(httpServletRequest)) {
|
||||
MultipartHttpServletRequest request = (MultipartHttpServletRequest) httpServletRequest;
|
||||
Class<?> bizClass = param.getClass();
|
||||
ReflectionUtils.doWithFields(bizClass, field -> {
|
||||
@@ -196,10 +199,6 @@ public class ApiArgumentResolver implements SopHandlerMethodArgumentResolver {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isMultipartRequest(HttpServletRequest request) {
|
||||
return request instanceof MultipartRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取其它的参数解析器
|
||||
*
|
||||
|
@@ -14,6 +14,7 @@ import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -23,6 +24,8 @@ import java.util.Set;
|
||||
@Slf4j
|
||||
public class OpenUtil {
|
||||
|
||||
public static final String MULTIPART = "multipart/";
|
||||
|
||||
/**
|
||||
* 将get类型的参数转换成map,
|
||||
*
|
||||
@@ -120,4 +123,19 @@ public class OpenUtil {
|
||||
return serverSign.equals(sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是文件上传请求
|
||||
*
|
||||
* @param request 请求
|
||||
* @return true:是
|
||||
*/
|
||||
public static boolean isMultipart(HttpServletRequest request) {
|
||||
String contentType = request.getContentType();
|
||||
// Don't use this filter on GET method
|
||||
if (contentType == null) {
|
||||
return false;
|
||||
}
|
||||
return contentType.toLowerCase(Locale.ENGLISH).startsWith(MULTIPART);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -12,7 +12,9 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -83,9 +85,10 @@ public class Example1001_BaseController {
|
||||
// 忽略验证
|
||||
@ApiOperation(value = "忽略签名验证", notes = "忽略签名验证")
|
||||
@Open(value = "story.get.ignore", ignoreValidate = true)
|
||||
@RequestMapping("/get/ignore/v1")
|
||||
public StoryResult getStory21(StoryParam story) {
|
||||
@RequestMapping(value = "/get/ignore/v1", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
public StoryResult getStory21(@RequestBody StoryParam story) {
|
||||
StoryResult result = new StoryResult();
|
||||
result.setId((long) story.getId());
|
||||
result.setName(story.getName() + ", ignoreValidate = true");
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user