公告结构化
This commit is contained in:
@ -37,6 +37,7 @@ import javax.servlet.http.Cookie;
|
|||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -44,6 +45,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static com.chinaunicom.mall.ebtp.cloud.security.starter.common.Constants.AUTHORIZATION_HEADER;
|
||||||
import static com.chinaunicom.mall.ebtp.cloud.security.starter.common.Constants.COOKIE_TOKEN_CODE;
|
import static com.chinaunicom.mall.ebtp.cloud.security.starter.common.Constants.COOKIE_TOKEN_CODE;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -149,6 +151,13 @@ public class WpsController {
|
|||||||
).findFirst());
|
).findFirst());
|
||||||
|
|
||||||
if (cookie.isPresent()) {
|
if (cookie.isPresent()) {
|
||||||
|
log.info(String.valueOf(request.getRequestURL()));
|
||||||
|
String protocol = request.getScheme(); // 获取协议,如HTTP或HTTPS
|
||||||
|
String ip = request.getRemoteAddr(); // 获取客户端IP地址
|
||||||
|
int port = request.getServerPort(); // 获取服务器端口号
|
||||||
|
String host = protocol+"://"+ip+":"+port;
|
||||||
|
log.info("getWpsUrlBy:"+host);
|
||||||
|
|
||||||
String authToken = cookie.get().getValue();
|
String authToken = cookie.get().getValue();
|
||||||
WpsClientInVo in = this.wpsService.getKSWpsUrlDecrypt(key,fileName);
|
WpsClientInVo in = this.wpsService.getKSWpsUrlDecrypt(key,fileName);
|
||||||
in.setUserToken(authToken);
|
in.setUserToken(authToken);
|
||||||
@ -245,23 +254,25 @@ public class WpsController {
|
|||||||
@ApiOperation("(金山)沃文档回调-查询文档")
|
@ApiOperation("(金山)沃文档回调-查询文档")
|
||||||
@GetMapping("/kingSoft/file2")
|
@GetMapping("/kingSoft/file2")
|
||||||
public boolean getKSFile2(HttpServletRequest request,HttpServletResponse response, @RequestParam("key") String key) {
|
public boolean getKSFile2(HttpServletRequest request,HttpServletResponse response, @RequestParam("key") String key) {
|
||||||
String fileId = this.wpsService.downloadDecrypt(key);
|
//带后缀
|
||||||
|
String fileNameE = this.wpsService.downloadDecrypt(key);
|
||||||
|
|
||||||
|
String[] fileId = fileNameE.split(".");
|
||||||
|
|
||||||
List<String> businessIdList = new ArrayList<>();
|
List<String> businessIdList = new ArrayList<>();
|
||||||
|
|
||||||
businessIdList.add(fileId);
|
businessIdList.add(fileId[0]);
|
||||||
|
|
||||||
Optional<AttachmentDetail> optional = attachmentClient.findByBusinessId(businessIdList);
|
Optional<AttachmentDetail> optional = attachmentClient.findByBusinessId(businessIdList);
|
||||||
|
|
||||||
|
String fileName = fileNameE;
|
||||||
String fileName = fileId;
|
|
||||||
String text = " ";
|
String text = " ";
|
||||||
byte buf[] = text.getBytes();
|
byte buf[] = text.getBytes();
|
||||||
String fileLength = String.valueOf(buf.length);
|
String fileLength = String.valueOf(buf.length);
|
||||||
|
|
||||||
if(optional!=null&&optional.get()!=null){
|
if(optional!=null&&optional.get()!=null){
|
||||||
AttachmentDetail detail = optional.get();
|
AttachmentDetail detail = optional.get();
|
||||||
List<AttachmentEntity> entityList = detail.get(fileId);
|
List<AttachmentEntity> entityList = detail.get(fileId[0]);
|
||||||
if(entityList!=null&&entityList.size()>0) {
|
if(entityList!=null&&entityList.size()>0) {
|
||||||
Optional<byte[]> optional1 = attachmentClient.downloadFileByObjectId(entityList.get(0).getId());
|
Optional<byte[]> optional1 = attachmentClient.downloadFileByObjectId(entityList.get(0).getId());
|
||||||
fileLength = String.valueOf(optional1.get().length);
|
fileLength = String.valueOf(optional1.get().length);
|
||||||
|
@ -551,7 +551,7 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
byte[] b = getFileByFileId(in.getFileId(),in.getFileName());
|
byte[] b = getFileByFileId(in.getFileId(),in.getFileName());
|
||||||
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
try {
|
try {
|
||||||
callBackUrl = kswdownloadUrl+"?key="+URLEncoder.encode(getDownloadEncrypt(in.getFileId(),in.getUserToken()), "utf-8");
|
callBackUrl = kswdownloadUrl+"?key="+URLEncoder.encode(getDownloadEncrypt(in.getFileId(),in.getFileExtension(),in.getUserToken()), "utf-8");
|
||||||
|
|
||||||
}catch (UnsupportedEncodingException e){
|
}catch (UnsupportedEncodingException e){
|
||||||
log.error("url转换失败",e);
|
log.error("url转换失败",e);
|
||||||
@ -610,9 +610,10 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
return ret.getData();
|
return ret.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDownloadEncrypt(String fileId,String token){
|
private String getDownloadEncrypt(String fileId,String fileExtension,String token){
|
||||||
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||||
//fileId+ebtp+token+time md5加密
|
//fileId+ebtp+token+time md5加密
|
||||||
|
fileId = fileId+"."+fileExtension;
|
||||||
String mdKey = MdConstants.getSha256(time+fileId+appName+token);
|
String mdKey = MdConstants.getSha256(time+fileId+appName+token);
|
||||||
log.info("mdKey:"+mdKey);
|
log.info("mdKey:"+mdKey);
|
||||||
//fileId|token|yyyyMMddHHmmss|md5加密
|
//fileId|token|yyyyMMddHHmmss|md5加密
|
||||||
|
Reference in New Issue
Block a user