From 269031cf8e6d1e4643e1be2b822bbfebcf87ea4b Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 16 Jul 2021 22:39:49 +0800
Subject: [PATCH] 考试成绩计算接口新增
---
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java | 35 ++++++++++++++++++++++++++++++-----
1 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java b/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
index ae158a0..d679d2a 100644
--- a/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
+++ b/src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -16,9 +16,18 @@
*/
package org.springblade.modules.resource.endpoint;
+import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.oss.model.OssFile;
@@ -171,10 +180,10 @@
*/
@SneakyThrows
@PostMapping("/put-file-attach")
- public R<BladeFile> putFileAttach(@RequestParam MultipartFile file) {
+ public R<BladeFile> putFileAttach(@RequestParam MultipartFile file,String deptid,String type) {
String fileName = file.getOriginalFilename();
BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
- Long attachId = buildAttach(fileName, file.getSize(), bladeFile);
+ Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type);
bladeFile.setAttachId(attachId);
return R.data(bladeFile);
}
@@ -188,9 +197,9 @@
*/
@SneakyThrows
@PostMapping("/put-file-attach-by-name")
- public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file) {
+ public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file,String deptid,String type) {
BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
- Long attachId = buildAttach(fileName, file.getSize(), bladeFile);
+ Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type);
bladeFile.setAttachId(attachId);
return R.data(bladeFile);
}
@@ -203,7 +212,7 @@
* @param bladeFile 对象存储文件
* @return attachId
*/
- private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile) {
+ private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type) throws Exception {
String fileExtension = FileUtil.getFileExtension(fileName);
Attach attach = new Attach();
attach.setDomain(bladeFile.getDomain());
@@ -212,10 +221,26 @@
attach.setOriginalName(bladeFile.getOriginalName());
attach.setAttachSize(fileSize);
attach.setExtension(fileExtension);
+ attach.setDeptid(deptid);
+ attach.setType(type);
attachService.save(attach);
+ test01("http://192.168.0.104:80/blade-resource/attach/save",attach);
return attach.getId();
}
+ public static String test01(String path,Object obj) throws Exception{
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ HttpPost httpPost = new HttpPost(path);
+ httpPost.setEntity(new StringEntity(JSON.toJSONString(obj),
+ ContentType.create("application/json", "UTF-8")));
+ CloseableHttpResponse execute = httpClient.execute(httpPost);
+ HttpEntity entity = execute.getEntity();
+ String str = EntityUtils.toString(entity);
+ httpPost.clone();
+ httpClient.close();
+ System.out.println(str);
+ return str;
+ }
/**
* 删除文件
*
--
Gitblit v1.9.3