update onlyoffice接口
This commit is contained in:
+9
-2
@@ -249,8 +249,15 @@ public class BusProcessModelHisController {
|
||||
|
||||
@ApiOperation(value = "|model| 传入 模板文档名称(不带后缀)默认 docx")
|
||||
@GetMapping("/saveEditFile")
|
||||
public BusProcessModelHis saveEditFile(String model) {
|
||||
return busProcessModelHisService.saveEditFile(model);
|
||||
public Result<BusProcessModelHis> saveEditFile(String model) {
|
||||
|
||||
return Result.OK(busProcessModelHisService.saveEditFile(model));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "根据路径下载文件")
|
||||
@GetMapping("/downLoadFile")
|
||||
public void downLoadFile(@RequestParam(name = "path") String path, HttpServletResponse response) {
|
||||
busProcessModelHisService.downLoadFile(path,response);
|
||||
}
|
||||
|
||||
@GetMapping("/processModelHisOneUpdStatus")
|
||||
|
||||
+3
-1
@@ -1,10 +1,10 @@
|
||||
package com.jero.modules.onlyoffice.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.modules.onlyoffice.entity.BusProcessModelHis;
|
||||
import com.jero.modules.onlyoffice.entity.OnlineFileLog;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -32,4 +32,6 @@ public interface IBusProcessModelHisService extends IService<BusProcessModelHis>
|
||||
List<BusProcessModelHis> modelHisList(String pid);
|
||||
|
||||
OnlineFileLog selectOnlineFile(String onlineFileId);
|
||||
|
||||
void downLoadFile(String path, HttpServletResponse response);
|
||||
}
|
||||
|
||||
+41
-4
@@ -13,10 +13,8 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -134,6 +132,45 @@ public class BusProcessModelHisServiceImpl extends ServiceImpl<BusProcessModelHi
|
||||
return onlineFileLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downLoadFile(String path, HttpServletResponse response) {
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
File file = new File(filePath + path);
|
||||
inputStream = new BufferedInputStream(new FileInputStream(file));
|
||||
//response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1"));
|
||||
response.setContentType("application/force-download");// 设置强制下载不打开
|
||||
outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
}catch (IOException e) {
|
||||
log.error("预览文件失败" + e.getMessage());
|
||||
response.setStatus(404);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 企标流程文件存储
|
||||
* @param pid
|
||||
|
||||
Reference in New Issue
Block a user