Merge branch 'master' into eureka

eureka
tanghc 5 years ago
commit 0e034af001
  1. 4
      changelog.md
  2. 2
      sop-auth/pom.xml
  3. 2
      sop-common/pom.xml
  4. 6
      sop-common/sop-bridge-gateway/pom.xml
  5. 6
      sop-common/sop-bridge-zuul/pom.xml
  6. 4
      sop-common/sop-gateway-common/pom.xml
  7. 13
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/IndexFilter.java
  8. 4
      sop-common/sop-service-common/pom.xml
  9. 2
      sop-example/sop-book/sop-book-web/pom.xml
  10. 2
      sop-example/sop-easyopen/pom.xml
  11. 2
      sop-example/sop-springmvc/pom.xml
  12. 2
      sop-example/sop-story/sop-story-web/pom.xml
  13. 21
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/FileUploadDemoController.java
  14. 2
      sop-gateway/pom.xml
  15. BIN
      sop-test/src/main/resources/img.png
  16. 23
      sop-test/src/test/java/com/gitee/sop/test/AllInOneTest.java
  17. 2
      sop-website/pom.xml

@ -1,5 +1,9 @@
# changelog
## 3.1.2
- 修复图片上传保存后图片破损问题
## 3.1.1
- 修复继承WebMvcConfigurationSupport导致的jackson序列化时间问题

@ -26,7 +26,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<!-- sop相关配置 end-->

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>

@ -5,11 +5,11 @@
<parent>
<artifactId>sop-common</artifactId>
<groupId>com.gitee.sop</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<artifactId>sop-bridge-gateway</artifactId>
@ -17,7 +17,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<dependency>

@ -5,11 +5,11 @@
<parent>
<artifactId>sop-common</artifactId>
<groupId>com.gitee.sop</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<artifactId>sop-bridge-zuul</artifactId>
@ -17,7 +17,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<dependency>

@ -5,11 +5,11 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sop-gateway-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sop-gateway-common</name>

@ -80,15 +80,16 @@ public class IndexFilter implements WebFilter {
if (request.getMethod() == HttpMethod.POST) {
ServerRequest serverRequest = ServerWebExchangeUtil.createReadBodyRequest(exchange);
// 读取请求体中的内容
Mono<?> modifiedBody = serverRequest.bodyToMono(String.class)
.flatMap(body -> {
Mono<?> modifiedBody = serverRequest.bodyToMono(byte[].class)
.flatMap(data -> {
String body = new String(data, SopConstants.CHARSET_UTF8);
// 构建ApiParam
ApiParam apiParam = ServerWebExchangeUtil.getApiParam(exchange, body);
// 签名验证
doValidate(exchange, apiParam);
return Mono.just(body);
return Mono.just(data);
});
BodyInserter bodyInserter = BodyInserters.fromPublisher(modifiedBody, (Class) String.class);
BodyInserter bodyInserter = BodyInserters.fromPublisher(modifiedBody, (Class)byte[].class);
HttpHeaders headers = new HttpHeaders();
headers.putAll(exchange.getRequest().getHeaders());
@ -130,7 +131,9 @@ public class IndexFilter implements WebFilter {
validator.validate(apiParam);
this.afterValidate(exchange, apiParam);
} catch (ApiException e) {
log.error("验证失败,ip:{}, params:{}, errorMsg:{}", apiParam.fetchIp(), apiParam.toJSONString(), e.getMessage());
log.error("验证失败,url:{}, ip:{}, params:{}, errorMsg:{}",
exchange.getRequest().getURI().toString(),
apiParam.fetchIp(), apiParam.toJSONString(), e.getMessage());
ServerWebExchangeUtil.setThrowable(exchange, e);
}
}

@ -6,11 +6,11 @@
<parent>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sop-service-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sop-service-common</name>

@ -28,7 +28,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gitee.sop</groupId>

@ -29,7 +29,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<!-- 使用nacos注册中心

@ -20,7 +20,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<!-- nacos -->
<dependency>

@ -28,7 +28,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-service-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gitee.sop</groupId>

@ -14,8 +14,10 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Optional;
/**
* 演示文件上传
@ -70,6 +72,25 @@ public class FileUploadDemoController {
return result;
}
@ApiMapping(value = "demo.file.upload3")
public FileUploadResult file3(FileUploadParam2 param, HttpServletRequest request) {
System.out.println(param.getRemark());
FileUploadResult result = new FileUploadResult();
// 获取上传的文件
Collection<MultipartFile> uploadFiles = UploadUtil.getUploadFiles(request);
Optional<MultipartFile> first = uploadFiles.stream().findFirst();
if (first.isPresent()) {
MultipartFile multipartFile = first.get();
try {
String path = System.getProperty("user.dir");
multipartFile.transferTo(new File(path + "/img_"+System.currentTimeMillis()+".png"));
} catch (IOException e) {
e.printStackTrace();
}
}
return result;
}
private FileUploadResult.FileMeta buildFileMeta(MultipartFile multipartFile) {
// 文件名
String fileName = multipartFile.getOriginalFilename();

@ -34,7 +34,7 @@
<groupId>com.gitee.sop</groupId>
<artifactId>sop-bridge-gateway</artifactId>
<!--<artifactId>sop-bridge-zuul</artifactId>-->
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<dependency>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

@ -239,6 +239,29 @@ public class AllInOneTest extends TestBase {
client.execute(requestBuilder);
}
/**
* 演示文件上传
*/
public void testFile3() {
Client client = new Client(url, appId, privateKey);
String root = System.getProperty("user.dir");
Client.RequestBuilder requestBuilder = new Client.RequestBuilder()
.method("demo.file.upload3")
.version("1.0")
.bizContent(new BizContent().add("remark", "test file upload"))
// 添加文件
.addFile("image", new File(root + "/src/main/resources/img.png"))
.callback((requestInfo, responseData) -> {
System.out.println(responseData);
JSONObject jsonObject = JSON.parseObject(responseData);
JSONObject data = jsonObject.getJSONObject(requestInfo.getDataNode());
Assert.assertEquals(data.getString("code"), "10000");
})
;
client.execute(requestBuilder);
}
/**
* 下载文件
*/

@ -35,7 +35,7 @@
<dependency>
<groupId>com.gitee.sop</groupId>
<artifactId>sop-gateway-common</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>
</dependency>
<dependency>

Loading…
Cancel
Save