Commit 183e43b0 by wang_jiaxing

修改新版本文件下载方法

parent 2247e7e7
......@@ -31,9 +31,9 @@ public class AppBbgxController {
}
@PostMapping("/fileUpload")
public R fileUpload(String version, String gxbz, MultipartFile file){
public R fileUpload(String version, String gxbz, String wjwz){
try {
String result = appBbgxService.fileUpload(version, gxbz, file);
String result = appBbgxService.fileUpload(version, gxbz, wjwz);
if (result == null){
return R.error("该版本已经存在");
}
......
......@@ -13,7 +13,7 @@ public class AppBbgx {
@TableId(type = IdType.INPUT)
private String appVersion;//版本号
private String appGxbz;//更新备注
private byte[] appGxwj;//更新文件
private String appGxwjwz;//更新文件
private Date rksj;//入库时间
private String xxscPdbz;//删除标志
}
......@@ -11,5 +11,5 @@ public interface AppBbgxService {
void getXbbwj(String version, HttpServletResponse response) throws IOException;
String fileUpload(String version, String gxbz, MultipartFile file) throws IOException;
String fileUpload(String version, String gxbz, String wjwz);
}
......@@ -15,9 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
......@@ -56,8 +54,12 @@ public class AppBbgxServiceImpl extends ServiceImpl<AppBbgxMapper, AppBbgx> impl
@Override
public void getXbbwj(String version, HttpServletResponse response) throws IOException {
long l1 = System.currentTimeMillis();
AppBbgx bbgx = appBbgxMapper.selectById(version);
InputStream inputStream = new ByteArrayInputStream(bbgx.getAppGxwj());
long l2 = System.currentTimeMillis();
System.out.println(l2 - l1);
File file = new File(bbgx.getAppGxwjwz());
InputStream inputStream = new FileInputStream(file);
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("智慧警务app" + version + ".apk", "UTF-8"));
ServletOutputStream outputStream = response.getOutputStream();
IOUtils.copy(inputStream, outputStream);
......@@ -67,15 +69,16 @@ public class AppBbgxServiceImpl extends ServiceImpl<AppBbgxMapper, AppBbgx> impl
} catch (Exception ignored) {
}
long l3 = System.currentTimeMillis();
System.out.println(l3 - l2);
}
@Override
public String fileUpload(String version, String gxbz, MultipartFile file) throws IOException {
byte[] bytes = file.getBytes();
public String fileUpload(String version, String gxbz, String wjwz) {
AppBbgx bbgx = new AppBbgx();
bbgx.setAppVersion(version);
bbgx.setAppGxbz(gxbz);
bbgx.setAppGxwj(bytes);
bbgx.setAppGxwjwz(wjwz);
int insert;
try {
insert = appBbgxMapper.insert(bbgx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment