diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.java index 409e954..141e5be 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/AttachmentClient.java @@ -1,106 +1,122 @@ package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.api; -import java.io.File; -import java.util.List; -import java.util.Optional; - import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentDetail; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.DownloadEntity; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.UploadObject; +import java.io.File; +import java.util.List; +import java.util.Optional; + /** * 附件客户端工具类 - * + * * @author Ajaxfan */ public interface AttachmentClient { - /** - * @return 创建业务ID - */ - Optional getBusinessId(); + /** + * @return 创建业务ID + */ + Optional getBusinessId(); - /** - * 查询业务ID下的所有附件信息 - * - * @param bid - * @return - */ - Optional findByBusinessId(List businessIdList); + /** + * 查询业务ID下的所有附件信息 + * + * @param bid + * @return + */ + Optional findByBusinessId(List businessIdList); - /** - * 查询指定Id的对象信息 - * - * @param oid - * @return - */ - Optional findByObjectId(String objectId); + /** + * 查询指定Id的对象信息 + * + * @param oid + * @return + */ + Optional findByObjectId(String objectId); - /** - * 下载业务ID下的所有资源 - * - * @param bid - * @return - */ - Optional downloadFilesByBusinessId(String businessId); + /** + * 下载业务ID下的所有资源 + * + * @param bid + * @return + */ + Optional downloadFilesByBusinessId(String businessId); - /** - * 下载业务ID下的所有资源 - * - * @param bid - * @return - */ - Optional downloadOriginalFilesByBusinessId(String businessId); + /** + * 下载业务ID下的所有资源 + * + * @param bid + * @return + */ + Optional downloadOriginalFilesByBusinessId(String businessId); - /** - * 下载指定的资源数据 - * - * @param bid - * @param oid - * @return - */ - Optional downloadFileByObjectId(String objectId); + /** + * 下载指定的资源数据 + * + * @param bid + * @param oid + * @return + */ + Optional downloadFileByObjectId(String objectId); - /** - * 下载指定的资源数据 - * - * @param bid - * @param oid - * @return - */ - Optional downloadOriginalFileByObjectId(String objectId); + /** + * 下载指定的资源数据 + * + * @param bid + * @param oid + * @return + */ + Optional downloadOriginalFileByObjectId(String objectId); - /** - * 上传资源文件 - * - * @param bid - * @param file - * @return - */ - Optional upload(String businessId, File file); + /** + * 上传资源文件 + * + * @param bid + * @param file + * @return + */ + Optional upload(String businessId, File file); - /** - * 上传资源文件 - * - * @param bid - * @param file - * @return - */ - Optional upload(String businessId, String filename, byte[] array); + /** + * 上传资源文件 + * + * @param bid + * @param file + * @return + */ + Optional upload(String businessId, String filename, byte[] array); - /** - * 根据业务id删除附件 - * - * @param businessId - */ - boolean deleteByBid(String businessId); + /** + * 根据业务id删除附件 + * + * @param businessId + */ + boolean deleteByBid(String businessId); - /** - * 根据对象id删除附件 - * - * @param objectId - */ - String deleteByOid(String objectId); + /** + * 根据对象id删除附件 + * + * @param objectId + */ + String deleteByOid(String objectId); + + /** + * 根据业务id复制附件 + * + * @param oldBusinessId + * @param newBusinessId + */ + AttachmentDetail copyByBid(String oldBusinessId, String newBusinessId); + + /** + * 根据对象id复制附件 + * + * @param objectId + * @param newBusinessId + */ + Optional copyByOid(String objectId, String newBusinessId); } diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java index 37e7097..33855be 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/api/DefaultAttachmentClient.java @@ -1,21 +1,6 @@ package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.api; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -import javax.validation.constraints.NotNull; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - +import cn.hutool.core.util.IdUtil; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.FileConvertor; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.convertor.ModelConvertor; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentDetail; @@ -23,14 +8,24 @@ import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.DownloadEntity; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.UploadObject; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.service.DocumentCenterService; +import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.SysStorageVO; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.query.QueryResult; - -import cn.hutool.core.util.IdUtil; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +import javax.validation.constraints.NotNull; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; /** * 附件工具客户端默认实现 - * + * * @author Ajaxfan */ @Primary @@ -38,259 +33,304 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class DefaultAttachmentClient implements AttachmentClient { - /* 附件工具类服务 */ - private @Autowired DocumentCenterService documentCenterService; + /* 附件工具类服务 */ + private @Autowired + DocumentCenterService documentCenterService; - /* 模型转换器 */ - private @Autowired ModelConvertor modelConvertor; + /* 模型转换器 */ + private @Autowired + ModelConvertor modelConvertor; - /* 文件转换器 */ - private @Autowired FileConvertor fileConvertor; + /* 文件转换器 */ + private @Autowired + FileConvertor fileConvertor; - /** - * 生成业务id - * - * @return - */ - @Override - public Optional getBusinessId() { - return Optional.of(String.format("{\"id\":\"%s\"}", IdUtil.getSnowflake(23, 16).nextIdStr())); - } + /** + * 生成业务id + * + * @return + */ + @Override + public Optional getBusinessId() { + return Optional.of(String.format("{\"id\":\"%s\"}", IdUtil.getSnowflake(23, 16).nextIdStr())); + } - /** - * 查询指定Id文件的详细信息 - * - * @param objectId - * @return - */ - @Override - public Optional findByObjectId(String objectId) { - return modelConvertor.toAttachmentEntity(documentCenterService.getObjectDetail(objectId)); - } + /** + * 查询指定Id文件的详细信息 + * + * @param objectId + * @return + */ + @Override + public Optional findByObjectId(String objectId) { + return modelConvertor.toAttachmentEntity(documentCenterService.getObjectDetail(objectId)); + } - /** - * 根据业务id列表查询详单 - * - * @param businessIdList - * @return - */ - @Override - public Optional findByBusinessId(List businessIdList) { - log.debug("query by bids: {}", businessIdList); - String json = documentCenterService.fetchDetails(businessIdList); - log.debug("document center return: {}", json); + /** + * 根据业务id列表查询详单 + * + * @param businessIdList + * @return + */ + @Override + public Optional findByBusinessId(List businessIdList) { + log.debug("query by bids: {}", businessIdList); + String json = documentCenterService.fetchDetails(businessIdList); + log.debug("document center return: {}", json); - Optional op = modelConvertor.toQueryResult(json); + Optional op = modelConvertor.toQueryResult(json); - if (op.isPresent()) { - AttachmentDetail detail = new AttachmentDetail(); + if (op.isPresent()) { + AttachmentDetail detail = new AttachmentDetail(); - Optional.ofNullable(op.get().getData()).ifPresent(data -> { - data.forEach(item -> { - detail.add(new AttachmentEntity().setBid(item.getObjectId()).setId(item.getFileId()) - .setFilename(item.getOriginalName()).setKey(item.getFileName())); - }); - }); - return Optional.of(detail); - } - return Optional.empty(); - } + Optional.ofNullable(op.get().getData()).ifPresent(data -> { + data.forEach(item -> { + detail.add(new AttachmentEntity().setBid(item.getObjectId()).setId(item.getFileId()) + .setFilename(item.getOriginalName()).setKey(item.getFileName())); + }); + }); + return Optional.of(detail); + } + return Optional.empty(); + } - /** - * 通过对象id下载附件 - * - * @param objectId - * @return - */ - @Override - public Optional downloadFileByObjectId(String objectId) { - return Optional.ofNullable(documentCenterService.download(objectId)); - } + /** + * 通过对象id下载附件 + * + * @param objectId + * @return + */ + @Override + public Optional downloadFileByObjectId(String objectId) { + return Optional.ofNullable(documentCenterService.download(objectId)); + } - /** - * 根据业务id下载文件 - * - * @param businessId - * @return - */ - @Override - public Optional downloadFilesByBusinessId(String businessId) { - /** 文档中心不提提供通过业务id下载。因此,需要先通过业务id获取对象列表,然后下载每一个对象资源 */ - Optional op = findByBusinessId(Arrays.asList(businessId)); + /** + * 根据业务id下载文件 + * + * @param businessId + * @return + */ + @Override + public Optional downloadFilesByBusinessId(String businessId) { + /** 文档中心不提提供通过业务id下载。因此,需要先通过业务id获取对象列表,然后下载每一个对象资源 */ + Optional op = findByBusinessId(Arrays.asList(businessId)); - if (op.isPresent()) { - List list = op.get().get(businessId); + if (op.isPresent()) { + List list = op.get().get(businessId); - // 如果业务id下只包含单独一个文件,则直接返回该文件数据 - if (list.size() == 1) { - return downloadFileByObjectId(list.get(0).getId()); - } - // 如果大于1个则返回压缩包数据流 - else if (list.size() > 1) { - try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { - // 创建压缩文件流 - createCompressionStream(list, out); + // 如果业务id下只包含单独一个文件,则直接返回该文件数据 + if (list.size() == 1) { + return downloadFileByObjectId(list.get(0).getId()); + } + // 如果大于1个则返回压缩包数据流 + else if (list.size() > 1) { + try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { + // 创建压缩文件流 + createCompressionStream(list, out); - return Optional.of(out.toByteArray()); - } catch (IOException e) { - log.error(e.getMessage()); - } - } - } - return Optional.empty(); - } + return Optional.of(out.toByteArray()); + } catch (IOException e) { + log.error(e.getMessage()); + } + } + } + return Optional.empty(); + } - /** - * 下载原始对象格式(包含原始文件的基本信息) - * - * @param objectId - * @return - */ - @Override - public Optional downloadOriginalFileByObjectId(String objectId) { - // 获取对象文件原数据 - Optional op = modelConvertor.toDownloadEntity(documentCenterService.getObjectDetail(objectId)); - // 设置文件流 - op.ifPresent(entity -> { - entity.setStream(documentCenterService.download(objectId)); - }); - return op; - } + /** + * 下载原始对象格式(包含原始文件的基本信息) + * + * @param objectId + * @return + */ + @Override + public Optional downloadOriginalFileByObjectId(String objectId) { + // 获取对象文件原数据 + Optional op = modelConvertor.toDownloadEntity(documentCenterService.getObjectDetail(objectId)); + // 设置文件流 + op.ifPresent(entity -> { + entity.setStream(documentCenterService.download(objectId)); + }); + return op; + } - /** - * 下载业务资源 - * - * @param businessId - * @return - */ - @Override - public Optional downloadOriginalFilesByBusinessId(String businessId) { - Optional op = findByBusinessId(Arrays.asList(businessId)); + /** + * 下载业务资源 + * + * @param businessId + * @return + */ + @Override + public Optional downloadOriginalFilesByBusinessId(String businessId) { + Optional op = findByBusinessId(Arrays.asList(businessId)); - if (op.isPresent()) { - List list = op.get().get(businessId); + if (op.isPresent()) { + List list = op.get().get(businessId); - // 如果业务id下只包含单独一个文件,则直接返回该文件数据 - if (list.size() == 1) { - return downloadOriginalFileByObjectId(list.get(0).getId()); - } - // 如果大于1个则返回压缩包数据流 - else if (list.size() > 1) { - try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { - // 创建压缩文件流 - createCompressionStream(list, out); + // 如果业务id下只包含单独一个文件,则直接返回该文件数据 + if (list.size() == 1) { + return downloadOriginalFileByObjectId(list.get(0).getId()); + } + // 如果大于1个则返回压缩包数据流 + else if (list.size() > 1) { + try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { + // 创建压缩文件流 + createCompressionStream(list, out); - return Optional.of(new DownloadEntity().setFilename(String.format("%s.zip", UUID.randomUUID())) - .setStream(out.toByteArray())); - } catch (IOException e) { - log.error(e.getMessage()); - } - } - } - return Optional.empty(); - } + return Optional.of(new DownloadEntity().setFilename(String.format("%s.zip", UUID.randomUUID())) + .setStream(out.toByteArray())); + } catch (IOException e) { + log.error(e.getMessage()); + } + } + } + return Optional.empty(); + } - /** - * 文件上传 - * - * @param businessId - * @param file - * @return - */ - @Override - public Optional upload(@NotNull String businessId, @NotNull File file) { - removeDuplicateObject(businessId, file.getName()); + /** + * 文件上传 + * + * @param businessId + * @param file + * @return + */ + @Override + public Optional upload(@NotNull String businessId, @NotNull File file) { + removeDuplicateObject(businessId, file.getName()); - String res = documentCenterService.upload("ebtp-mall-cloud", businessId, fileConvertor.toMultipartFile(file)); + String res = documentCenterService.upload("ebtp-mall-cloud", businessId, fileConvertor.toMultipartFile(file)); - log.info("document center upload result: {}", res); + log.info("document center upload result: {}", res); - return modelConvertor.toUploadObject(res); - } + return modelConvertor.toUploadObject(res); + } - /** - * @param businessId - * @param filename - * @param array - * @return - */ - @Override - public Optional upload(@NotNull String businessId, @NotNull String filename, @NotNull byte[] array) { - removeDuplicateObject(businessId, filename); + /** + * @param businessId + * @param filename + * @param array + * @return + */ + @Override + public Optional upload(@NotNull String businessId, @NotNull String filename, @NotNull byte[] array) { + removeDuplicateObject(businessId, filename); - String res = documentCenterService.upload("ebtp-mall-cloud", businessId, - fileConvertor.toMultipartFile(filename, array)); + String res = documentCenterService.upload("ebtp-mall-cloud", businessId, + fileConvertor.toMultipartFile(filename, array)); - log.info("document center upload result: {}", res); + log.info("document center upload result: {}", res); - return modelConvertor.toUploadObject(res); - } + return modelConvertor.toUploadObject(res); + } - /** - * @param businessId - * @return - */ - @Override - public boolean deleteByBid(String businessId) { - Optional op = findByBusinessId(Arrays.asList(businessId)); + /** + * @param businessId + * @return + */ + @Override + public boolean deleteByBid(String businessId) { + Optional op = findByBusinessId(Arrays.asList(businessId)); - op.ifPresent(attachmentDetail -> { - attachmentDetail.values().forEach(collection -> { - collection.forEach(attachmentEntity -> { - documentCenterService.deleteByOid(attachmentEntity.getId()); - }); - }); - }); - return op.map(detail -> detail.values().size() > 0).orElseGet(() -> false); - } + op.ifPresent(attachmentDetail -> { + attachmentDetail.values().forEach(collection -> { + collection.forEach(attachmentEntity -> { + documentCenterService.deleteByOid(attachmentEntity.getId()); + }); + }); + }); + return op.map(detail -> detail.values().size() > 0).orElseGet(() -> false); + } - /** - * @param objectId - * @return - */ - @Override - public String deleteByOid(String objectId) { - return documentCenterService.deleteByOid(objectId); - } + /** + * @param objectId + * @return + */ + @Override + public String deleteByOid(String objectId) { + return documentCenterService.deleteByOid(objectId); + } - /////////////////////////////////////// Private Method - /** - * 根据业务要求, bid下不能挂在同名文件,需要去重 - * - * @param businessId - * @param filename - */ - private void removeDuplicateObject(String businessId, String filename) { - log.info("remove files {} in business: {} if exists", filename, businessId); - Optional op = findByBusinessId(Arrays.asList(businessId)); + /** + * 根据业务id复制附件 + * + * @param businessId + */ + @Override + public AttachmentDetail copyByBid(String businessId, String newBusinessId) { + AttachmentDetail result = new AttachmentDetail(); - op.ifPresent(detail -> { - detail.get(businessId).stream().filter(obj -> obj.getFilename().equals(filename)).forEach(obj -> { - deleteByOid(obj.getId()); - }); - }); - } + this.findByBusinessId(Collections.singletonList(businessId)) + .ifPresent(attachmentDetail -> + attachmentDetail.get(businessId).forEach( + o -> this.copyByOid(o.getId(), newBusinessId).ifPresent(result::add))); + return result; + } - /** - * 创建压缩文件流 - * - * @param list - * @param out - * @throws IOException - */ - private void createCompressionStream(List list, ByteArrayOutputStream out) throws IOException { - try (ZipOutputStream zout = new ZipOutputStream(out)) { - list.forEach(data -> { - downloadFileByObjectId(data.getId()).ifPresent(buffer -> { - try { - zout.putNextEntry(new ZipEntry(data.getFilename()));// 文件项名称 - zout.write(buffer);// 文件数据流 - } catch (IOException e) { - log.error(e.getMessage()); - } - }); - }); - } - } + /** + * 根据对象id复制附件 + * + * @param objectId + */ + @Override + public Optional copyByOid(String objectId, String newBusinessId) { + //复制 + Optional opt = modelConvertor.toUploadObject(documentCenterService.copyByOid(objectId)); + //修改bid + if (opt.isPresent()) { + UploadObject uploadObject = opt.get(); + + String json = documentCenterService.updateByBid(Collections.singletonList(new SysStorageVO().setFileId(uploadObject.getId()).setObjectId(newBusinessId))); + Optional updateOtp = modelConvertor.toUploadObject(json); + if (updateOtp.isPresent()) { + UploadObject uo = updateOtp.get(); + if (uo.getId() != null && uo.getId().equals(uploadObject.getId())) { + return Optional.of(new AttachmentEntity().setId(uo.getId()).setBid(newBusinessId)); + } + } + } + return Optional.empty(); + } + + /////////////////////////////////////// Private Method + + /** + * 根据业务要求, bid下不能挂在同名文件,需要去重 + * + * @param businessId + * @param filename + */ + private void removeDuplicateObject(String businessId, String filename) { + log.info("remove files {} in business: {} if exists", filename, businessId); + Optional op = findByBusinessId(Arrays.asList(businessId)); + + op.ifPresent(detail -> { + detail.get(businessId).stream().filter(obj -> obj.getFilename().equals(filename)).forEach(obj -> { + deleteByOid(obj.getId()); + }); + }); + } + + /** + * 创建压缩文件流 + * + * @param list + * @param out + * @throws IOException + */ + private void createCompressionStream(List list, ByteArrayOutputStream out) throws IOException { + try (ZipOutputStream zout = new ZipOutputStream(out)) { + list.forEach(data -> { + downloadFileByObjectId(data.getId()).ifPresent(buffer -> { + try { + zout.putNextEntry(new ZipEntry(data.getFilename()));// 文件项名称 + zout.write(buffer);// 文件数据流 + } catch (IOException e) { + log.error(e.getMessage()); + } + }); + }); + } + } } diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/DocumentCenterServiceFallback.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/DocumentCenterServiceFallback.java index f387b57..cafb06d 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/DocumentCenterServiceFallback.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/fallback/DocumentCenterServiceFallback.java @@ -2,6 +2,7 @@ package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.fallback; import java.util.List; +import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.SysStorageVO; import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; @@ -35,4 +36,13 @@ public class DocumentCenterServiceFallback implements DocumentCenterService { return new byte[0]; } + @Override + public String updateByBid(List sysStorageVO) { + return null; + } + + @Override + public String copyByOid(String fileId) { + return null; + } } diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/DocumentCenterService.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/DocumentCenterService.java index 766cab0..e5f46dc 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/DocumentCenterService.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/service/DocumentCenterService.java @@ -1,70 +1,84 @@ package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.service; +import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.fallback.DocumentCenterServiceFallback; +import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.SysStorageVO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + import java.util.List; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.fallback.DocumentCenterServiceFallback; - /** * 连接山分的文档中心服务 - * + * * @author Ajaxfan */ -//@FeignClient(name = "DocumentCenterService", url = "${document.center.ip-address}", fallback = DocumentCenterServiceFallback.class) -@FeignClient(name = "${document.center.service.id}", fallback = DocumentCenterServiceFallback.class) +@FeignClient(name = "DocumentCenterService", url = "${document.center.ip-address}", fallback = DocumentCenterServiceFallback.class) +//@FeignClient(name = "${document.center.service.id}", fallback = DocumentCenterServiceFallback.class) public interface DocumentCenterService { - /** - * 通过附件id查询明细 - * - * @param fileId - * @return - */ - @RequestMapping(method = RequestMethod.GET, value = "v1.0/files/download") - byte[] download(@RequestParam("fileId") String fileId); + /** + * 通过附件id查询明细 + * + * @param fileId + * @return + */ + @RequestMapping(method = RequestMethod.GET, value = "v1.0/files/download") + byte[] download(@RequestParam("fileId") String fileId); - /** - * 通过附件id查询明细 - * - * @param fileId - * @return - */ - @RequestMapping(method = RequestMethod.POST, value = "v1.0/files/findById") - String getObjectDetail(@RequestParam("fileId") String fileId); + /** + * 通过附件id查询明细 + * + * @param fileId + * @return + */ + @RequestMapping(method = RequestMethod.POST, value = "v1.0/files/findById") + String getObjectDetail(@RequestParam("fileId") String fileId); - /** - * 通过业务id列表获取明细 - * - * @param bids - * @return - */ - @RequestMapping(method = RequestMethod.POST, value = "v1.0/files/queryReturn") - String fetchDetails(@RequestBody List bids); + /** + * 通过业务id列表获取明细 + * + * @param bids + * @return + */ + @RequestMapping(method = RequestMethod.POST, value = "v1.0/files/queryReturn") + String fetchDetails(@RequestBody List bids); - /** - * 上传文件 - * - * @return - */ - @RequestMapping(method = RequestMethod.POST, value = "/v1.0/files/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - String upload(@RequestPart("appCode") String appCode, @RequestPart("objectId") String objectId, - @RequestPart("multipartFiles") MultipartFile multipartFiles); + /** + * 上传文件 + * + * @return + */ + @RequestMapping(method = RequestMethod.POST, value = "/v1.0/files/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + String upload(@RequestPart("appCode") String appCode, @RequestPart("objectId") String objectId, + @RequestPart("multipartFiles") MultipartFile multipartFiles); - /** - * 删除附件信息 - * - * @param fileId - * @return - */ - @RequestMapping(method = RequestMethod.POST, value = "v1.0/files/disk") - String deleteByOid(@RequestParam("fileId") String fileId); + /** + * 删除附件信息 + * + * @param fileId + * @return + */ + @RequestMapping(method = RequestMethod.POST, value = "v1.0/files/disk") + String deleteByOid(@RequestParam("fileId") String fileId); + + /** + * 根据fileid进行附件的复制 + * + * @param fileId + * @return + */ + @RequestMapping(method = RequestMethod.POST, value = "v1.0/files/copy/") + String copyByOid(@RequestParam("fileId") String fileId); + + /** + * 根据fileid更新附件表信息 + * + * @param sysStorageVO + * @return + */ + @RequestMapping(method = RequestMethod.POST, value = "v1.0/files/update/") + String updateByBid(@RequestBody List sysStorageVO); } diff --git a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/SysStorageVO.java b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/SysStorageVO.java index cafc118..d714e5f 100644 --- a/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/SysStorageVO.java +++ b/mall-ebtp-cloud-attachment-sdk/src/main/java/com/chinaunicom/ebtp/mall/cloud/attachment/sdk/vo/SysStorageVO.java @@ -1,8 +1,10 @@ package com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo; import lombok.Data; +import lombok.experimental.Accessors; @Data +@Accessors(chain = true) public class SysStorageVO { /* 文件原始名称 */