完成占用功能。
This commit is contained in:
parent
2cb8c77567
commit
79c62ba97c
|
|
@ -202,5 +202,15 @@ public class SysEdFileInfoController {
|
|||
return ElectromagneticResultUtil.success(edFileInfoService.findFavorite(userId, fileInfoQueryDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示当前用户收藏夹文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/flushDataStatus")
|
||||
@UserOperation(value = "刷新文件状态", modelName = UserOperationModuleEnum.SYS_PRJ_DATABASE)
|
||||
public ElectromagneticResult<?> flushDataStatus(@RequestParam String id) {
|
||||
return ElectromagneticResultUtil.success(edFileInfoService.flushDataStatus(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -243,4 +243,6 @@ public interface EdFileInfoService {
|
|||
* @return
|
||||
*/
|
||||
ElectromagneticResult<?> uploadFileAndRelation(String parentId, String id, MultipartFile file, String desc, int dataOwnCode);
|
||||
|
||||
boolean flushDataStatus(String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -652,7 +652,7 @@ public class CommonService {
|
|||
.setSaveStatus(EleDataSaveStatusEnum.UPLOADING.code)
|
||||
.setDataOwn(dataOwnCode)
|
||||
.setFileName(mainName)
|
||||
.setFileContent(EleCommonUtil.parse(file.getInputStream(), suffix))
|
||||
.setFileContent("")
|
||||
.setFileType(suffix)
|
||||
.setFileVersion(FILE_START_VERSION)
|
||||
.setFileSize(file.getSize())
|
||||
|
|
@ -708,7 +708,7 @@ public class CommonService {
|
|||
String timeStr = EleCommonUtil.getNowTimeStr();
|
||||
newEdFileInfo.setFileName(mainName)
|
||||
.setFileType(suffix)
|
||||
.setFileContent(EleCommonUtil.parse(file.getInputStream(), suffix))
|
||||
.setFileContent("")
|
||||
.setFileTime(timeStr)
|
||||
.setFileSize(file.getSize())
|
||||
.setDataType(EleDataTypeEnum.FILE.code)
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
this.baseMapper.update(Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.OCCUPY.code)
|
||||
.set(EdFileInfo::getUpdatedTime, new Date())
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id));
|
||||
.eq(EdFileInfo::getId, id));
|
||||
// 构建响应实体(可以返回<byte[]或Resource,返回类型取决body入参类型)
|
||||
return ResponseEntity
|
||||
.ok()
|
||||
|
|
@ -992,9 +992,6 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
EdFileInfo destFolderInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo.class, file -> !StrUtil.equals(file.getColumn(), "file_content"))
|
||||
.eq(EdFileInfo::getId, targetFolderId));
|
||||
this.baseMapper.update(Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.OCCUPY.code)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id));
|
||||
if (count == 0) {
|
||||
// 没有同名文件
|
||||
// 首先将信息保存到MySQL
|
||||
|
|
@ -1006,10 +1003,13 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.setFileTime(fileTime)
|
||||
.setDataOwn(dataOwnCode)
|
||||
.setFilePath(destFolderInfo.getFilePath() + MYSQL_FILE_PATH_SPLIT + srcFileInfo.getId())
|
||||
.setDataStatus(EleDataStatusEnum.OCCUPY.code)
|
||||
.setFileCode(newFileCode);
|
||||
this.baseMapper.updateById(srcFileInfo);
|
||||
} else {
|
||||
srcFileInfo = handMoveConflict(targetFolderId, strategy, srcFileInfo, destFolderInfo, dataOwnCode);
|
||||
srcFileInfo.setDataStatus(EleDataStatusEnum.OCCUPY.code);
|
||||
this.baseMapper.updateById(srcFileInfo);
|
||||
}
|
||||
UserThreadLocal.setSuccessInfo(srcFileInfo.getParentId(), srcFileInfo.getFileId(), "文件 {} 移动到 {},成功,处理文件同名同后缀的方式为 {},最终文件名为 {}", srcFileInfo.getFileName() + "." + srcFileInfo.getFileName(),
|
||||
commonService.getDbPath(destFolderInfo.getFilePath()), FileRepeatEnum.getDesc(strategy), srcFileInfo.getFileName());
|
||||
|
|
@ -1082,7 +1082,11 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ElectromagneticResult<?> copyFile(String id, String targetFolderId, Integer strategy, int dataOwnCode) {
|
||||
this.baseMapper.update(Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.OCCUPY.code)
|
||||
.eq(EdFileInfo::getId, id));
|
||||
Assert.isTrue(FileRepeatEnum.contains(strategy), "解决重名文件参数错误");
|
||||
// 获取原文件mysql模型
|
||||
EdFileInfo srcFileInfo = this.baseMapper.selectById1(id);
|
||||
|
|
@ -1094,9 +1098,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
|
||||
EdFileInfo destFolderInfo = this.baseMapper.selectById(targetFolderId);
|
||||
EdFileInfo destFileInfo;
|
||||
this.baseMapper.update(Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.OCCUPY.code)
|
||||
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id));
|
||||
|
||||
if (count == 0) {
|
||||
// 没有同名文件
|
||||
// 首先将信息保存到MySQL
|
||||
|
|
@ -1534,6 +1536,15 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
return ElectromagneticResultUtil.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean flushDataStatus(String id) {
|
||||
this.baseMapper.update(Wrappers.<EdFileInfo>lambdaUpdate()
|
||||
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
||||
.eq(EdFileInfo::getId, id));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 统一废除文件相关数据
|
||||
|
|
|
|||
|
|
@ -114,10 +114,7 @@ public final class EleCommonUtil {
|
|||
public static String parse(InputStream inputStream, String fileType) {
|
||||
|
||||
FileParse fileParse = PARSE_MAP.getOrDefault(fileType, null);
|
||||
if (fileParse == null) {
|
||||
return "";
|
||||
}
|
||||
return fileParse.parseAllText(inputStream, fileType);
|
||||
return fileParse == null ? "" : fileParse.parseAllText(inputStream, fileType);
|
||||
}
|
||||
|
||||
private static boolean between(int start, int end, char value) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue