zcr:链接图标文件流
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.adc.da.slrs.sarUrl.controller;
|
||||
|
||||
|
||||
import com.adc.da.att.entity.AttFileEO;
|
||||
import com.adc.da.att.service.IAttFileEOService;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.sarUrl.entity.OrderUrlVO;
|
||||
@@ -12,12 +14,21 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -34,6 +45,52 @@ public class TsUrlController{
|
||||
@Autowired
|
||||
private ITsUrlService tsUrlService;
|
||||
|
||||
@Autowired
|
||||
private IAttFileEOService iAttFileEOService;
|
||||
|
||||
@Value("${file.path}")
|
||||
private String filePath;
|
||||
|
||||
@GetMapping("getIconImg")
|
||||
public String getIconImg(HttpServletRequest request, HttpServletResponse response){
|
||||
String url = "";
|
||||
String path = "api/att/attFile/upload";
|
||||
ServletOutputStream outputStream = null;
|
||||
FileInputStream inputStream = null;
|
||||
//通过id获取路径
|
||||
String id = request.getParameter("id");
|
||||
String fid = tsUrlService.getById(id).getIcon();
|
||||
List<AttFileEO> attFileEOS = iAttFileEOService.getMultiFileInfos(fid);
|
||||
if(attFileEOS.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
AttFileEO attFileEO = attFileEOS.get(0);
|
||||
url = filePath + attFileEO.getFilePath() + attFileEO.getFileName();
|
||||
|
||||
try {
|
||||
System.out.println(id);
|
||||
TsUrl tsUrl = tsUrlService.getById(id);
|
||||
System.out.println(tsUrl);
|
||||
|
||||
File file = new File(url);
|
||||
if(!file.exists()) return null;
|
||||
inputStream = new FileInputStream(file);
|
||||
response.setContentType("image/jpeg");
|
||||
outputStream = response.getOutputStream();
|
||||
int len = 0;
|
||||
byte[] buffer = new byte[1024 * 10];
|
||||
while ((len = inputStream.read(buffer)) != -1){
|
||||
outputStream.write(buffer,0,len);
|
||||
}
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println("---------图标获取异常--------------");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ApiOperation("查询")
|
||||
@GetMapping
|
||||
public ResponseMessage<List<TsUrl>> getUrls(){
|
||||
|
||||
@@ -61,4 +61,10 @@ public class TsUrl implements Serializable {
|
||||
/**排序*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderBy;
|
||||
|
||||
/**新增*/
|
||||
@ApiModelProperty(value = "图标信息")
|
||||
private String icon;
|
||||
@ApiModelProperty(value = "位置")
|
||||
private Integer type;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user