Commit a305c105 authored by liqin's avatar liqin 💬

bug fixed

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