Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
d5f7ebc4
Commit
d5f7ebc4
authored
Jul 29, 2019
by
songxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
错题本2.75期相关代码
parent
56de0445
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
291 additions
and
122 deletions
+291
-122
FilePathConstant.java
...ain/java/com/pcloud/common/constant/FilePathConstant.java
+69
-0
StoreFlowInfoDto.java
...src/main/java/com/pcloud/common/dto/StoreFlowInfoDto.java
+149
-0
FileUtils.java
...mmon/src/main/java/com/pcloud/common/utils/FileUtils.java
+5
-5
ImageUtils.java
...mon/src/main/java/com/pcloud/common/utils/ImageUtils.java
+39
-85
PictureUtil.java
...on/src/main/java/com/pcloud/common/utils/PictureUtil.java
+0
-0
OssUtils.java
...rc/main/java/com/pcloud/common/utils/aliyun/OssUtils.java
+3
-3
UrlUtils.java
...ain/java/com/pcloud/common/utils/httpclient/UrlUtils.java
+2
-18
PdfUtils.java
...n/src/main/java/com/pcloud/common/utils/pdf/PdfUtils.java
+5
-7
StringUtil.java
.../main/java/com/pcloud/common/utils/string/StringUtil.java
+15
-0
WordNewUtils.java
.../main/java/com/pcloud/common/utils/word/WordNewUtils.java
+0
-0
WordUtils.java
...src/main/java/com/pcloud/common/utils/word/WordUtils.java
+4
-4
No files found.
pcloud-common/src/main/java/com/pcloud/common/constant/FilePathConstant.java
0 → 100644
View file @
d5f7ebc4
/*
* 武汉理工数字传播工程有限公司源代码,版权归武汉理工数字传播工程有限公司所有.
* 项目名称 : pcloud-common
* 创建日期 : 2017年3月3日
* 修改历史 :
* 1. [2017年3月3日]创建文件 by xnxqs
*/
package
com
.
pcloud
.
common
.
constant
;
/**
*
*
* @Author: songx
* @Date: 2019/7/29,14:11
*/
public
class
FilePathConstant
{
/**
* 视频剪切文件夹
*/
public
final
static
String
CUT
=
getFolder
(
"cut"
);
/**
* 下载文件夹
*/
public
final
static
String
DOWNLOAD
=
getFolder
(
"download"
);
/**
* 生成图片地址
*/
public
final
static
String
IMAGE
=
getFolder
(
"image"
);
/**
* 生成带水印文件夹
*/
public
final
static
String
IMAGE_WATERMARK
=
getFolder
(
"image/watermark"
);
/**
* 生成音频文件夹
*/
public
final
static
String
AUDIO
=
getFolder
(
"audio"
);
/**
* 生成PDF文件夹
*/
public
final
static
String
PDF
=
getFolder
(
"pdf"
);
/**
* 生成WORD文件夹
*/
public
final
static
String
WORD
=
getFolder
(
"word"
);
/**
* 生成TEXT文件夹
*/
public
final
static
String
TEXT
=
getFolder
(
"text"
);
/**
* 组装文件夹路径
*
* @param folderName
* @return
*/
private
static
String
getFolder
(
String
folderName
)
{
return
OSConstant
.
USERDIR
+
OSConstant
.
SEPARATOR
+
"files"
+
folderName
+
OSConstant
.
SEPARATOR
;
}
}
pcloud-common/src/main/java/com/pcloud/common/dto/StoreFlowInfoDto.java
0 → 100644
View file @
d5f7ebc4
package
com
.
pcloud
.
common
.
dto
;
import
com.pcloud.common.dto.BaseDto
;
import
java.math.BigDecimal
;
/**
* @Describe: TODO
* @Author: zhangdongwei
* @Date: Create on 11:35 2019/7/24 0024
*/
public
class
StoreFlowInfoDto
extends
BaseDto
{
/**
* 标识(appId/productId/bookGroupId)
*/
private
Long
originId
;
/**
* 类型(APP/PRODUCT/BOOK_GROUP)
*/
private
String
originType
;
/**
*具体类型
*/
private
String
typeCode
;
/**
* 标题
*/
private
String
title
;
/**
* 封面图片
*/
private
String
coverImg
;
/**
* 价格
*/
private
BigDecimal
price
;
/**
* 开始时间(MM-dd)
*/
private
String
startDate
;
/**
* 结束时间(MM-dd)
*/
private
String
endDate
;
/**
* 数量(应用、作品下的资源数量, 社群书的群数量,等)
*/
private
Integer
resourceNum
;
/**
* 数量(资源的item数量,群的成员数量,等)
*/
private
Integer
resourceItemNum
;
public
Long
getOriginId
()
{
return
originId
;
}
public
void
setOriginId
(
Long
originId
)
{
this
.
originId
=
originId
;
}
public
String
getOriginType
()
{
return
originType
;
}
public
void
setOriginType
(
String
originType
)
{
this
.
originType
=
originType
;
}
public
String
getTypeCode
()
{
return
typeCode
;
}
public
void
setTypeCode
(
String
typeCode
)
{
this
.
typeCode
=
typeCode
;
}
public
String
getTitle
()
{
return
title
;
}
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
public
String
getCoverImg
()
{
return
coverImg
;
}
public
void
setCoverImg
(
String
coverImg
)
{
this
.
coverImg
=
coverImg
;
}
public
BigDecimal
getPrice
()
{
return
price
;
}
public
void
setPrice
(
BigDecimal
price
)
{
this
.
price
=
price
;
}
public
String
getStartDate
()
{
return
startDate
;
}
public
void
setStartDate
(
String
startDate
)
{
this
.
startDate
=
startDate
;
}
public
String
getEndDate
()
{
return
endDate
;
}
public
void
setEndDate
(
String
endDate
)
{
this
.
endDate
=
endDate
;
}
public
Integer
getResourceNum
()
{
return
resourceNum
;
}
public
void
setResourceNum
(
Integer
resourceNum
)
{
this
.
resourceNum
=
resourceNum
;
}
public
Integer
getResourceItemNum
()
{
return
resourceItemNum
;
}
public
void
setResourceItemNum
(
Integer
resourceItemNum
)
{
this
.
resourceItemNum
=
resourceItemNum
;
}
@Override
public
String
toString
()
{
return
"StoreFlowInfoDto{"
+
"originId="
+
originId
+
", originType='"
+
originType
+
'\''
+
", typeCode='"
+
typeCode
+
'\''
+
", title='"
+
title
+
'\''
+
", coverImg='"
+
coverImg
+
'\''
+
", price="
+
price
+
", startDate='"
+
startDate
+
'\''
+
", endDate='"
+
endDate
+
'\''
+
", resourceNum="
+
resourceNum
+
", resourceItemNum="
+
resourceItemNum
+
"} "
+
super
.
toString
();
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/FileUtils.java
View file @
d5f7ebc4
...
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
...
@@ -29,7 +29,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.pcloud.common.constant.AliyunConstant
;
import
com.pcloud.common.constant.AliyunConstant
;
import
com.pcloud.common.constant.FilePathConst
;
import
com.pcloud.common.constant.FilePathConst
ant
;
import
com.pcloud.common.constant.OSConstant
;
import
com.pcloud.common.constant.OSConstant
;
import
com.pcloud.common.entity.UploadResultInfo
;
import
com.pcloud.common.entity.UploadResultInfo
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.BizException
;
...
@@ -215,7 +215,7 @@ public class FileUtils {
...
@@ -215,7 +215,7 @@ public class FileUtils {
/**
/**
* 传入文件夹路径,该方法能够实现创建整个路径
* 传入文件夹路径,该方法能够实现创建整个路径
*
*
* @param
p
ath
* @param
fileP
ath
* 文件夹路径,不包含文件名称及后缀名
* 文件夹路径,不包含文件名称及后缀名
*/
*/
public
static
boolean
isDir
(
String
filePath
)
{
public
static
boolean
isDir
(
String
filePath
)
{
...
@@ -882,7 +882,7 @@ public class FileUtils {
...
@@ -882,7 +882,7 @@ public class FileUtils {
String
fileType
=
getFileType
(
url
);
String
fileType
=
getFileType
(
url
);
String
localFilePath
=
url
;
String
localFilePath
=
url
;
if
(
url
.
startsWith
(
"http"
))
{
if
(
url
.
startsWith
(
"http"
))
{
localFilePath
=
FilePathConst
.
TEXT_PATH
+
UUIDUitl
.
taskName
()
+
"."
+
fileType
;
localFilePath
=
FilePathConst
ant
.
TEXT
+
UUIDUitl
.
taskName
()
+
"."
+
fileType
;
downloadFileFromUrl
(
url
,
localFilePath
);
downloadFileFromUrl
(
url
,
localFilePath
);
}
}
try
{
try
{
...
@@ -919,7 +919,7 @@ public class FileUtils {
...
@@ -919,7 +919,7 @@ public class FileUtils {
return
null
;
return
null
;
}
}
// 下载文件
// 下载文件
String
downloadPath
=
FilePathConst
.
DOWNLOAD_PATH
+
UUIDUitl
.
generateString
(
32
)
+
"."
+
fileType
;
String
downloadPath
=
FilePathConst
ant
.
DOWNLOAD
+
UUIDUitl
.
generateString
(
32
)
+
"."
+
fileType
;
FileUtils
.
downloadFileFromUrl
(
url
,
downloadPath
);
FileUtils
.
downloadFileFromUrl
(
url
,
downloadPath
);
// 剪切文件
// 剪切文件
String
cutPath
=
clipByPercent
(
new
File
(
downloadPath
),
percent
);
String
cutPath
=
clipByPercent
(
new
File
(
downloadPath
),
percent
);
...
@@ -969,7 +969,7 @@ public class FileUtils {
...
@@ -969,7 +969,7 @@ public class FileUtils {
throw
new
FileException
(
FileException
.
FILE_READ_FAILURE
,
"剪切的文件必须大于1KB"
);
throw
new
FileException
(
FileException
.
FILE_READ_FAILURE
,
"剪切的文件必须大于1KB"
);
}
}
// 输出文件路径
// 输出文件路径
String
outFilePath
=
FilePathConst
.
CUT_PATH
+
UUIDUitl
.
generateString
(
12
)
+
"_"
+
inputFile
.
getName
();
String
outFilePath
=
FilePathConst
ant
.
CUT
+
UUIDUitl
.
generateString
(
12
)
+
"_"
+
inputFile
.
getName
();
creatFiles
(
outFilePath
);
creatFiles
(
outFilePath
);
// 剪切长度
// 剪切长度
cutLength
=
cutLength
>
inputFile
.
length
()
?
inputFile
.
length
()
:
cutLength
;
cutLength
=
cutLength
>
inputFile
.
length
()
?
inputFile
.
length
()
:
cutLength
;
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/ImageUtils.java
View file @
d5f7ebc4
...
@@ -11,16 +11,12 @@ import java.math.BigDecimal;
...
@@ -11,16 +11,12 @@ import java.math.BigDecimal;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.itextpdf.text.Image
;
import
com.itextpdf.text.Image
;
import
com.pcloud.common.constant.AliyunConstant
;
import
com.pcloud.common.constant.AliyunConstant
;
import
com.pcloud.common.constant.FilePathConst
;
import
com.pcloud.common.constant.ImageConstant
;
import
com.pcloud.common.constant.ImageConstant
;
import
com.pcloud.common.entity.UploadResultInfo
;
import
com.pcloud.common.enums.ImageEnum
;
import
com.pcloud.common.enums.ImageEnum
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.FileException
;
import
com.pcloud.common.exceptions.FileException
;
...
@@ -738,37 +734,32 @@ public class ImageUtils {
...
@@ -738,37 +734,32 @@ public class ImageUtils {
* @param fileUrl
* @param fileUrl
* @return
* @return
*/
*/
// public static UploadResultInfo transcodeToWebp(String fileUrl, int quality) {
// public static UploadResultInfo transcodeToWebp(String fileUrl, int quality) {
// LOGGER.info("【IMAGE API】image transcode to webp.<START>.[fileUrl]=" + fileUrl
// LOGGER.info("【IMAGE API】image transcode to webp.<START>.[fileUrl]=" + fileUrl + ",[quality]=" + quality);
// + ",[quality]=" + quality);
// String fileNameAll = FileUtils.getFileNameAll(fileUrl);
// String fileNameAll = FileUtils.getFileNameAll(fileUrl);
// String localFilePath = FilePathConstant.DOWNLOAD_PATH + fileNameAll;
// String localFilePath = FilePathConst.DOWNLOAD_PATH + fileNameAll;
// FileUtils.downloadFileFromUrl(fileUrl, localFilePath);
// FileUtils.downloadFileFromUrl(fileUrl, localFilePath);
// String outputFilePath = FilePathConstant.IMAGE_PATH + "webp/" + fileNameAll + ".webp";
// String outputFilePath = FilePathConst.IMAGE_PATH + "webp/" + fileNameAll +
// FileUtils.creatFiles(outputFilePath);
// ".webp";
// UploadResultInfo uploadResultInfo = null;
// FileUtils.creatFiles(outputFilePath);
// try {
// UploadResultInfo uploadResultInfo = null;
// String os = System.getProperty("os.name");
// try {
// if (os.toLowerCase().startsWith("win")) {
// String os = System.getProperty("os.name");
// executeCwebp4Win(localFilePath, outputFilePath, quality);
// if (os.toLowerCase().startsWith("win")) {
// } else {
// executeCwebp4Win(localFilePath, outputFilePath, quality);
// executeCwebp4Linux(localFilePath, outputFilePath, quality);
// } else {
// }
// executeCwebp4Linux(localFilePath, outputFilePath, quality);
// uploadResultInfo = OssUtils.uploadLocalFile4Child(outputFilePath, fileUrl);
// }
// } catch (Exception e) {
// uploadResultInfo = OssUtils.uploadLocalFile4Child(outputFilePath, fileUrl);
// LOGGER.error("An error happend when convert to webp. Img is: " + e.getMessage(), e);
// } catch (Exception e) {
// throw new FileException(FileException.FILE_CONVERT_FAIL, "transcode to webp is fail!");
// LOGGER.error("An error happend when convert to webp. Img is: " +
// } finally {
// e.getMessage(), e);
// FileUtils.deleteFile(localFilePath);
// throw new FileException(FileException.FILE_CONVERT_FAIL, "transcode to webp
// FileUtils.deleteFile(outputFilePath);
// is fail!");
// }
// } finally {
// LOGGER.info("【IMAGE API】image transcode to webp.<START>.[uploadResultInfo]=" + uploadResultInfo);
// FileUtils.deleteFile(localFilePath);
// return uploadResultInfo;
// FileUtils.deleteFile(outputFilePath);
// }
// }
// LOGGER.info("【IMAGE API】image transcode to webp.<START>.[uploadResultInfo]="
// + uploadResultInfo);
// return uploadResultInfo;
// }
/**
/**
* execute cwebp command:cwebp [options] input_file -o output_file.webp
* execute cwebp command:cwebp [options] input_file -o output_file.webp
...
@@ -778,15 +769,13 @@ public class ImageUtils {
...
@@ -778,15 +769,13 @@ public class ImageUtils {
* @param quality
* @param quality
* @throws Exception
* @throws Exception
*/
*/
// private static void executeCwebp4Win(String inputFilePath, String
// private static void executeCwebp4Win(String inputFilePath, String outputFilePath, int quality) throws Exception {
// outputFilePath, int quality) throws Exception {
// Process process = new ProcessBuilder("cwebp", "-q", (quality == 0 ? 80 : quality) + "", inputFilePath, "-o",
// Process process = new ProcessBuilder("cwebp", "-q", (quality == 0 ? 80 :
// outputFilePath).redirectErrorStream(true).start();
// quality) + "", inputFilePath, "-o",
// if (0 != process.waitFor()) {
// outputFilePath).redirectErrorStream(true).start();
// throw new Exception("process wait for fail!");
// if (0 != process.waitFor()) {
// }
// throw new Exception("process wait for fail!");
// }
// }
// }
/**
/**
* execute cwebp command:cwebp [options] input_file -o output_file.webp
* execute cwebp command:cwebp [options] input_file -o output_file.webp
...
@@ -796,47 +785,12 @@ public class ImageUtils {
...
@@ -796,47 +785,12 @@ public class ImageUtils {
* @param quality
* @param quality
* @throws Exception
* @throws Exception
*/
*/
// private static void executeCwebp4Linux(String inputFilePath, String
// private static void executeCwebp4Linux(String inputFilePath, String outputFilePath, int quality) throws Exception {
// outputFilePath, int quality) throws Exception {
// Process process = new ProcessBuilder("/usr/local/bin/cwebp", "-q", (quality == 0 ? 80 : quality) + "",
// Process process = new ProcessBuilder("/usr/local/bin/cwebp", "-q", (quality
// inputFilePath, "-o", outputFilePath).redirectErrorStream(true).start();
// == 0 ? 80 : quality) + "",
// if (0 != process.waitFor()) {
// inputFilePath, "-o", outputFilePath).redirectErrorStream(true).start();
// throw new Exception("process wait for fail!");
// if (0 != process.waitFor()) {
// throw new Exception("process wait for fail!");
// }
// }
/**
* 上传的图片转换成webpO
*
* @param localFilePath
* 源文件的本地路径
* @param httpUrl
* 源文件上传后的路径,主要用于子文件上传时对应http文件路径
*/
public
static
UploadResultInfo
toWebp
(
String
fileUrl
)
{
// String fileNameAll = FileUtils.getFileNameAll(fileUrl);
// String localFilePath = FilePathConst.DOWNLOAD_PATH + fileNameAll;
// FileUtils.downloadFileFromUrl(fileUrl, localFilePath);
// String tragetPath = null;
// try {
// tragetPath = com.dcg.util.ImageUtils.transcodeToWebp(localFilePath, 80);
// } catch (Exception e) {
// LOGGER.error("【IMAGE】图片转换成webp失败:" + e.getMessage(), e);
// return null;
// }
// if (StringUtils.isEmpty(tragetPath)) {
// return null;
// }
// }
// try {
// }
// return OssUtils.uploadLocalFile4Child(tragetPath, fileUrl);
// } catch (Exception e) {
// LOGGER.error("【IMAGE】图片转换成webp,上传失败:" + e.getMessage(), e);
// } finally {
// FileUtils.deleteFile(localFilePath);
// FileUtils.deleteFile(tragetPath);
// }
return
null
;
}
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/PictureUtil.java
View file @
d5f7ebc4
This diff is collapsed.
Click to expand it.
pcloud-common/src/main/java/com/pcloud/common/utils/aliyun/OssUtils.java
View file @
d5f7ebc4
...
@@ -40,7 +40,7 @@ import com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobRequest;
...
@@ -40,7 +40,7 @@ import com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobRequest;
import
com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobResponse.SnapshotJob
;
import
com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobResponse.SnapshotJob
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.pcloud.common.constant.AliyunConstant
;
import
com.pcloud.common.constant.AliyunConstant
;
import
com.pcloud.common.constant.FilePathConst
;
import
com.pcloud.common.constant.FilePathConst
ant
;
import
com.pcloud.common.constant.UrlConstant
;
import
com.pcloud.common.constant.UrlConstant
;
import
com.pcloud.common.dto.OssImageCropDTO
;
import
com.pcloud.common.dto.OssImageCropDTO
;
import
com.pcloud.common.dto.OssImageDTO
;
import
com.pcloud.common.dto.OssImageDTO
;
...
@@ -1600,7 +1600,7 @@ public class OssUtils {
...
@@ -1600,7 +1600,7 @@ public class OssUtils {
// 创建OSSClient实例
// 创建OSSClient实例
OSSClient
ossClient
=
getOSSClient
(
bucketName
);
OSSClient
ossClient
=
getOSSClient
(
bucketName
);
// 生成新的图片地址
// 生成新的图片地址
String
localPath
=
FilePathConst
.
IMAGE_PATH
+
UUIDUitl
.
generateString
(
32
)
+
"."
+
fileType
;
String
localPath
=
FilePathConst
ant
.
IMAGE
+
UUIDUitl
.
generateString
(
32
)
+
"."
+
fileType
;
FileUtils
.
creatFiles
(
localPath
);
FileUtils
.
creatFiles
(
localPath
);
try
{
try
{
ossClient
.
getObject
(
request
,
new
File
(
localPath
));
ossClient
.
getObject
(
request
,
new
File
(
localPath
));
...
@@ -1720,7 +1720,7 @@ public class OssUtils {
...
@@ -1720,7 +1720,7 @@ public class OssUtils {
// 创建OSSClient实例
// 创建OSSClient实例
OSSClient
ossClient
=
getOSSClient
(
bucketName
);
OSSClient
ossClient
=
getOSSClient
(
bucketName
);
// 生成带水印的本地图片地址
// 生成带水印的本地图片地址
String
localPath
=
FilePathConst
.
IMAGE_WATERMARK_PATH
+
fileName
+
"_"
+
LocalDateUtils
.
getYmdhmss
()
+
"."
String
localPath
=
FilePathConst
ant
.
IMAGE_WATERMARK
+
fileName
+
"_"
+
LocalDateUtils
.
getYmdhmss
()
+
"."
+
fileType
;
+
fileType
;
FileUtils
.
creatFiles
(
localPath
);
FileUtils
.
creatFiles
(
localPath
);
ossClient
.
getObject
(
request
,
new
File
(
localPath
));
ossClient
.
getObject
(
request
,
new
File
(
localPath
));
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/httpclient/UrlUtils.java
View file @
d5f7ebc4
...
@@ -14,7 +14,6 @@ import org.apache.http.util.EntityUtils;
...
@@ -14,7 +14,6 @@ import org.apache.http.util.EntityUtils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pcloud.common.utils.rsa.MD5
;
import
com.pcloud.common.utils.rsa.MD5
;
import
com.pcloud.common.utils.string.StringUtil
;
import
com.pcloud.common.utils.string.StringUtil
;
...
@@ -25,17 +24,9 @@ import com.pcloud.common.utils.string.StringUtil;
...
@@ -25,17 +24,9 @@ import com.pcloud.common.utils.string.StringUtil;
*/
*/
public
class
UrlUtils
{
public
class
UrlUtils
{
/**
*
*/
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
UrlUtils
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
UrlUtils
.
class
);
/**
/**
* 请求地址(新郎接口)
*/
private
static
final
String
REQUEST_URL
=
"https://api.weibo.com/2/short_url/shorten.json?source=1681459862&url_long="
;
/**
* 请求地址(OWN)
* 请求地址(OWN)
*/
*/
private
static
final
String
REQUEST_URL2
=
"https://rays.5rs.me/convert/v1.0/url/shorten"
;
private
static
final
String
REQUEST_URL2
=
"https://rays.5rs.me/convert/v1.0/url/shorten"
;
...
@@ -51,20 +42,13 @@ public class UrlUtils {
...
@@ -51,20 +42,13 @@ public class UrlUtils {
public
static
final
String
PRIVATE_KEY
=
"lgsc1205"
;
public
static
final
String
PRIVATE_KEY
=
"lgsc1205"
;
/**
/**
* 获取短链接
(新浪)
* 获取短链接
*
*
* @param long_url
* @param long_url
* @return
* @return
*/
*/
public
static
String
getShortUrl
(
String
long_url
)
{
public
static
String
getShortUrl
(
String
long_url
)
{
String
result
=
callHttp
(
REQUEST_URL
+
long_url
);
return
getShortUrl4Own
(
long_url
);
if
(
StringUtil
.
isEmpty
(
result
))
{
return
null
;
}
JSONObject
resultObject
=
JSONObject
.
parseObject
(
result
);
JSONArray
array
=
resultObject
.
getJSONArray
(
"urls"
);
JSONObject
object
=
array
.
getJSONObject
(
0
);
return
object
.
getString
(
"url_short"
);
}
}
/**
/**
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/pdf/PdfUtils.java
View file @
d5f7ebc4
...
@@ -29,7 +29,7 @@ import com.itextpdf.text.pdf.PdfPTable;
...
@@ -29,7 +29,7 @@ import com.itextpdf.text.pdf.PdfPTable;
import
com.itextpdf.text.pdf.PdfReader
;
import
com.itextpdf.text.pdf.PdfReader
;
import
com.itextpdf.text.pdf.PdfStamper
;
import
com.itextpdf.text.pdf.PdfStamper
;
import
com.itextpdf.text.pdf.PdfWriter
;
import
com.itextpdf.text.pdf.PdfWriter
;
import
com.pcloud.common.constant.FilePathConst
;
import
com.pcloud.common.constant.FilePathConst
ant
;
import
com.pcloud.common.entity.UploadResultInfo
;
import
com.pcloud.common.entity.UploadResultInfo
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.FileException
;
import
com.pcloud.common.exceptions.FileException
;
...
@@ -105,7 +105,7 @@ public class PdfUtils {
...
@@ -105,7 +105,7 @@ public class PdfUtils {
*/
*/
private
static
String
pdfConvert
(
byte
[]
b
,
String
fileName
,
String
prefix
,
String
format
)
throws
FileException
{
private
static
String
pdfConvert
(
byte
[]
b
,
String
fileName
,
String
prefix
,
String
format
)
throws
FileException
{
// 解析PDF文件
// 解析PDF文件
String
outPath
=
FilePathConst
.
PDF_PATH
+
fileName
+
"_"
+
UUIDUitl
.
generateString
(
12
);
String
outPath
=
FilePathConst
ant
.
PDF
+
fileName
+
"_"
+
UUIDUitl
.
generateString
(
12
);
File
fi
=
new
File
(
outPath
);
File
fi
=
new
File
(
outPath
);
if
(!
fi
.
exists
())
{
if
(!
fi
.
exists
())
{
fi
.
mkdirs
();
fi
.
mkdirs
();
...
@@ -161,7 +161,7 @@ public class PdfUtils {
...
@@ -161,7 +161,7 @@ public class PdfUtils {
/**
/**
* 创建PDF
* 创建PDF
*
*
* @param pdf
ChunkD
Os
* @param pdf
P
Os
* @return
* @return
* @throws Exception
* @throws Exception
*/
*/
...
@@ -176,7 +176,7 @@ public class PdfUtils {
...
@@ -176,7 +176,7 @@ public class PdfUtils {
OutputStream
os
=
null
;
OutputStream
os
=
null
;
try
{
try
{
// 输出路径
// 输出路径
outPath
=
FilePathConst
.
PDF_PATH
+
UUIDUitl
.
taskName
()
+
".pdf"
;
outPath
=
FilePathConst
ant
.
PDF
+
UUIDUitl
.
taskName
()
+
".pdf"
;
FileUtils
.
creatFiles
(
outPath
);
FileUtils
.
creatFiles
(
outPath
);
// 创建输出流
// 创建输出流
os
=
new
FileOutputStream
(
new
File
(
outPath
));
os
=
new
FileOutputStream
(
new
File
(
outPath
));
...
@@ -358,10 +358,8 @@ public class PdfUtils {
...
@@ -358,10 +358,8 @@ public class PdfUtils {
/**
/**
* 加水印(字符串)
* 加水印(字符串)
*
*
* @param
inputFile
* @param
filePath
* 需要加水印的PDF路径
* 需要加水印的PDF路径
* @param outputFile
* 输出生成PDF的路径
* @param waterMarkName
* @param waterMarkName
* 水印字符
* 水印字符
*/
*/
...
...
pcloud-common/src/main/java/com/pcloud/common/utils/string/StringUtil.java
View file @
d5f7ebc4
...
@@ -590,5 +590,20 @@ public class StringUtil extends StringUtilParent {
...
@@ -590,5 +590,20 @@ public class StringUtil extends StringUtilParent {
}
}
return
false
;
return
false
;
}
}
/**
* 过滤HTML标签
*
* @param str
* @return
*/
public
static
String
replaceHtml
(
String
str
)
{
if
(
StringUtil
.
isEmpty
(
str
))
{
return
""
;
}
Pattern
p_html
=
Pattern
.
compile
(
"<[^>]+>"
,
Pattern
.
CASE_INSENSITIVE
);
Matcher
m_html
=
p_html
.
matcher
(
str
);
return
m_html
.
replaceAll
(
""
).
replaceAll
(
" "
,
""
);
}
}
}
pcloud-common/src/main/java/com/pcloud/common/utils/word/WordNewUtils.java
View file @
d5f7ebc4
This diff is collapsed.
Click to expand it.
pcloud-common/src/main/java/com/pcloud/common/utils/word/WordUtils.java
View file @
d5f7ebc4
...
@@ -41,7 +41,7 @@ import com.lowagie.text.Paragraph;
...
@@ -41,7 +41,7 @@ import com.lowagie.text.Paragraph;
import
com.lowagie.text.Phrase
;
import
com.lowagie.text.Phrase
;
import
com.lowagie.text.Table
;
import
com.lowagie.text.Table
;
import
com.lowagie.text.rtf.RtfWriter2
;
import
com.lowagie.text.rtf.RtfWriter2
;
import
com.pcloud.common.constant.FilePathConst
;
import
com.pcloud.common.constant.FilePathConst
ant
;
import
com.pcloud.common.constant.WordConstant
;
import
com.pcloud.common.constant.WordConstant
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.BizException
;
import
com.pcloud.common.exceptions.FileException
;
import
com.pcloud.common.exceptions.FileException
;
...
@@ -84,7 +84,7 @@ public class WordUtils {
...
@@ -84,7 +84,7 @@ public class WordUtils {
RtfWriter2
rtfWriter2
=
null
;
RtfWriter2
rtfWriter2
=
null
;
try
{
try
{
// 输出路径
// 输出路径
outPath
=
FilePathConst
.
WORD_PATH
+
UUIDUitl
.
taskName
()
+
".doc"
;
outPath
=
FilePathConst
ant
.
WORD
+
UUIDUitl
.
taskName
()
+
".doc"
;
FileUtils
.
creatFiles
(
outPath
);
FileUtils
.
creatFiles
(
outPath
);
// 创建输出流
// 创建输出流
os
=
new
FileOutputStream
(
new
File
(
outPath
));
os
=
new
FileOutputStream
(
new
File
(
outPath
));
...
@@ -302,14 +302,14 @@ public class WordUtils {
...
@@ -302,14 +302,14 @@ public class WordUtils {
CustomXWPFDocument
document
=
null
;
CustomXWPFDocument
document
=
null
;
FileOutputStream
fos
=
null
;
FileOutputStream
fos
=
null
;
try
{
try
{
wordTemplate
=
FilePathConst
.
WORD_PATH
+
UUIDUitl
.
taskName
()
+
".docx"
;
wordTemplate
=
FilePathConst
ant
.
WORD
+
UUIDUitl
.
taskName
()
+
".docx"
;
FileUtils
.
downloadFileFromUrl
(
WordConstant
.
TEMPLATE_URL
,
wordTemplate
);
FileUtils
.
downloadFileFromUrl
(
WordConstant
.
TEMPLATE_URL
,
wordTemplate
);
OPCPackage
pack
=
POIXMLDocument
.
openPackage
(
wordTemplate
);
OPCPackage
pack
=
POIXMLDocument
.
openPackage
(
wordTemplate
);
document
=
new
CustomXWPFDocument
(
pack
);
document
=
new
CustomXWPFDocument
(
pack
);
// 添加内容到文档中
// 添加内容到文档中
addChunks
(
wordPOs
,
document
);
addChunks
(
wordPOs
,
document
);
// 生成目标word
// 生成目标word
outPath
=
FilePathConst
.
WORD_PATH
+
UUIDUitl
.
taskName
()
+
".docx"
;
outPath
=
FilePathConst
ant
.
WORD
+
UUIDUitl
.
taskName
()
+
".docx"
;
fos
=
new
FileOutputStream
(
outPath
);
fos
=
new
FileOutputStream
(
outPath
);
document
.
write
(
fos
);
document
.
write
(
fos
);
fos
.
flush
();
fos
.
flush
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment