From c8ded0f1436bb152f382af4008533129a5ff8b0a Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Mon, 6 Feb 2023 16:55:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E4=B8=8A=E4=BC=A0=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=AE=9E=E6=97=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iasf/controller/SysFilesController.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/huoran/iasf/controller/SysFilesController.java b/src/main/java/com/huoran/iasf/controller/SysFilesController.java index 7058cb5..a7e9210 100644 --- a/src/main/java/com/huoran/iasf/controller/SysFilesController.java +++ b/src/main/java/com/huoran/iasf/controller/SysFilesController.java @@ -10,7 +10,10 @@ import com.huoran.iasf.common.aop.annotation.NoRepeatSubmit; import com.huoran.iasf.common.config.NonStaticResourceHttpRequestConfig; import com.huoran.iasf.common.utils.R; import com.huoran.iasf.entity.SysFilesEntity; +import com.huoran.iasf.entity.SysUser; +import com.huoran.iasf.service.HttpSessionService; import com.huoran.iasf.service.SysFilesService; +import com.huoran.iasf.service.UserService; import com.huoran.iasf.vo.UEditorResultVO; import com.huoran.iasf.vo.req.FileParameters; import io.swagger.annotations.Api; @@ -49,6 +52,12 @@ public class SysFilesController { @Resource private SysFilesService sysFilesService; + @Autowired + private UserService userService; + + @Resource + private HttpSessionService httpSessionService; + @ApiOperation(value = "上传文件前获取配置文件") @GetMapping("/upload") public String upload(@RequestParam(required = false) String action,HttpServletResponse response) throws IOException { @@ -67,6 +76,8 @@ public class SysFilesController { public UEditorResultVO add( @RequestParam(required = false) String action, @RequestParam(value = "file") MultipartFile file, FileParameters fileParameters) { + Integer userId = httpSessionService.getCurrentUserId(); + fileParameters.setUploader(userId.toString()); //判断文件是否空 if (file == null || file.getOriginalFilename() == null || "".equalsIgnoreCase(file.getOriginalFilename().trim())) { UEditorResultVO uEditorResult = new UEditorResultVO(); @@ -136,6 +147,14 @@ public class SysFilesController { //查看文章未删除的 queryWrapper.eq(SysFilesEntity::getIsDel,0); IPage iPage = sysFilesService.page(sysFiles.getQueryPage(),queryWrapper); + iPage.getRecords().forEach(sysFilesEntity -> { + if (sysFilesEntity.getUploader()!=null){ + SysUser sysUser = userService.getById(sysFilesEntity.getUploader()); + if (sysUser!=null){ + sysFilesEntity.setUploader(sysUser.getRealName()); + } + } + }); return R.success(iPage); }