Commit 574e7177 by zzrdark

1.增加下载模板

2.修复其他接口请求问题
parent 9fb6c8cc
......@@ -9,12 +9,18 @@ import com.mx.cneeds.server.datashow.client.DeviceClient;
import com.mx.cneeds.server.datashow.client.UserClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;
......@@ -318,4 +324,31 @@ public class DeviceController {
return R.ok();
}
@RequestMapping(value = "/device/downloadDeviceUploadFile", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> downloadDeviceUploadFile(){
ResponseEntity<InputStreamResource> response = null;
try {
ClassPathResource classPathResource = new ClassPathResource("template/order-Info.xlsx");
InputStream inputStream = classPathResource.getInputStream();
//File file = new File(path);
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
headers.add("Content-Disposition",
"attachment; filename = 模板文件.xlsx");
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
response = ResponseEntity.ok().headers(headers)
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(new InputStreamResource(inputStream));
} catch (FileNotFoundException e1) {
log.error("找不到指定的文件", e1);
} catch (IOException e) {
log.error("获取不到文件流", e);
}
return response;
}
}
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