Browse Source

[feat]通用文件方法,添加文件上传用户,上传时间。

dev
zhangsiqi 6 months ago
parent
commit
2b57a4f1ba
  1. 6
      ruoyi-admin/src/main/java/com/ruoyi/common/service/impl/CommonServiceImpl.java

6
ruoyi-admin/src/main/java/com/ruoyi/common/service/impl/CommonServiceImpl.java

@ -3,7 +3,10 @@ package com.ruoyi.common.service.impl;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.config.ServerConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.service.ICommonService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.system.domain.SysAttach;
@ -84,6 +87,7 @@ public class CommonServiceImpl implements ICommonService {
public AjaxResult uploadSingleFile(MultipartFile file) {
try
{
String loginName = ShiroUtils.getLoginName();
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
@ -99,6 +103,8 @@ public class CommonServiceImpl implements ICommonService {
sysAttachFile.setSize(fileSize);
sysAttachFile.setExt(fileExt);
sysAttachFile.setPath(fileName);
sysAttachFile.setCreateBy(loginName);
sysAttachFile.setCreateTime(DateUtils.getNowDate());
attachFileService.insertSysAttachFile(sysAttachFile);
AjaxResult ajax = AjaxResult.success(sysAttachFile);
return ajax;

Loading…
Cancel
Save