|
@@ -1,17 +1,14 @@
|
|
|
package com.ruoyi.web.controller.system;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.ruoyi.common.config.RuoYiConfig;
|
|
|
+import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
@@ -20,6 +17,7 @@ import com.ruoyi.system.domain.SysFileInfo;
|
|
|
import com.ruoyi.system.service.ISysFileInfoService;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
/**
|
|
|
* 文件信息Controller
|
|
@@ -101,4 +99,21 @@ public class SysFileInfoController extends BaseController
|
|
|
{
|
|
|
return toAjax(sysFileInfoService.deleteSysFileInfoByFileIds(fileIds));
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/addsave")
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxResult addSave(@RequestParam("file") MultipartFile file,
|
|
|
+ @RequestParam("fileName") String fileName,
|
|
|
+ SysFileInfo fileInfo) throws IOException
|
|
|
+ {
|
|
|
+ // 上传文件路径
|
|
|
+ String filePath = RuoYiConfig.getUploadPath();
|
|
|
+ // 上传并返回新文件名称
|
|
|
+ String fileNewName = FileUploadUtils.upload(filePath, file);
|
|
|
+ fileInfo.setFileName(fileName);
|
|
|
+ fileInfo.setFilePath(fileNewName);
|
|
|
+ return toAjax(sysFileInfoService.insertSysFileInfo(fileInfo));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|