fixbug 文件上传大小 && 微信https 异常问题

This commit is contained in:
limqhz
2021-03-28 12:52:21 +08:00
parent 3fa693bf01
commit dbf34c9fd1
4 changed files with 54 additions and 13 deletions

View File

@@ -5,12 +5,18 @@ import com.sv.dto.app.VenueLessonStatus;
import com.sv.entity.Venue;
import com.sv.service.api.VenueLessonService;
import com.sv.service.oms.VenueService;
import org.apache.http.client.fluent.Request;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@@ -22,6 +28,10 @@ public class AppVenueLessonController {
private VenueService venueService;
@Resource
private VenueLessonService venueLessonService;
@Value("${oss.url}")
private String url;
@Value("${sv.file.store.health}")
private String healthDir;
/**
* 通过返回页面来进行拼接每个APP可以返回具体的场馆的课程预订情况
@@ -138,4 +148,26 @@ public class AppVenueLessonController {
return venueItems;
}
/**
* 查询数据库
*/
@RequestMapping(value = "/fetchFile/{fileUrl}", method = {RequestMethod.GET,RequestMethod.POST})
public void fetchFile(String fileUrl, HttpServletResponse response) throws IOException {
String findFile = url + healthDir + fileUrl;
InputStream inputStream = Request.Get(findFile).execute().returnContent().asStream();
ServletOutputStream servletOutputStream = response.getOutputStream();
if (inputStream != null && servletOutputStream != null) {
int temp = 0;
// 开始拷贝
while ((temp = inputStream.read()) != -1) {
// 边读边写
servletOutputStream.write(temp);
}
// 关闭输入输出流
inputStream.close();
servletOutputStream.flush();
servletOutputStream.close();
}
}
}