Commit 343853dc by huzhenkun

Merge branch 'master' of http://begitlab.chubanyun.me/rays/pcloud-common-parent into hzk

parents fb4b6933 d45e4c47
...@@ -95,3 +95,6 @@ product.parentTutor.proLabelId = 7461 ...@@ -95,3 +95,6 @@ product.parentTutor.proLabelId = 7461
book.group.qrcode.domain = https://qrcode.5rs.me book.group.qrcode.domain = https://qrcode.5rs.me
ownAgentIds = 2,1362 ownAgentIds = 2,1362
## \u9519\u9898\u672C\u73AF\u5883\u57DF\u540D
papercut.domain = papercut.5rs.me
\ No newline at end of file
...@@ -96,3 +96,6 @@ product.parentTutor.proLabelId = 812 ...@@ -96,3 +96,6 @@ product.parentTutor.proLabelId = 812
book.group.qrcode.domain = https://qrcode.raysyun.com book.group.qrcode.domain = https://qrcode.raysyun.com
ownAgentIds = 12829 ownAgentIds = 12829
## \u9519\u9898\u672C\u73AF\u5883\u57DF\u540D
papercut.domain = papercut.raysyun.com
\ No newline at end of file
...@@ -20,7 +20,6 @@ import com.alibaba.fastjson.JSON; ...@@ -20,7 +20,6 @@ import com.alibaba.fastjson.JSON;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
/** /**
*
* @author:songx * @author:songx
* @date:2018年4月26日,下午2:32:36 * @date:2018年4月26日,下午2:32:36
*/ */
...@@ -67,7 +66,8 @@ public class ParamLogAspect { ...@@ -67,7 +66,8 @@ public class ParamLogAspect {
/** /**
* 方法执行完以后执行 * 方法执行完以后执行
* *
* @param object * @param joinPoint
* @param result
*/ */
@AfterReturning(pointcut = "bizPoint()", returning = "result") @AfterReturning(pointcut = "bizPoint()", returning = "result")
public void doAfterReturn(JoinPoint joinPoint, Object result) { public void doAfterReturn(JoinPoint joinPoint, Object result) {
......
...@@ -72,7 +72,7 @@ public enum AppTypeEnum { ...@@ -72,7 +72,7 @@ public enum AppTypeEnum {
/** /**
* 直播 * 直播
*/ */
LIVE("live", com.pcloud.common.core.enums.AppTypeEnum.LIVE.value), LIVE("live", com.pcloud.common.core.enums.AppTypeEnum.LIVE_TIMETABLE.value),
/** /**
* 打卡 * 打卡
...@@ -147,7 +147,13 @@ public enum AppTypeEnum { ...@@ -147,7 +147,13 @@ public enum AppTypeEnum {
/** /**
* 英语随身听 * 英语随身听
*/ */
ENGLISH_WALKMAN("wm", com.pcloud.common.core.enums.AppTypeEnum.ENGLISH_WALKMAN.value); ENGLISH_WALKMAN("wm", com.pcloud.common.core.enums.AppTypeEnum.ENGLISH_WALKMAN.value),
/**
* 口语评测
*/
ORAL_EVALUATION("speak", com.pcloud.common.core.enums.AppTypeEnum.ORAL_EVALUATION.value);
/** /**
* 值 * 值
......
...@@ -76,13 +76,15 @@ public class MQTopicProducer { ...@@ -76,13 +76,15 @@ public class MQTopicProducer {
*/ */
public static final String TIP = "topic.tip"; public static final String TIP = "topic.tip";
/** /**
* 打赏给读者 * 给读者的打赏
*/ */
public static final String TIP_FOR_WECHAT_USER = "topic.tipForWechatUser"; public static final String TIP_FOR_WECHAT_USER = "topic.tipForWechatUser";
/** /**
* GENUINE * GENUINE
*/ */
public static final String GENUINE = "topic.genuine"; public static final String GENUINE = "topic.genuine";
/** /**
* 订单完成 * 订单完成
*/ */
...@@ -307,4 +309,24 @@ public class MQTopicProducer { ...@@ -307,4 +309,24 @@ public class MQTopicProducer {
* 更新用户头像 * 更新用户头像
*/ */
public static final String UPDATE_USER_HEADURL = "topic.updateUserHeadUrl"; public static final String UPDATE_USER_HEADURL = "topic.updateUserHeadUrl";
/**
* 入群
*/
public static final String ADD_WXGROUP = "topic.addWXGroup";
/**
* 微信群发送文字消息
*/
public static final String WXGROUP_SEND_TEXT = "topic.WXGroupSendText";
/**
* 新用户消息
*/
public static final String PUSH_ADD_USER_MESSAGE = "topic.pushAddUserMessage";
/**
* 签到打卡作者返现TOPIC
*/
public static final String ATTENDANCETASK_CASHBACK_MERCHANT = "topic.attendancetaskCashbackMerchant";
} }
...@@ -308,6 +308,22 @@ public class ProductTypeConstant { ...@@ -308,6 +308,22 @@ public class ProductTypeConstant {
public static final String PDF_APP = "PDF_APP"; public static final String PDF_APP = "PDF_APP";
/** /**
* 背单词
*/
public static final String WORD_APP = "WORD_APP";
/**
* 签到打卡
*/
public static final String ATTENDANCE_TASK = "ATTENDANCE_TASK";
/**
* 资源外链
*/
public static final String LINK = "LINK";
/**
* 热门作品类型 * 热门作品类型
*/ */
public static final String[] HOT_PRODUCT_TYPE = {QA, PDF, VIDEO, PRETEST}; public static final String[] HOT_PRODUCT_TYPE = {QA, PDF, VIDEO, PRETEST};
...@@ -316,7 +332,7 @@ public class ProductTypeConstant { ...@@ -316,7 +332,7 @@ public class ProductTypeConstant {
* 资源型作品(免费即可体验) * 资源型作品(免费即可体验)
*/ */
public static final String[] RESOURCE_PRODUCT = {AUDIO, VIDEO, PDF, EBOOK, ALBUM, PRETEST, QANEWS, public static final String[] RESOURCE_PRODUCT = {AUDIO, VIDEO, PDF, EBOOK, ALBUM, PRETEST, QANEWS,
FORMAT, WORD, ARTICLE, LISTEN, SCHEDULE, PBMUSIC, TUTORIAL, VIDEO_SCHEDULE, AUDIO_SCHEDULE}; FORMAT, WORD, ARTICLE, LISTEN, SCHEDULE, PBMUSIC, TUTORIAL, VIDEO_SCHEDULE, AUDIO_SCHEDULE, LINK};
/** /**
* 参与促销激励作品 * 参与促销激励作品
...@@ -335,7 +351,7 @@ public class ProductTypeConstant { ...@@ -335,7 +351,7 @@ public class ProductTypeConstant {
public static final String[] APP_PRODUCT = {LOOK, LIVE, TUTOR, GROUP, ZSCORE, VOTE, CLOCK, TEST, AUDIOAPP, ANSWER, public static final String[] APP_PRODUCT = {LOOK, LIVE, TUTOR, GROUP, ZSCORE, VOTE, CLOCK, TEST, AUDIOAPP, ANSWER,
EF, VIDEO_COURSE, PRETESTAPP, AUDIO_RESOURCE, QA_APP, EBOOK_APP, AUDIO_MAGIC, TEACH_RESOURCE_APP, EF, VIDEO_COURSE, PRETESTAPP, AUDIO_RESOURCE, QA_APP, EBOOK_APP, AUDIO_MAGIC, TEACH_RESOURCE_APP,
COURSE_WARE, TEST_PAPER_APP, MATCH_LISTEN, WORD_DICTATION, STROKE_ORDER_APP, IMAGE_APP, MEMBER_APP, COURSE_WARE, TEST_PAPER_APP, MATCH_LISTEN, WORD_DICTATION, STROKE_ORDER_APP, IMAGE_APP, MEMBER_APP,
ARTICLE_READING, ENGLISH_WALKMAN, ORAL_EVALUATION, PBSTORY, PDF_APP}; ARTICLE_READING, ENGLISH_WALKMAN, ORAL_EVALUATION, PBSTORY, PDF_APP, WORD_APP};
/** /**
* 数据平台埋点型作品 * 数据平台埋点型作品
......
...@@ -34,7 +34,8 @@ public enum AppProductTypeEnum { ...@@ -34,7 +34,8 @@ public enum AppProductTypeEnum {
ARTICLE_READING(AppTypeEnum.ARTICLE_READING.value, ProductTypeConstant.ARTICLE_READING), ARTICLE_READING(AppTypeEnum.ARTICLE_READING.value, ProductTypeConstant.ARTICLE_READING),
ENGLISH_WALKMAN(AppTypeEnum.ENGLISH_WALKMAN.value, ProductTypeConstant.ENGLISH_WALKMAN), ENGLISH_WALKMAN(AppTypeEnum.ENGLISH_WALKMAN.value, ProductTypeConstant.ENGLISH_WALKMAN),
ORAL_EVALUATION(AppTypeEnum.ORAL_EVALUATION.value, ProductTypeConstant.ORAL_EVALUATION), ORAL_EVALUATION(AppTypeEnum.ORAL_EVALUATION.value, ProductTypeConstant.ORAL_EVALUATION),
PDF(AppTypeEnum.PDF.value, ProductTypeConstant.PDF_APP); PDF(AppTypeEnum.PDF.value, ProductTypeConstant.PDF_APP),
RECITE_WORD(AppTypeEnum.RECITE_WORD.value, ProductTypeConstant.WORD_APP);
public final String appTypeCode; public final String appTypeCode;
......
...@@ -59,7 +59,8 @@ public enum AppTypeEnum { ...@@ -59,7 +59,8 @@ public enum AppTypeEnum {
ENGLISH_WALKMAN("ENGLISH_WALKMAN"), //英语随身听 ENGLISH_WALKMAN("ENGLISH_WALKMAN"), //英语随身听
ORAL_EVALUATION("ORAL_EVALUATION"), //口语评测 ORAL_EVALUATION("ORAL_EVALUATION"), //口语评测
WISH("WISH"),//愿望单 WISH("WISH"),//愿望单
DRAW("DRAW");//抽奖 DRAW("DRAW"),//抽奖
LIVE_TIMETABLE("LIVE_TIMETABLE");//直播
/** /**
* 值 * 值
*/ */
......
...@@ -20,7 +20,12 @@ public enum NotifyOriginTypeEnum { ...@@ -20,7 +20,12 @@ public enum NotifyOriginTypeEnum {
/** /**
* 订单 * 订单
*/ */
ORDERNUM("ORDERNUM"); ORDERNUM("ORDERNUM"),
/**
* 社群书
*/
BOOK_GROUP("BOOK_GROUP");
/** /**
* 值 * 值
......
...@@ -52,7 +52,17 @@ public enum TranscodeFromEnum { ...@@ -52,7 +52,17 @@ public enum TranscodeFromEnum {
/** /**
* 文件管理中心 * 文件管理中心
*/ */
CONVERT_PDF("CONVERT_PDF"); CONVERT_PDF("CONVERT_PDF"),
/**
* 错题本-题目
*/
NOTE_SUBJECT("NOTE_SUBJECT"),
/**
* 错题本-答案
*/
NOTE_ANSWER("NOTE_ANSWER");
/** /**
* 值 * 值
......
/**
*
*/
package com.pcloud.common.dto;
import com.alibaba.fastjson.JSON;
/**
* @author:songx
* @date:2019年1月14日,上午9:51:21
*/
public class OssImageCropDTO {
/**
* bucket名称
*/
private String bucket;
/**
* OSS object key
*/
private String object;
/**
* 文件大小
*/
private Long fileSize;
/**
* 文件地址
*/
private String fileUrl;
/**
* 状态,OK
*/
private String status;
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public String getBucket() {
return bucket;
}
public String getObject() {
return object;
}
public String getStatus() {
return status;
}
public void setBucket(String bucket) {
this.bucket = bucket;
}
public void setObject(String object) {
this.object = object;
}
public void setStatus(String status) {
this.status = status;
}
public Long getFileSize() {
return fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
@Override
public String toString() {
return "OssImageCropDTO -> " + JSON.toJSONString(this);
}
}
/**
*
*/
package com.pcloud.common.dto;
import com.alibaba.fastjson.JSON;
/**
*
* @author:songx
* @date:2019年1月14日,上午9:51:21
*/
public class OssImageDTO {
/**
* 图片所在的OSS路径
*/
private String fileUrl;
/**
* 水印内容
*/
private String text;
/**
* 水印字体大小(px),取值范围:(0,1000]默认值:40
*/
private int size;
/**
* 水印文字颜色
*
* 参数的构成必须是:六个十六进制数,默认值:000000黑色
*/
private String color;
/**
* 水印文字的透明度,默认值:100, 表示 100%(不透明)取值范围: [0-100]
*/
private int t;
/**
* 水印X轴坐标,默认值:10
*
* 取值范围:[0 – 4096]
*
* 单位:像素(px)
*/
private int x;
/**
* 水印Y轴坐标,默认值:10
*
* 取值范围:[0 – 4096]
*
* 单位:像素(px)
*/
private int y;
/**
* 水印所在的位置,取值范围:[nw,north,ne,west,center,east,sw,south,se]
*/
private String g;
/**
* 水印文字的阴影透明度
*/
private int shadow;
public int getShadow() {
return shadow;
}
public void setShadow(int shadow) {
this.shadow = shadow;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public int getT() {
return t;
}
public void setT(int t) {
this.t = t;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public String getG() {
return g;
}
public void setG(String g) {
this.g = g;
}
@Override
public String toString() {
return "OssImageDTO -> " + JSON.toJSONString(this);
}
}
...@@ -468,7 +468,8 @@ public class FileUtils { ...@@ -468,7 +468,8 @@ public class FileUtils {
/** /**
* 根据路径删除指定的目录或文件,无论存在与否 * 根据路径删除指定的目录或文件,无论存在与否
* *
* @param sPath 要删除的目录或文件 * @param sPath
* 要删除的目录或文件
* @return 删除成功返回 true,否则返回 false。 * @return 删除成功返回 true,否则返回 false。
*/ */
public static boolean deleteFolder(String sPath) { public static boolean deleteFolder(String sPath) {
...@@ -493,7 +494,8 @@ public class FileUtils { ...@@ -493,7 +494,8 @@ public class FileUtils {
/** /**
* 删除单个文件 * 删除单个文件
* *
* @param sPath 被删除文件的文件名 * @param sPath
* 被删除文件的文件名
* @return 单个文件删除成功返回true,否则返回false * @return 单个文件删除成功返回true,否则返回false
*/ */
public static boolean deleteFile(String sPath) { public static boolean deleteFile(String sPath) {
...@@ -513,7 +515,8 @@ public class FileUtils { ...@@ -513,7 +515,8 @@ public class FileUtils {
/** /**
* 删除目录(文件夹)以及目录下的文件 * 删除目录(文件夹)以及目录下的文件
* *
* @param sPath 被删除目录的文件路径 * @param sPath
* 被删除目录的文件路径
* @return 目录删除成功返回true,否则返回false * @return 目录删除成功返回true,否则返回false
*/ */
public static boolean deleteDirectory(String sPath) { public static boolean deleteDirectory(String sPath) {
...@@ -687,8 +690,10 @@ public class FileUtils { ...@@ -687,8 +690,10 @@ public class FileUtils {
/** /**
* 合并两个文件 * 合并两个文件
* *
* @param outFile 目标文件 * @param outFile
* @param leafFile 源文件 * 目标文件
* @param leafFile
* 源文件
*/ */
public static void mergeFiles(File outFile, File leafFile) { public static void mergeFiles(File outFile, File leafFile) {
FileOutputStream fos = null; FileOutputStream fos = null;
...@@ -705,7 +710,7 @@ public class FileUtils { ...@@ -705,7 +710,7 @@ public class FileUtils {
fos = new FileOutputStream(outFile, true); fos = new FileOutputStream(outFile, true);
fis = new FileInputStream(leafFile); fis = new FileInputStream(leafFile);
int len = 0; int len = 0;
for (byte[] buf = new byte[1024 * 1024]; (len = fis.read(buf)) != -1; ) { for (byte[] buf = new byte[1024 * 1024]; (len = fis.read(buf)) != -1;) {
fos.write(buf, 0, len); fos.write(buf, 0, len);
} }
} catch (IOException ioe) { } catch (IOException ioe) {
...@@ -724,8 +729,10 @@ public class FileUtils { ...@@ -724,8 +729,10 @@ public class FileUtils {
/** /**
* 合并多个文件 * 合并多个文件
* *
* @param outFile 输出文件, * @param outFile
* @param leafFiles 文件碎片集 * 输出文件,
* @param leafFiles
* 文件碎片集
*/ */
public static void mergeFileList(File outFile, List<File> leafFiles) { public static void mergeFileList(File outFile, List<File> leafFiles) {
FileOutputStream fos = null; FileOutputStream fos = null;
...@@ -764,9 +771,12 @@ public class FileUtils { ...@@ -764,9 +771,12 @@ public class FileUtils {
/** /**
* 音频文件转换 * 音频文件转换
* *
* @param data 音频byte数组 * @param data
* @param sourExt 原始后缀 * 音频byte数组
* @param ext 新后缀 * @param sourExt
* 原始后缀
* @param ext
* 新后缀
* @return * @return
* @author PENG * @author PENG
*/ */
...@@ -1093,7 +1103,8 @@ public class FileUtils { ...@@ -1093,7 +1103,8 @@ public class FileUtils {
/** /**
* 从输入流中获取数据 * 从输入流中获取数据
* *
* @param inStream 输入流 * @param inStream
* 输入流
* @return * @return
* @throws Exception * @throws Exception
*/ */
......
...@@ -11,10 +11,11 @@ import java.math.BigDecimal; ...@@ -11,10 +11,11 @@ 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.dcg.util.StringUtils;
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.FilePathConst;
...@@ -440,6 +441,43 @@ public class ImageUtils { ...@@ -440,6 +441,43 @@ public class ImageUtils {
} }
/** /**
* 获取图片的宽度和高度(考虑了图片旋转的情况。也就是说,获得的宽就是宽,高就是高)
*
* @param img
* 图片文件
* @return
*/
public static float[] getWidthHeightSize(String fileUrl) {
Image image = null;
String localFile = null;
float[] size = new float[2];
try {
if (StringTools.contains(fileUrl, AliyunConstant.OSS_CDN_URLS)) {
localFile = OssUtils.imageAutoOrient(fileUrl, 0);
image = Image.getInstance(localFile);
} else if (fileUrl.startsWith("http")) {
image = Image.getInstance(FileUtils.downloadByteFromUrl(fileUrl));
} else {
image = Image.getInstance(fileUrl);
}
} catch (Exception e) {
LOGGER.error("【IMAGE API】获取图片的宽度和高度[getWidthHeightSize]:" + e.getMessage(), e);
} finally {
if (!StringUtil.isEmpty(localFile)) {
FileUtils.deleteFile(localFile);
}
}
if (image == null) {
size[0] = 0;
size[1] = 0;
} else {
size[0] = image.getWidth();
size[1] = image.getHeight();
}
return size;
}
/**
* 获取对比比例 * 获取对比比例
* *
* @param num1 * @param num1
...@@ -655,27 +693,28 @@ public class ImageUtils { ...@@ -655,27 +693,28 @@ public class ImageUtils {
} }
/** /**
* 获取图片的宽度和高度 * 获取图片的宽度和高度(未考虑图片旋转的情况。也就是说,获得的宽可能是宽也可能是高,高可能是高也肯是宽)
* *
* @param img * @param fileUrl
* 图片文件
* @return * @return
*/ */
public static float[] getWidthHeightSize(String fileUrl) { public static float[] getWidthHeightNoOrient(String fileUrl) {
Image image = null; Image image = null;
String localFile = null; String localFile = null;
float[] size = new float[2]; float[] size = new float[2];
try { try {
if (StringTools.contains(fileUrl, AliyunConstant.OSS_CDN_URLS)) { /*
localFile = OssUtils.imageAutoOrient(fileUrl, 0); * if (StringTools.contains(fileUrl, AliyunConstant.OSS_CDN_URLS)) { localFile =
image = Image.getInstance(localFile); * OssUtils.imageAutoOrient(fileUrl); image = Image.getInstance(localFile); }
} else if (fileUrl.startsWith("http")) { * else
*/
if (fileUrl.startsWith("http")) {
image = Image.getInstance(FileUtils.downloadByteFromUrl(fileUrl)); image = Image.getInstance(FileUtils.downloadByteFromUrl(fileUrl));
} else { } else {
image = Image.getInstance(fileUrl); image = Image.getInstance(fileUrl);
} }
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("【IMAGE API】获取图片的宽度和高度:" + e.getMessage(), e); LOGGER.error("【IMAGE API】获取图片的宽度和高度[getWidthHeightNoOrient]:" + e.getMessage(), e);
} finally { } finally {
if (!StringUtil.isEmpty(localFile)) { if (!StringUtil.isEmpty(localFile)) {
FileUtils.deleteFile(localFile); FileUtils.deleteFile(localFile);
...@@ -692,6 +731,82 @@ public class ImageUtils { ...@@ -692,6 +731,82 @@ public class ImageUtils {
} }
/** /**
* image transcode to webp
*
* 注意:使用此方法转图片格式,机器上必须安装有谷歌cwebp工具
*
* @param fileUrl
* @return
*/
// public static UploadResultInfo transcodeToWebp(String fileUrl, int quality) {
// LOGGER.info("【IMAGE API】image transcode to webp.<START>.[fileUrl]=" + fileUrl
// + ",[quality]=" + quality);
// String fileNameAll = FileUtils.getFileNameAll(fileUrl);
// String localFilePath = FilePathConst.DOWNLOAD_PATH + fileNameAll;
// FileUtils.downloadFileFromUrl(fileUrl, localFilePath);
// String outputFilePath = FilePathConst.IMAGE_PATH + "webp/" + fileNameAll +
// ".webp";
// FileUtils.creatFiles(outputFilePath);
// UploadResultInfo uploadResultInfo = null;
// try {
// String os = System.getProperty("os.name");
// if (os.toLowerCase().startsWith("win")) {
// executeCwebp4Win(localFilePath, outputFilePath, quality);
// } else {
// executeCwebp4Linux(localFilePath, outputFilePath, quality);
// }
// uploadResultInfo = OssUtils.uploadLocalFile4Child(outputFilePath, fileUrl);
// } catch (Exception e) {
// LOGGER.error("An error happend when convert to webp. Img is: " +
// e.getMessage(), e);
// throw new FileException(FileException.FILE_CONVERT_FAIL, "transcode to webp
// is fail!");
// } finally {
// FileUtils.deleteFile(localFilePath);
// 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
*
* @param inputFilePath
* @param outputFilePath
* @param quality
* @throws Exception
*/
// private static void executeCwebp4Win(String inputFilePath, String
// outputFilePath, int quality) throws Exception {
// Process process = new ProcessBuilder("cwebp", "-q", (quality == 0 ? 80 :
// quality) + "", inputFilePath, "-o",
// outputFilePath).redirectErrorStream(true).start();
// if (0 != process.waitFor()) {
// throw new Exception("process wait for fail!");
// }
// }
/**
* execute cwebp command:cwebp [options] input_file -o output_file.webp
*
* @param inputFilePath
* @param outputFilePath
* @param quality
* @throws Exception
*/
// private static void executeCwebp4Linux(String inputFilePath, String
// outputFilePath, int quality) throws Exception {
// Process process = new ProcessBuilder("/usr/local/bin/cwebp", "-q", (quality
// == 0 ? 80 : quality) + "",
// inputFilePath, "-o", outputFilePath).redirectErrorStream(true).start();
// if (0 != process.waitFor()) {
// throw new Exception("process wait for fail!");
// }
// }
/**
* 上传的图片转换成webpO * 上传的图片转换成webpO
* *
* @param localFilePath * @param localFilePath
......
package com.pcloud.common.utils.bean;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.utils.ListUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
* @author:songx
* @date:2018年8月24日,下午2:18:40
*/
public class BeanUtils extends org.springframework.beans.BeanUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(BeanUtils.class);
/**
* 实体类之间的转换
*
* @param source 来源
* @param clazz 目标对象
* @return
*/
public static <T> T copy(Object source, Class<T> clazz) {
if (source == null) {
return null;
}
T t = null;
try {
t = clazz.newInstance();
} catch (Exception e) {
LOGGER.error("clazz newInstance is error:" + e.getMessage(), e);
}
copyProperties(source, t);
return t;
}
/**
* 实体类之间的转换
*
* @param sources 来源
* @param clazz 目标对象
* @return
*/
public static <T> List<T> copy(List<?> sources, Class<T> clazz) {
if (ListUtils.isEmpty(sources)) {
return null;
}
List<T> results = new ArrayList<>();
for (Object source : sources) {
results.add(copy(source, clazz));
}
return results;
}
/**
* 分页结果的实体类之间的转换
*
* @param source
* @param clazz
* @param <T>
* @return
*/
public static <T> PageBeanNew<T> copy(PageBeanNew<?> source, Class<T> clazz) {
if (source == null) {
return null;
}
PageBeanNew<T> result = new PageBeanNew<>();
copyProperties(source, result);
List<?> recordList = source.getRecordList();
if (ListUtils.isEmpty(recordList)) {
result.setRecordList(new ArrayList<>());
} else {
result.setRecordList(copy(recordList, clazz));
}
return result;
}
}
/**
*
*/
package com.pcloud.common.utils.bean;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.utils.ListUtils;
import org.apache.commons.collections.MapUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author:songx
* @date:2019年3月28日,下午2:47:41
*/
public class ResponesUtils {
/**
* 单个对象实例化
*
* @param object
* @param clazz
* @return
* @author songx
* @date 2019年1月14日, 下午7:32:35
*/
public static <T> T object(Object object, Class<T> clazz) {
if (object == null) {
try {
return clazz.newInstance();
} catch (Exception e) {
}
}
return BeanUtils.copy(object, clazz);
}
/**
* 集合查询结果判断
*
* @param lists
* @return
*/
public static <T> List<T> list(List<T> lists) {
if (!ListUtils.isEmpty(lists)) {
return lists;
}
return Lists.newArrayList();
}
/**
* map查询结果判断
*
* @param map
* @return
*/
public static <K, V> Map<K, V> map(Map<K, V> map) {
if (!MapUtils.isEmpty(map)) {
return map;
}
return Maps.newHashMap();
}
/**
* list集合结果转换
*
* @param lists
* @param clazz
* @return
* @author songx
* @date 2019年4月23日, 下午4:13:19
*/
public static <T> List<T> list(List<?> lists, Class<T> clazz) {
if (ListUtils.isEmpty(lists)) {
return new ArrayList<>();
}
return BeanUtils.copy(lists, clazz);
}
/**
* 分页查询结果判断
*
* @param pageBean
* @return
*/
public static <T> PageBeanNew<T> pageBean(PageBeanNew<T> pageBean) {
if (pageBean != null) {
return pageBean;
}
return new PageBeanNew<T>(0, 15, 0, new ArrayList<>());
}
/**
* 分页查询结果转换
*
* @param pageBean
* @param clazz
* @return
* @author songx
* @date 2019年4月23日, 下午4:03:11
*/
public static <T> PageBeanNew<T> pageBean(PageBeanNew<?> pageBean, Class<T> clazz) {
if (pageBean == null) {
return new PageBeanNew<>(0, 15, 0, new ArrayList<>());
}
return pageBean(BeanUtils.copy(pageBean, clazz));
}
}
...@@ -99,6 +99,21 @@ public class Cookie { ...@@ -99,6 +99,21 @@ public class Cookie {
public static final String SECOND_TD = "secondTd"; public static final String SECOND_TD = "secondTd";
/** /**
* 社群码ID
*/
public static final String BOOK_GROUP_ID = "bookGroupId";
/**
* 群分类ID
*/
public static final String CLASSIFY_ID = "classifyId";
/**
* 微信群ID
*/
public static final String QRCODE_ID = "qrcodeId";
/**
* cookie 信息處理 * cookie 信息處理
* @param userInfo * @param userInfo
* @return * @return
...@@ -214,6 +229,26 @@ public class Cookie { ...@@ -214,6 +229,26 @@ public class Cookie {
userInfos.put(SECOND_TD, StringUtil.isEmpty(code) || "undefined".equalsIgnoreCase(code) || "null".equalsIgnoreCase(code) ? null userInfos.put(SECOND_TD, StringUtil.isEmpty(code) || "undefined".equalsIgnoreCase(code) || "null".equalsIgnoreCase(code) ? null
: NumberUtil.toLong(code)); : NumberUtil.toLong(code));
} }
// add by gaop at 2019年5月6日16:23:32
if (userInfoArry[i].contains(BOOK_GROUP_ID)) {
String[] bookGroupId = userInfoArry[i].split("=");
String code = bookGroupId[bookGroupId.length - 1];
userInfos.put(BOOK_GROUP_ID, StringUtil.isEmpty(code) || "undefined".equalsIgnoreCase(code) || "null".equalsIgnoreCase(code) ? null
: NumberUtil.toLong(code));
}
if (userInfoArry[i].contains(CLASSIFY_ID)) {
String[] classifyId = userInfoArry[i].split("=");
String code = classifyId[classifyId.length - 1];
userInfos.put(CLASSIFY_ID, StringUtil.isEmpty(code) || "undefined".equalsIgnoreCase(code) || "null".equalsIgnoreCase(code) ? null
: NumberUtil.toLong(code));
}
if (userInfoArry[i].contains(QRCODE_ID)) {
String[] qrcodeId = userInfoArry[i].split("=");
String code = qrcodeId[qrcodeId.length - 1];
userInfos.put(QRCODE_ID, StringUtil.isEmpty(code) || "undefined".equalsIgnoreCase(code) || "null".equalsIgnoreCase(code) ? null
: NumberUtil.toLong(code));
}
} }
return userInfos; return userInfos;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment