|
@@ -1,5 +1,6 @@
|
|
|
package com.persagy.adm.diagram.controller;
|
|
|
|
|
|
+import cn.hutool.crypto.digest.DigestUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.persagy.adm.diagram.entity.IconEntity;
|
|
|
import com.persagy.adm.diagram.frame.BdtpRequest;
|
|
@@ -78,7 +79,7 @@ public class IconController {
|
|
|
Image img = null;
|
|
|
try {
|
|
|
inputStream = file.getInputStream();
|
|
|
- img = ImageIO.read(inputStream);
|
|
|
+ img = ImageIO.read(file.getInputStream());
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@@ -90,7 +91,11 @@ public class IconController {
|
|
|
FileInfo fileInfo = FileInfoCreator.of(BdtpRequest.getCurrent().getGroupCode(), null,
|
|
|
null, entity.getIconName());
|
|
|
String fileId = FileStorageHelper.uploadFile(fileInfo, inputStream);
|
|
|
-
|
|
|
+ try {
|
|
|
+ inputStream.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
entity.setIconFileId(fileId);
|
|
|
|
|
|
return ResultHelper.single(iconService.saveIcon(entity));
|
|
@@ -99,21 +104,20 @@ public class IconController {
|
|
|
|
|
|
/**
|
|
|
* 图标预览
|
|
|
- * TODO 目前这个接口不可用 文件服务器好像有问题
|
|
|
+ *
|
|
|
* @param request 请求体
|
|
|
* @param response 响应体
|
|
|
* @param iconId 图标数据id
|
|
|
*/
|
|
|
@ApiOperation("图标预览")
|
|
|
@GetMapping("/showImage")
|
|
|
- public void loadFile(HttpServletRequest request, HttpServletResponse response,
|
|
|
- @RequestParam("id") String iconId) {
|
|
|
+ public void showImage(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ @RequestParam("id") String iconId) {
|
|
|
IconEntity info = iconService.getIconInfo(iconId);
|
|
|
if (null == info) {
|
|
|
throw new BusinessException(ResponseCode.A0400.getCode(), "未查到此数据");
|
|
|
}
|
|
|
FileInfo fileInfo = FileStorageHelper.downloadUrl(info.getIconFileId());
|
|
|
- System.out.println(fileInfo);
|
|
|
// 2.通过http请求获取文件流
|
|
|
byte[] bytes = HttpUtil.downloadBytes(fileInfo.getFileDownloadUrl());
|
|
|
ServletOutputStream out = null;
|