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); }