fix(file): 上传文件微调
This commit is contained in:
@@ -29,9 +29,6 @@ public class DBFileClient extends AbstractFileClient<DBFileClientConfig> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String upload(byte[] content, String path, String type) {
|
public String upload(byte[] content, String path, String type) {
|
||||||
FileContentDO contentDO = new FileContentDO().setConfigId(getId())
|
|
||||||
.setPath(path).setContent(content);
|
|
||||||
fileContentMapper.insert(contentDO);
|
|
||||||
// 拼接返回路径
|
// 拼接返回路径
|
||||||
return super.formatFileUrl(config.getDomain(), path);
|
return super.formatFileUrl(config.getDomain(), path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ import com.njcn.rdms.framework.common.util.object.BeanUtils;
|
|||||||
import com.njcn.rdms.module.system.controller.admin.file.vo.file.FileCreateReqVO;
|
import com.njcn.rdms.module.system.controller.admin.file.vo.file.FileCreateReqVO;
|
||||||
import com.njcn.rdms.module.system.controller.admin.file.vo.file.FilePageReqVO;
|
import com.njcn.rdms.module.system.controller.admin.file.vo.file.FilePageReqVO;
|
||||||
import com.njcn.rdms.module.system.controller.admin.file.vo.file.FilePresignedUrlRespVO;
|
import com.njcn.rdms.module.system.controller.admin.file.vo.file.FilePresignedUrlRespVO;
|
||||||
|
import com.njcn.rdms.module.system.dal.dataobject.file.FileContentDO;
|
||||||
import com.njcn.rdms.module.system.dal.dataobject.file.FileDO;
|
import com.njcn.rdms.module.system.dal.dataobject.file.FileDO;
|
||||||
|
import com.njcn.rdms.module.system.dal.mysql.file.FileContentMapper;
|
||||||
import com.njcn.rdms.module.system.dal.mysql.file.FileMapper;
|
import com.njcn.rdms.module.system.dal.mysql.file.FileMapper;
|
||||||
import com.njcn.rdms.module.system.framework.file.core.client.FileClient;
|
import com.njcn.rdms.module.system.framework.file.core.client.FileClient;
|
||||||
import com.njcn.rdms.module.system.framework.file.core.utils.FileTypeUtils;
|
import com.njcn.rdms.module.system.framework.file.core.utils.FileTypeUtils;
|
||||||
@@ -36,13 +38,13 @@ public class FileServiceImpl implements FileService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传文件的前缀,是否包含日期(yyyyMMdd)
|
* 上传文件的前缀,是否包含日期(yyyyMMdd)
|
||||||
*
|
* <p>
|
||||||
* 目的:按照日期,进行分目录
|
* 目的:按照日期,进行分目录
|
||||||
*/
|
*/
|
||||||
static boolean PATH_PREFIX_DATE_ENABLE = true;
|
static boolean PATH_PREFIX_DATE_ENABLE = true;
|
||||||
/**
|
/**
|
||||||
* 上传文件的后缀,是否包含时间戳
|
* 上传文件的后缀,是否包含时间戳
|
||||||
*
|
* <p>
|
||||||
* 目的:保证文件的唯一性,避免覆盖
|
* 目的:保证文件的唯一性,避免覆盖
|
||||||
* 定制:可按需调整成 UUID、或者其他方式
|
* 定制:可按需调整成 UUID、或者其他方式
|
||||||
*/
|
*/
|
||||||
@@ -54,6 +56,9 @@ public class FileServiceImpl implements FileService {
|
|||||||
@Resource
|
@Resource
|
||||||
private FileMapper fileMapper;
|
private FileMapper fileMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FileContentMapper fileContentMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<FileDO> getFilePage(FilePageReqVO pageReqVO) {
|
public PageResult<FileDO> getFilePage(FilePageReqVO pageReqVO) {
|
||||||
return fileMapper.selectPage(pageReqVO);
|
return fileMapper.selectPage(pageReqVO);
|
||||||
@@ -90,6 +95,9 @@ public class FileServiceImpl implements FileService {
|
|||||||
.setName(name).setPath(path).setUrl(url)
|
.setName(name).setPath(path).setUrl(url)
|
||||||
.setType(type).setSize((long) content.length);
|
.setType(type).setSize((long) content.length);
|
||||||
fileMapper.insert(file);
|
fileMapper.insert(file);
|
||||||
|
FileContentDO contentDO = new FileContentDO().setConfigId(file.getId())
|
||||||
|
.setPath(path).setContent(content);
|
||||||
|
fileContentMapper.insert(contentDO);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user