From 71c0a947b137eed3349bf6597c729d6bea5fcb51 Mon Sep 17 00:00:00 2001 From: zhangqinbin <181961702@qq.com> Date: Thu, 14 Sep 2023 16:19:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=20=E9=87=91=E5=B1=B1pws?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extend/wps/controller/WpsController.java | 47 +++++++++++++++++++ .../ebtp/extend/wps/service/WpsService.java | 3 ++ .../wps/service/impl/WpsServiceImpl.java | 14 ++++++ 3 files changed, 64 insertions(+) diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java index 448a1ad..bb8274a 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java @@ -81,4 +81,51 @@ public class WpsController { return this.wpsService.saveWpsFile(token,userId,userName,fileId,fileName,file); } + /** + * (金山)获得编辑或查看链接 + * + * @param in + * @return + */ + @ApiOperation("(金山)获得编辑或查看链接") + @PostMapping("/kingSoft/getWpsUrl") + public BaseResponse getKSWpsUrl(WpsClientInVo in) { + WpsResultVo str = null;//this.wpsService.getWpsUrl(in); + log.info("----调用天擎WPS接口---getWpsUrl-------:"+str); + return BaseResponse.success(str); + } + /** + * (金山)沃文档回调-查询文档 + * 编辑 permission=write + * 预览 permission=read + * @param + * @return + */ + @ApiOperation("(金山)沃文档回调-查询文档") + @GetMapping("/kingSoft/file/{id}") + public BaseResponse getKSFile(@PathVariable String id) { + return BaseResponse.success(this.wpsService.getKSWpsFile(id)); + } + + /** + * 沃文档回调-保存文档 + * @param token + * @param userId + * @param userName + * @param fileId + * @param fileName + * @param file + * @return + */ + @ApiOperation("沃文档回调-保存文档") + @PostMapping("/kingSoft/file/save") + @OperationLogDetail(businessModule = EbtpLogBusinessModule.OTHER,operationType = EbtpLogType.SELECT,detail = "沃文档回调-保存文档") + public Object saveKSFile(@RequestHeader("X-Weboffice-Token") String token, + @RequestParam("_w_third_user_id") String userId, + @RequestParam("_w_third_user_name") String userName, + @RequestParam("_w_third_file_id") String fileId, + @RequestParam("_w_third_file_name") String fileName, + @RequestPart("file") File file) { + return this.wpsService.saveWpsFile(token,userId,userName,fileId,fileName,file); + } } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/WpsService.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/WpsService.java index 0926f08..379b275 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/WpsService.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/WpsService.java @@ -7,6 +7,7 @@ import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean; import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure; import com.chinaunicom.mall.ebtp.extend.wps.vo.WpsClientInVo; import com.chinaunicom.mall.ebtp.extend.wps.vo.WpsResultVo; +import org.springframework.web.bind.annotation.PathVariable; import java.io.File; import java.util.Map; @@ -22,4 +23,6 @@ public interface WpsService{ Object getWpsFile(String token, String userId, String userName, String fileId, String fileName, String permission); Object saveWpsFile(String token, String userId, String userName, String fileId, String fileName, File file); + + String getKSWpsFile(String id); } diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java index 6b5efe0..9c9ad25 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/service/impl/WpsServiceImpl.java @@ -2,12 +2,14 @@ package com.chinaunicom.mall.ebtp.extend.wps.service.impl; import cn.hutool.core.exceptions.ExceptionUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.api.AttachmentClient; 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 com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService; import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum; @@ -44,6 +46,7 @@ import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; +import java.util.zip.ZipEntry; /** * 沃文档-wps在线文档 @@ -467,6 +470,7 @@ public class WpsServiceImpl implements WpsService { return null; } + public static void main(String[] args) throws UnsupportedEncodingException { String str = URLEncoder.encode("file_preview,file_edit,file_format_control","utf-8"); System.out.println(str); @@ -475,4 +479,14 @@ public class WpsServiceImpl implements WpsService { System.out.println(str1); } + + @Override + public String getKSWpsFile(String id){ + Optional optional=attachmentClient.findByObjectId(id); + + Optional optional1 = attachmentClient.downloadFileByObjectId(optional.get().getId()); + + return new String(Base64.getEncoder().encode(optional1.get())); + } + }