Commit a305c105 authored by liqin's avatar liqin 💬

bug fixed

parent b043bdcf
......@@ -8,7 +8,6 @@ import com.github.tobato.fastdfs.domain.fdfs.FileInfo;
import com.github.tobato.fastdfs.domain.fdfs.MetaData;
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
import com.github.tobato.fastdfs.domain.fdfs.ThumbImageConfig;
import com.github.tobato.fastdfs.domain.proto.storage.DownloadByteArray;
import com.github.tobato.fastdfs.domain.proto.storage.DownloadFileStream;
import com.github.tobato.fastdfs.exception.FdfsServerException;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
......@@ -106,17 +105,6 @@ public class FastDFSUtils {
/**
* 下载文件(字节数组)
*/
public static byte[] downloadFile(String fileUrl) {
fileUrl = fileUrl.replace(dfsFileAccessBasePath + "/", "");
String groupName = fileUrl.substring(0, fileUrl.indexOf("/"));
String path = fileUrl.substring(fileUrl.indexOf("/") + 1);
return storageClient.downloadFile(groupName, path, new DownloadByteArray());
}
/**
* 下载文件(字节数组)
* @return
*/
public static BufferedInputStream downloadFile(String fileUrl, OutputStream outputStream) {
fileUrl = fileUrl.replace(dfsFileAccessBasePath + "/", "");
String groupName = fileUrl.substring(0, fileUrl.indexOf("/"));
......@@ -126,14 +114,11 @@ public class FastDFSUtils {
/**
* 下载文件
*
* @param groupName
* @param path
* @return
*/
public static InputStream deleteFile(String groupName, String path) {
public static InputStream downloadFile(String filePath) {
try {
return storageClient.downloadFile(groupName, path, inputStream -> inputStream);
StorePath storePath = StorePath.parseFromUrl(filePath);
return storageClient.downloadFile(storePath.getGroup(), storePath.getPath(), inputStream -> inputStream);
} catch (FdfsServerException e) {
//不起作用
log.error("文件不存在,下载失败:" + e.getErrorCode());
......@@ -144,11 +129,9 @@ public class FastDFSUtils {
/**
* 删除文件
*/
public static byte[] deleteFile(String fileUrl) {
fileUrl = fileUrl.replace(dfsFileAccessBasePath + "/", "");
String groupName = fileUrl.substring(0, fileUrl.indexOf("/"));
String path = fileUrl.substring(fileUrl.indexOf("/") + 1);
return storageClient.downloadFile(groupName, path, new DownloadByteArray());
public static void deleteFile(String filePath) {
StorePath storePath = StorePath.parseFromUrl(filePath);
storageClient.deleteFile(storePath.getGroup(), storePath.getPath());
}
private static int[] getImageInfo(byte[] bytes) {
......
package cn.wisenergy.chnmuseum.party.web.controller;
import cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.model.Asset;
import cn.wisenergy.chnmuseum.party.service.AssetService;
......@@ -13,10 +14,10 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
......@@ -80,9 +81,15 @@ public class AssetController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("asset:download")
public void download(@RequestParam("idList") List<String> idList) {
final List<Asset> assetList = assetService.listByIds(idList);
for (Asset asset : assetList) {
final String fileUrl = asset.getFileUrl();
final InputStream inputStream = FastDFSUtils.downloadFile(fileUrl);
}
}
}
......
......@@ -22,7 +22,6 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -144,6 +143,7 @@ public class ExhibitionBoardCatController extends BaseController {
queryWrapper.select(
ExhibitionBoardCat::getId,
ExhibitionBoardCat::getName,
ExhibitionBoardCat::getRemarks,
ExhibitionBoardCat::getCreateTime,
ExhibitionBoardCat::getUpdateTime);
Page<ExhibitionBoardCat> page = this.exhibitionBoardCatService.page(getPage(), queryWrapper);
......
......@@ -18,7 +18,6 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -269,6 +268,8 @@ public class ExhibitionBoardController extends BaseController {
queryWrapper.select(
ExhibitionBoard::getId,
ExhibitionBoard::getName,
ExhibitionBoard::getRemarks,
ExhibitionBoard::getQrcodeUrl,
ExhibitionBoard::getAuditStatus,
ExhibitionBoard::getPublished,
ExhibitionBoard::getDeleted,
......
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