文章上传名称实时修改

master 230208
cheney 2 years ago
parent c4292172ed
commit c8ded0f143
  1. 19
      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.config.NonStaticResourceHttpRequestConfig;
import com.huoran.iasf.common.utils.R; import com.huoran.iasf.common.utils.R;
import com.huoran.iasf.entity.SysFilesEntity; 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.SysFilesService;
import com.huoran.iasf.service.UserService;
import com.huoran.iasf.vo.UEditorResultVO; import com.huoran.iasf.vo.UEditorResultVO;
import com.huoran.iasf.vo.req.FileParameters; import com.huoran.iasf.vo.req.FileParameters;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -49,6 +52,12 @@ public class SysFilesController {
@Resource @Resource
private SysFilesService sysFilesService; private SysFilesService sysFilesService;
@Autowired
private UserService userService;
@Resource
private HttpSessionService httpSessionService;
@ApiOperation(value = "上传文件前获取配置文件") @ApiOperation(value = "上传文件前获取配置文件")
@GetMapping("/upload") @GetMapping("/upload")
public String upload(@RequestParam(required = false) String action,HttpServletResponse response) throws IOException { public String upload(@RequestParam(required = false) String action,HttpServletResponse response) throws IOException {
@ -67,6 +76,8 @@ public class SysFilesController {
public UEditorResultVO add( public UEditorResultVO add(
@RequestParam(required = false) String action, @RequestParam(required = false) String action,
@RequestParam(value = "file") MultipartFile file, FileParameters fileParameters) { @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())) { if (file == null || file.getOriginalFilename() == null || "".equalsIgnoreCase(file.getOriginalFilename().trim())) {
UEditorResultVO uEditorResult = new UEditorResultVO(); UEditorResultVO uEditorResult = new UEditorResultVO();
@ -136,6 +147,14 @@ public class SysFilesController {
//查看文章未删除的 //查看文章未删除的
queryWrapper.eq(SysFilesEntity::getIsDel,0); queryWrapper.eq(SysFilesEntity::getIsDel,0);
IPage<SysFilesEntity> iPage = sysFilesService.page(sysFiles.getQueryPage(),queryWrapper); IPage<SysFilesEntity> 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); return R.success(iPage);
} }

Loading…
Cancel
Save