|
|
@ -3,6 +3,9 @@ package com.zc.business.controller; |
|
|
|
import java.util.List; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import com.ruoyi.common.config.RuoYiConfig; |
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils; |
|
|
|
import com.ruoyi.common.utils.file.FileUtils; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
@ -21,6 +24,8 @@ import com.zc.business.domain.DcFileDownload; |
|
|
|
import com.zc.business.service.IDcFileDownloadService; |
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
|
|
import com.ruoyi.common.core.page.TableDataInfo; |
|
|
|
import com.ruoyi.framework.config.ServerConfig; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
/** |
|
|
|
* 文件管理Controller |
|
|
@ -33,7 +38,8 @@ import com.ruoyi.common.core.page.TableDataInfo; |
|
|
|
public class DcFileDownloadController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private IDcFileDownloadService dcFileDownloadService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ServerConfig serverConfig; |
|
|
|
/** |
|
|
|
* 查询文件管理列表 |
|
|
|
*/ |
|
|
@ -95,4 +101,29 @@ public class DcFileDownloadController extends BaseController { |
|
|
|
public AjaxResult remove(@PathVariable Long[] ids) { |
|
|
|
return toAjax(dcFileDownloadService.deleteDcFileDownloadByIds(ids)); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 文件管理-文件上传请求 |
|
|
|
*/ |
|
|
|
@PostMapping("/uploadFileManagement") |
|
|
|
public AjaxResult uploadFileManagement(MultipartFile file) throws Exception |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
// 上传文件路径
|
|
|
|
String filePath = RuoYiConfig.getFileManagementPath(); |
|
|
|
// 上传并返回新文件名称
|
|
|
|
String fileName = FileUploadUtils.upload(filePath, file); |
|
|
|
String url = serverConfig.getUrl() + fileName; |
|
|
|
AjaxResult ajax = AjaxResult.success(); |
|
|
|
ajax.put("url", url); |
|
|
|
ajax.put("fileName", fileName); |
|
|
|
ajax.put("newFileName", FileUtils.getName(fileName)); |
|
|
|
ajax.put("originalFilename", file.getOriginalFilename()); |
|
|
|
return ajax; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
return AjaxResult.error(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|