mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
添加重命名接口
This commit is contained in:
@@ -139,6 +139,20 @@ public class NetDiskController {
|
||||
return this.service.preCreateFile(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/rename")
|
||||
@SysLog(action = "rename")
|
||||
public Boolean rename(@RequestBody UpdateNetDiskDto request) {
|
||||
|
||||
this.service.rename(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建文件分片
|
||||
*
|
||||
|
||||
@@ -596,13 +596,13 @@ public class NetDiskService extends BaseService<NetDiskEntity, NetDiskRepository
|
||||
src.setName(request.getNewName());
|
||||
}
|
||||
|
||||
// TreeUtils.allChildren(src, NetDiskEntity::getChildren)
|
||||
// .forEach(
|
||||
// x -> {
|
||||
// if (x.getId().equals(src.getId())) {
|
||||
// throw new BizException("不能复制到自己的子目录");
|
||||
// }
|
||||
// });
|
||||
// TreeUtils.allChildren(src, NetDiskEntity::getChildren)
|
||||
// .forEach(
|
||||
// x -> {
|
||||
// if (x.getId().equals(src.getId())) {
|
||||
// throw new BizException("不能复制到自己的子目录");
|
||||
// }
|
||||
// });
|
||||
|
||||
if (!target.getEntryType().equals("0")) {
|
||||
throw new BizException("只能复制到目录");
|
||||
@@ -888,7 +888,24 @@ public class NetDiskService extends BaseService<NetDiskEntity, NetDiskRepository
|
||||
|
||||
List<String> ans = this.repository.idToPath2(id);
|
||||
|
||||
List<NetDiskEntity> allById = this.repository.findAllById(ans).stream().sorted( Comparator.comparing(x -> ans.indexOf(x.getId()))).collect(Collectors.toList());
|
||||
List<NetDiskEntity> allById =
|
||||
this.repository.findAllById(ans).stream()
|
||||
.sorted(Comparator.comparing(x -> ans.indexOf(x.getId())))
|
||||
.collect(Collectors.toList());
|
||||
return this.mapper.toDto(allById);
|
||||
}
|
||||
|
||||
public void rename(UpdateNetDiskDto dto) {
|
||||
|
||||
NetDiskEntity entity = get(dto.getId());
|
||||
|
||||
if (entity.getParent() != null) {
|
||||
if (entity.getParent().getChildren().stream()
|
||||
.anyMatch(x -> x.getId() != dto.getId() && x.getName().equals(dto.getName()))) {
|
||||
throw new BizException("目录已经存在同名文件/文件夹");
|
||||
}
|
||||
}
|
||||
entity.setName(dto.getName());
|
||||
save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user