v2.1.0 add:文件sdk 新增修改文件名称接口
This commit is contained in:
@ -131,4 +131,20 @@ public interface AttachmentClient {
|
||||
*/
|
||||
Optional<AttachmentEntity> copyByOid(String objectId, String newBusinessId);
|
||||
|
||||
/**
|
||||
* 根据对象id修改文件名称
|
||||
*
|
||||
* @param objectId
|
||||
* @param fileName
|
||||
*/
|
||||
boolean updateFileNameByOid(String objectId, String fileName);
|
||||
|
||||
/**
|
||||
* 根据业务id修改文件名称
|
||||
*
|
||||
* @param businessId
|
||||
* @param fileName
|
||||
*/
|
||||
boolean updateFileNameByBid(String businessId, String fileName);
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@ -306,6 +308,37 @@ public class DefaultAttachmentClient implements AttachmentClient {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据对象id修改文件名称
|
||||
*
|
||||
* @param objectId
|
||||
* @param fileName
|
||||
*/
|
||||
@Override
|
||||
public boolean updateFileNameByOid(String objectId, String fileName) {
|
||||
String json = documentCenterService.updateByBid(Collections.singletonList(new SysStorageVO().setFileId(objectId).setOriginalName(fileName)));
|
||||
return modelConvertor.toAttachmentEntity(json).orElseGet(AttachmentEntity::new).getId() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据业务id修改文件名称
|
||||
*
|
||||
* @param businessId
|
||||
* @param fileName
|
||||
*/
|
||||
@Override
|
||||
public boolean updateFileNameByBid(String businessId, String fileName) {
|
||||
return this.findByBusinessId(Collections.singletonList(businessId))
|
||||
.map(attachmentDetail -> {
|
||||
List<SysStorageVO> collect = attachmentDetail.get(businessId)
|
||||
.stream()
|
||||
.flatMap(o -> Stream.of(new SysStorageVO().setFileId(o.getId()).setOriginalName(fileName)))
|
||||
.collect(Collectors.toList());
|
||||
String json = documentCenterService.updateByBid(collect);
|
||||
return modelConvertor.toUploadObject(json).orElseGet(UploadObject::new).getId();
|
||||
}).isPresent();
|
||||
|
||||
}
|
||||
/////////////////////////////////////// Private Method
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user