|
@@ -12,6 +12,7 @@ import org.apache.commons.io.IOUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -34,6 +35,9 @@ public class DataGovernanceController {
|
|
|
@Autowired
|
|
|
private DataGovernanceService dataGovernanceService;
|
|
|
|
|
|
+ @Value("${ERImagePath}")
|
|
|
+ private String ERImagePath;
|
|
|
+
|
|
|
|
|
|
@RequestMapping(value = "/databaseList",method = RequestMethod.GET)
|
|
|
public List<DatabaseInfo> databaseList(){
|
|
@@ -118,4 +122,34 @@ public class DataGovernanceController {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping(value = "/loadERImage")
|
|
|
+ public void loadFile(@RequestParam(value = "databaseName") String databaseName, HttpServletResponse servletResponse) throws Exception{
|
|
|
+ File image = new File(ERImagePath+databaseName+".jpg");
|
|
|
+ InputStream inputStream = null;
|
|
|
+ ServletOutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ inputStream = new FileInputStream(image);
|
|
|
+ outputStream = servletResponse.getOutputStream();
|
|
|
+ servletResponse.setHeader("Content-Disposition", String.format(
|
|
|
+ "attachment; filename=\"%s\"",
|
|
|
+ java.net.URLEncoder.encode(image.getName(), "UTF-8")));
|
|
|
+ servletResponse.setContentType("application/octet-stream;charset=UTF-8");
|
|
|
+ int count = 0;
|
|
|
+ byte[] buffer = new byte[1024 * 1024];
|
|
|
+ while ((count = inputStream.read(buffer)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, count);
|
|
|
+ }
|
|
|
+ outputStream.flush();
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("文件加载失败", e);
|
|
|
+ } finally {
|
|
|
+ if (inputStream != null) {
|
|
|
+ inputStream.close();
|
|
|
+ }
|
|
|
+ if (outputStream != null) {
|
|
|
+ outputStream.close();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|