Commit 343853dc by huzhenkun

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

parents fb4b6933 d45e4c47
......@@ -94,4 +94,7 @@ product.parentTutor.proLabelId = 7461
book.group.qrcode.domain = https://qrcode.5rs.me
ownAgentIds = 2,1362
\ No newline at end of file
ownAgentIds = 2,1362
## \u9519\u9898\u672C\u73AF\u5883\u57DF\u540D
papercut.domain = papercut.5rs.me
\ No newline at end of file
......@@ -95,4 +95,7 @@ product.parentTutor.proLabelId = 812
book.group.qrcode.domain = https://qrcode.raysyun.com
ownAgentIds = 12829
\ No newline at end of file
ownAgentIds = 12829
## \u9519\u9898\u672C\u73AF\u5883\u57DF\u540D
papercut.domain = papercut.raysyun.com
\ No newline at end of file
/**
*
*
*/
package com.pcloud.common.core.aspect;
......@@ -20,7 +20,6 @@ import com.alibaba.fastjson.JSON;
import com.pcloud.common.utils.string.StringUtil;
/**
*
* @author:songx
* @date:2018年4月26日,下午2:32:36
*/
......@@ -28,79 +27,80 @@ import com.pcloud.common.utils.string.StringUtil;
@Configuration
public class ParamLogAspect {
/**
*
*/
private final static Logger LOGGER = LoggerFactory.getLogger("");
/**
*
*/
private final static Logger LOGGER = LoggerFactory.getLogger("");
@Pointcut("execution(* com.pcloud..*(..))")
public void bizPoint() {
}
@Pointcut("execution(* com.pcloud..*(..))")
public void bizPoint() {
}
/**
* 方法执行前以后执行
*
* @param joinPoint
*/
@Before("bizPoint()")
public void doBefore(JoinPoint joinPoint) {
ParamLog paramLog = checkAnnotation(joinPoint);
if (paramLog == null) {
return;
}
Signature signature = joinPoint.getSignature();
String methodName = signature.getName();
String description = paramLog.description();
description = StringUtil.isEmpty(description) ? paramLog.value() : description;
StringBuffer msg = new StringBuffer(signature.getDeclaringTypeName()).append(" 【" + methodName + " before】");
if (!StringUtil.isEmpty(description)) {
msg.append(description);
}
if (!paramLog.isBefore()) {
LOGGER.info(msg.toString());
} else {
String argsJson = JSON.toJSONString(joinPoint.getArgs());
LOGGER.info(msg.append(",[Args]=").append(argsJson).toString());
}
}
/**
* 方法执行前以后执行
*
* @param joinPoint
*/
@Before("bizPoint()")
public void doBefore(JoinPoint joinPoint) {
ParamLog paramLog = checkAnnotation(joinPoint);
if (paramLog == null) {
return;
}
Signature signature = joinPoint.getSignature();
String methodName = signature.getName();
String description = paramLog.description();
description = StringUtil.isEmpty(description) ? paramLog.value() : description;
StringBuffer msg = new StringBuffer(signature.getDeclaringTypeName()).append(" 【" + methodName + " before】");
if (!StringUtil.isEmpty(description)) {
msg.append(description);
}
if (!paramLog.isBefore()) {
LOGGER.info(msg.toString());
} else {
String argsJson = JSON.toJSONString(joinPoint.getArgs());
LOGGER.info(msg.append(",[Args]=").append(argsJson).toString());
}
}
/**
* 方法执行完以后执行
*
* @param object
*/
@AfterReturning(pointcut = "bizPoint()", returning = "result")
public void doAfterReturn(JoinPoint joinPoint, Object result) {
ParamLog paramLog = checkAnnotation(joinPoint);
if (paramLog == null) {
return;
}
Signature signature = joinPoint.getSignature();
String methodName = signature.getName();
String description = paramLog.description();
description = StringUtil.isEmpty(description) ? paramLog.value() : description;
StringBuffer msg = new StringBuffer(signature.getDeclaringTypeName())
.append(" 【" + methodName + " afterReturn】");
if (!StringUtil.isEmpty(description)) {
msg.append(description);
}
if (!paramLog.isAfterReturn()) {
LOGGER.info(msg.toString());
} else {
String resultJson = JSON.toJSONString(result);
LOGGER.info(msg.append(",[result]=").append(resultJson).toString());
}
}
/**
* 方法执行完以后执行
*
* @param joinPoint
* @param result
*/
@AfterReturning(pointcut = "bizPoint()", returning = "result")
public void doAfterReturn(JoinPoint joinPoint, Object result) {
ParamLog paramLog = checkAnnotation(joinPoint);
if (paramLog == null) {
return;
}
Signature signature = joinPoint.getSignature();
String methodName = signature.getName();
String description = paramLog.description();
description = StringUtil.isEmpty(description) ? paramLog.value() : description;
StringBuffer msg = new StringBuffer(signature.getDeclaringTypeName())
.append(" 【" + methodName + " afterReturn】");
if (!StringUtil.isEmpty(description)) {
msg.append(description);
}
if (!paramLog.isAfterReturn()) {
LOGGER.info(msg.toString());
} else {
String resultJson = JSON.toJSONString(result);
LOGGER.info(msg.append(",[result]=").append(resultJson).toString());
}
}
private static ParamLog checkAnnotation(JoinPoint joinPoint) {
// 获取方法签名
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
// java reflect相关类,通过反射得到注解
Method method = signature.getMethod();
if (!method.isAnnotationPresent(ParamLog.class)) {
return null;
}
return method.getAnnotation(ParamLog.class);
}
private static ParamLog checkAnnotation(JoinPoint joinPoint) {
// 获取方法签名
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
// java reflect相关类,通过反射得到注解
Method method = signature.getMethod();
if (!method.isAnnotationPresent(ParamLog.class)) {
return null;
}
return method.getAnnotation(ParamLog.class);
}
}
......@@ -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 {
/**
* 英语随身听
*/
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);
/**
* 值
......
......@@ -11,10 +11,10 @@ package com.pcloud.common.core.constant;
*/
public class MQTopicProducer {
/**
* 文件转码结束(PDF、EXCEL)
*/
public static final String FILE_TRANSCODE = "topic.fileTranscode";
/**
* 文件转码结束(PDF、EXCEL)
*/
public static final String FILE_TRANSCODE = "topic.fileTranscode";
/**
* 音频配音结束(MP3)
......@@ -26,257 +26,259 @@ public class MQTopicProducer {
*/
public static final String BM_ADD_USER = "topic.bmAddUser";
/**
* 应用新增
*/
public static final String APP_ADD = "topic.appAdd";
/**
* 应用修改
*/
public static final String APP_UPDATE = "topic.appUpdate";
/**
* 应用删除
*/
public static final String APP_DELETE = "topic.appDelete";
/**
* 应用删除(新)
*/
public static final String APP_DELETE_NEW = "topic.appDeleteNew";
/**
* 应用审核
*/
public static final String APP_AUDIT = "topic.appAudit";
/**
* 选择默认渠道
*/
public static final String CHOOSE_DEFAULT_CHANNEL = "topic.chooseDefaultChannel";
/**
* 删除视频
*/
public static final String DELETE_VIDEO = "topic.deleteVideo";
/**
* 标签修改
*/
public static final String LABEL_UPDATE = "topic.labelUpdate";
/**
* 支付
*/
public static final String PAYMENT = "topic.payment";
/**
* TIP
*/
public static final String TIP = "topic.tip";
/**
* 打赏给读者
*/
public static final String TIP_FOR_WECHAT_USER = "topic.tipForWechatUser";
/**
* 应用新增
*/
public static final String APP_ADD = "topic.appAdd";
/**
* 应用修改
*/
public static final String APP_UPDATE = "topic.appUpdate";
/**
* 应用删除
*/
public static final String APP_DELETE = "topic.appDelete";
/**
* 应用删除(新)
*/
public static final String APP_DELETE_NEW = "topic.appDeleteNew";
/**
* 应用审核
*/
public static final String APP_AUDIT = "topic.appAudit";
/**
* 选择默认渠道
*/
public static final String CHOOSE_DEFAULT_CHANNEL = "topic.chooseDefaultChannel";
/**
* 删除视频
*/
public static final String DELETE_VIDEO = "topic.deleteVideo";
/**
* 标签修改
*/
public static final String LABEL_UPDATE = "topic.labelUpdate";
/**
* 支付
*/
public static final String PAYMENT = "topic.payment";
/**
* TIP
*/
public static final String TIP = "topic.tip";
/**
* 给读者的打赏
*/
public static final String TIP_FOR_WECHAT_USER = "topic.tipForWechatUser";
/**
* GENUINE
*/
public static final String GENUINE = "topic.genuine";
/**
* 订单完成
*/
public static final String FINISH_ORDER = "topic.finishOrder";
/**
* 资源修改
*/
public static final String RESOURCE_UPDATE = "topic.resourceUpdate";
/**
* 资源删除
*/
public static final String RESOURCE_DELETE = "topic.resourceDelete";
/**
* 扫码记录
*/
public static final String SCAN_RECORD = "topic.scanRecord";
/**
* 图书删除
*/
public static final String BOOK_DELETE = "topic.bookDelete";
/**
* BOOKTHAW
*/
public static final String BOOK_THAW = "topic.bookThaw";
/**
* TEMPLETAPPCREATE
*/
public static final String TEMPLET_APP_CREATE = "topic.templetAppCreate";
/**
* PERMISSION
*/
public static final String PERMISSION = "topic.permission";
/**
* PROMOTION_EXPIRE
*/
public static final String PROMOTION_EXPIRE = "topic.promotionExpire";
/**
* 商品修改
*/
public static final String PRODUCT_UPDATE = "topic.productUpdate";
/**
* 商品删除
*/
public static final String PRODUCT_DELETE = "topic.productDelete";
/**
* 商品审核
*/
public static final String PRODUCT_AUDIT = "topic.productAudit";
/**
* 商品图片1修改
*/
public static final String PRODUCT_PIC1_UPDATE = "topic.productPic1Update";
/**
* 用户注册
*/
public static final String REGISTER_PARTY = "topic.registerParty";
/**
* 用户修改
*/
public static final String UPDATE_PARTY = "topic.updateParty";
/**
* 问答确认
*/
public static final String QA_ASK = "topic.qaAsk";
/**
* 订单完成
*/
public static final String FINISH_ORDER = "topic.finishOrder";
/**
* 资源修改
*/
public static final String RESOURCE_UPDATE = "topic.resourceUpdate";
/**
* 资源删除
*/
public static final String RESOURCE_DELETE = "topic.resourceDelete";
/**
* 扫码记录
*/
public static final String SCAN_RECORD = "topic.scanRecord";
/**
* 图书删除
*/
public static final String BOOK_DELETE = "topic.bookDelete";
/**
* BOOKTHAW
*/
public static final String BOOK_THAW = "topic.bookThaw";
/**
* TEMPLETAPPCREATE
*/
public static final String TEMPLET_APP_CREATE = "topic.templetAppCreate";
/**
* PERMISSION
*/
public static final String PERMISSION = "topic.permission";
/**
* PROMOTION_EXPIRE
*/
public static final String PROMOTION_EXPIRE = "topic.promotionExpire";
/**
* 商品修改
*/
public static final String PRODUCT_UPDATE = "topic.productUpdate";
/**
* 商品删除
*/
public static final String PRODUCT_DELETE = "topic.productDelete";
/**
* 商品审核
*/
public static final String PRODUCT_AUDIT = "topic.productAudit";
/**
* 商品图片1修改
*/
public static final String PRODUCT_PIC1_UPDATE = "topic.productPic1Update";
/**
* 用户注册
*/
public static final String REGISTER_PARTY = "topic.registerParty";
/**
* 用户修改
*/
public static final String UPDATE_PARTY = "topic.updateParty";
/**
* 问答确认
*/
public static final String QA_ASK = "topic.qaAsk";
/**
* 问答完成
*/
public static final String QA_FINISH = "topic.qaFinish";
/**
* 问答答案
*/
public static final String QA_ANSWER = "topic.qaAnswer";
/**
* 问答取消
*/
public static final String QA_REFUSE = "topic.qaRefuse";
/**
* QR_MESSAGE_UPDATE
*/
public static final String QR_MESSAGE_UPDATE = "topic.qrMessageUpdate";
/**
* GIVE_GIFT
*/
public static final String GIVE_GIFT = "topic.giveGift";
/**
* 修改密码
*/
public static final String UPDATE_PWD = "topic.updatePwd";
/**
* 管理消息
*/
public static final String MANAGE_MESSAGE = "topic.manageMessage";
/**
* RETURN_4_ADVISER
*/
public static final String RETURN_4_ADVISER = "topic.return4adviser";
/**
* 退款
*/
public static final String REFUND = "topic.refund";
/**
* 退货
*/
public static final String REFUND_PRODUCT = "topic.refundProduct";
/**
* 发货
*/
public static final String SEND_PRODUCT = "topic.sendProduct";
/**
* 确认收货
*/
public static final String CONFIRM_ORDER = "topic.confirmOrder";
/**
* 申请退货
*/
public static final String APPLY_REFUND_PRODUCT = "topic.applyRefundProduct";
/**
* 取消订单
*/
public static final String CANCEL_ORDER = "topic.cancelOrder";
/**
* 模板二维码扫描
*/
public static final String TEMP_QRCODE_SCAN = "topic.tempQrcodeScan";
/**
* 删除二维码
*/
public static final String DELETE_QRCODE = "topic.deleteQrcode";
/**
* 二维码图书修改
*/
public static final String QRCODE_BOOK_UPDATE = "topic.qrcodeBookUpdate";
/**
* 重置
*/
public static final String RECHARGE = "topic.recharge";
/**
* 改变显示状态
*/
public static final String CHANGE_SHOW_STATE = "topic.changeShowState";
/**
* 删除合作出版社
*/
public static final String DELETE_COOPERATIVE_AGENT = "topic.deleteCooperativeAgent";
/**
* TASK_BONUS
*/
public static final String TASK_BONUS = "topic.taskBonus";
/**
* 读者消息
*/
public static final String READER_MESSAGE = "topic.readerMessage";
/**
* 记录用户习惯
*/
public static final String RECORD_USER_HABIT = "topic.recordUserHabit";
* 问答完成
*/
public static final String QA_FINISH = "topic.qaFinish";
/**
* 问答答案
*/
public static final String QA_ANSWER = "topic.qaAnswer";
/**
* 问答取消
*/
public static final String QA_REFUSE = "topic.qaRefuse";
/**
* QR_MESSAGE_UPDATE
*/
public static final String QR_MESSAGE_UPDATE = "topic.qrMessageUpdate";
/**
* GIVE_GIFT
*/
public static final String GIVE_GIFT = "topic.giveGift";
/**
* 修改密码
*/
public static final String UPDATE_PWD = "topic.updatePwd";
/**
* 管理消息
*/
public static final String MANAGE_MESSAGE = "topic.manageMessage";
/**
* RETURN_4_ADVISER
*/
public static final String RETURN_4_ADVISER = "topic.return4adviser";
/**
* 退款
*/
public static final String REFUND = "topic.refund";
/**
* 退货
*/
public static final String REFUND_PRODUCT = "topic.refundProduct";
/**
* 发货
*/
public static final String SEND_PRODUCT = "topic.sendProduct";
/**
* 确认收货
*/
public static final String CONFIRM_ORDER = "topic.confirmOrder";
/**
* 申请退货
*/
public static final String APPLY_REFUND_PRODUCT = "topic.applyRefundProduct";
/**
* 取消订单
*/
public static final String CANCEL_ORDER = "topic.cancelOrder";
/**
* 模板二维码扫描
*/
public static final String TEMP_QRCODE_SCAN = "topic.tempQrcodeScan";
/**
* 删除二维码
*/
public static final String DELETE_QRCODE = "topic.deleteQrcode";
/**
* 二维码图书修改
*/
public static final String QRCODE_BOOK_UPDATE = "topic.qrcodeBookUpdate";
/**
* 重置
*/
public static final String RECHARGE = "topic.recharge";
/**
* 改变显示状态
*/
public static final String CHANGE_SHOW_STATE = "topic.changeShowState";
/**
* 删除合作出版社
*/
public static final String DELETE_COOPERATIVE_AGENT = "topic.deleteCooperativeAgent";
/**
* TASK_BONUS
*/
public static final String TASK_BONUS = "topic.taskBonus";
/**
* 读者消息
*/
public static final String READER_MESSAGE = "topic.readerMessage";
/**
* 记录用户习惯
*/
public static final String RECORD_USER_HABIT = "topic.recordUserHabit";
/**
* 扫码
......@@ -288,23 +290,43 @@ public class MQTopicProducer {
*/
public static final String EXCHAGE = "rays.topic";
/**
* 更新图书封面图
*/
public static final String UPDATE_BOOK_COVERIMG = "topic.updateBookCoverImg";
/**
* 更新图书封面图
*/
public static final String UPDATE_BOOK_COVERIMG = "topic.updateBookCoverImg";
/**
* 更新图书名称
*/
public static final String UPDATE_BOOK_NAME = "topic.updateBookName";
/**
* 微信用户关系
*/
public static final String WECHAT_RELATE_INFO = "topic.wechatRelateInfo";
/**
* 微信用户关系
*/
public static final String WECHAT_RELATE_INFO = "topic.wechatRelateInfo";
/**
* 更新用户头像
*/
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 {
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};
......@@ -316,7 +332,7 @@ public class ProductTypeConstant {
* 资源型作品(免费即可体验)
*/
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 {
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,
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 {
ARTICLE_READING(AppTypeEnum.ARTICLE_READING.value, ProductTypeConstant.ARTICLE_READING),
ENGLISH_WALKMAN(AppTypeEnum.ENGLISH_WALKMAN.value, ProductTypeConstant.ENGLISH_WALKMAN),
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;
......
......@@ -59,7 +59,8 @@ public enum AppTypeEnum {
ENGLISH_WALKMAN("ENGLISH_WALKMAN"), //英语随身听
ORAL_EVALUATION("ORAL_EVALUATION"), //口语评测
WISH("WISH"),//愿望单
DRAW("DRAW");//抽奖
DRAW("DRAW"),//抽奖
LIVE_TIMETABLE("LIVE_TIMETABLE");//直播
/**
* 值
*/
......
......@@ -20,7 +20,12 @@ public enum NotifyOriginTypeEnum {
/**
* 订单
*/
ORDERNUM("ORDERNUM");
ORDERNUM("ORDERNUM"),
/**
* 社群书
*/
BOOK_GROUP("BOOK_GROUP");
/**
* 值
......
......@@ -9,62 +9,72 @@ package com.pcloud.common.core.enums;
*/
public enum TranscodeFromEnum {
/**
* 内容中心,office
*/
CONTENT_OFFICE("CONTENT_OFFICE"),
/**
* 内容中心,office
*/
CONTENT_OFFICE("CONTENT_OFFICE"),
/**
* 内容中心,PDF
*/
CONTENT_PDF("CONTENT_PDF"),
/**
* 内容中心,PDF
*/
CONTENT_PDF("CONTENT_PDF"),
/**
* 内容中心,好文PDF
*/
CONTENT_ARTICLE_PDF("CONTENT_ARTICLE_PDF"),
/**
* 内容中心,好文PDF
*/
CONTENT_ARTICLE_PDF("CONTENT_ARTICLE_PDF"),
/**
* 圈子应用
*/
GROUPAPP_PDF_OR_OFFICE("GROUPAPP_PDF_OR_OFFICE"),
/**
* 圈子应用
*/
GROUPAPP_PDF_OR_OFFICE("GROUPAPP_PDF_OR_OFFICE"),
/**
* 帮助中心
*/
HELPCENTER_PDF("HELPCENTER_PDF"),
/**
* 帮助中心
*/
HELPCENTER_PDF("HELPCENTER_PDF"),
/**
* 直播
*/
LIVE_PPT("LIVE_PPT"),
/**
* 直播
*/
LIVE_PPT("LIVE_PPT"),
/**
* 直播
*/
LIVE_HOMEWORD("LIVE_HOMEWORD"),
/**
* 直播
*/
LIVE_HOMEWORD("LIVE_HOMEWORD"),
/**
* 音频
*/
AUDIOAPP_PDF("AUDIOAPP_PDF"),
/**
* 音频
*/
AUDIOAPP_PDF("AUDIOAPP_PDF"),
/**
* 文件管理中心
*/
CONVERT_PDF("CONVERT_PDF");
/**
* 文件管理中心
*/
CONVERT_PDF("CONVERT_PDF"),
/**
* 值
*/
public final String code;
/**
* 错题本-题目
*/
NOTE_SUBJECT("NOTE_SUBJECT"),
/**
* 构造
*
* @param code
*/
private TranscodeFromEnum(String code) {
this.code = code;
}
/**
* 错题本-答案
*/
NOTE_ANSWER("NOTE_ANSWER");
/**
* 值
*/
public final String code;
/**
* 构造
*
* @param code
*/
private TranscodeFromEnum(String code) {
this.code = code;
}
}
/**
*
*/
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);
}
}
......@@ -290,151 +290,151 @@ public class FileUtils {
return false;
}
/**
* 该方法用来判断文件夹是否存在,如果不存在则创建,存在则什么都不做
*
* @param filePath
*/
public static boolean creatDir(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
if (!file.exists()) {
file.mkdir();
return true;
}
return false;
}
/**
* 该方法用来判断文件夹是否存在,如果不存在则创建,存在则什么都不做 该方法能够实现创建整个路径
*
* @param filePath
*/
public static boolean creatDirs(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
if (!file.exists()) {
file.mkdirs();
return true;
}
return false;
}
/**
* 获取文件类型
*
* @param filePath
*/
public static String getFileType(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return null;
}
int index1 = filePath.lastIndexOf(".");
if (index1 < 1) {
return null;
}
int index2 = filePath.lastIndexOf("?");
if (index2 > index1) {
filePath = filePath.substring(0, filePath.lastIndexOf("?"));
}
filePath = filePath.replace("/", OSConstant.SEPARATOR);
int index3 = filePath.lastIndexOf(OSConstant.SEPARATOR);
if (index3 > index1) {
return null;
}
return filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length()).toLowerCase();
}
/**
* 获取文件名称
*
* @param filePath
*/
public static String getFileName(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return null;
}
String fileName = null;
filePath = filePath.replace("/", OSConstant.SEPARATOR);
int index1 = filePath.lastIndexOf(".");
if (index1 > -1) {
int index2 = filePath.lastIndexOf("?");
if (index2 > index1) {
filePath = filePath.substring(0, filePath.lastIndexOf("?"));
}
int index3 = filePath.lastIndexOf(OSConstant.SEPARATOR);
if (index3 > index1) {
fileName = filePath.substring(filePath.lastIndexOf(OSConstant.SEPARATOR) + 1);
} else {
fileName = filePath.substring(filePath.lastIndexOf(OSConstant.SEPARATOR) + 1,
filePath.lastIndexOf("."));
}
} else {
fileName = filePath.substring(filePath.lastIndexOf(OSConstant.SEPARATOR) + 1);
}
return formatName(fileName);
}
/**
* 获取文件名称包括后缀
*
* @param filePath
* @return
*/
public static String getFileNameAll(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return null;
}
String fileName = getFileName(filePath);
if (StringUtil.isEmpty(fileName)) {
return null;
}
String fileType = getFileType(filePath);
return StringUtil.isEmpty(fileType) ? fileName : fileName + "." + fileType;
}
/**
* 格式化文件名称,过滤特殊字符(名称太长进行截断)
*
* @param fileName
*/
public static String formatName(String fileName) {
if (StringUtil.isEmpty(fileName)) {
return null;
}
try {
String regEx = "[*/\\\\:?\"<|>\\s+%#&=.()]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(fileName);
String result = m.replaceAll("").trim();
// 文件名称过长的话,限制40个字
return result.length() > 40 ? result.substring(0, 40) : result;
} catch (Exception e) {
LOGGER.error("【文件API】格式化文件名称.[formatName]:" + e.getMessage(), e);
return UUIDUitl.taskName();
}
}
/**
* 获取文件所在的目录
*
* @param filePath
* @return
*/
public static String getFileFolder(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return null;
}
return filePath.substring(0, filePath.lastIndexOf(OSConstant.SEPARATOR));
}
/**
* 该方法用来判断文件夹是否存在,如果不存在则创建,存在则什么都不做
*
* @param filePath
*/
public static boolean creatDir(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
if (!file.exists()) {
file.mkdir();
return true;
}
return false;
}
/**
* 该方法用来判断文件夹是否存在,如果不存在则创建,存在则什么都不做 该方法能够实现创建整个路径
*
* @param filePath
*/
public static boolean creatDirs(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
if (!file.exists()) {
file.mkdirs();
return true;
}
return false;
}
/**
* 获取文件类型
*
* @param filePath
*/
public static String getFileType(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return null;
}
int index1 = filePath.lastIndexOf(".");
if (index1 < 1) {
return null;
}
int index2 = filePath.lastIndexOf("?");
if (index2 > index1) {
filePath = filePath.substring(0, filePath.lastIndexOf("?"));
}
filePath = filePath.replace("/", OSConstant.SEPARATOR);
int index3 = filePath.lastIndexOf(OSConstant.SEPARATOR);
if (index3 > index1) {
return null;
}
return filePath.substring(filePath.lastIndexOf(".") + 1, filePath.length()).toLowerCase();
}
/**
* 获取文件名称
*
* @param filePath
*/
public static String getFileName(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return null;
}
String fileName = null;
filePath = filePath.replace("/", OSConstant.SEPARATOR);
int index1 = filePath.lastIndexOf(".");
if (index1 > -1) {
int index2 = filePath.lastIndexOf("?");
if (index2 > index1) {
filePath = filePath.substring(0, filePath.lastIndexOf("?"));
}
int index3 = filePath.lastIndexOf(OSConstant.SEPARATOR);
if (index3 > index1) {
fileName = filePath.substring(filePath.lastIndexOf(OSConstant.SEPARATOR) + 1);
} else {
fileName = filePath.substring(filePath.lastIndexOf(OSConstant.SEPARATOR) + 1,
filePath.lastIndexOf("."));
}
} else {
fileName = filePath.substring(filePath.lastIndexOf(OSConstant.SEPARATOR) + 1);
}
return formatName(fileName);
}
/**
* 获取文件名称包括后缀
*
* @param filePath
* @return
*/
public static String getFileNameAll(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return null;
}
String fileName = getFileName(filePath);
if (StringUtil.isEmpty(fileName)) {
return null;
}
String fileType = getFileType(filePath);
return StringUtil.isEmpty(fileType) ? fileName : fileName + "." + fileType;
}
/**
* 格式化文件名称,过滤特殊字符(名称太长进行截断)
*
* @param fileName
*/
public static String formatName(String fileName) {
if (StringUtil.isEmpty(fileName)) {
return null;
}
try {
String regEx = "[*/\\\\:?\"<|>\\s+%#&=.()]";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(fileName);
String result = m.replaceAll("").trim();
// 文件名称过长的话,限制40个字
return result.length() > 40 ? result.substring(0, 40) : result;
} catch (Exception e) {
LOGGER.error("【文件API】格式化文件名称.[formatName]:" + e.getMessage(), e);
return UUIDUitl.taskName();
}
}
/**
* 获取文件所在的目录
*
* @param filePath
* @return
*/
public static String getFileFolder(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return null;
}
return filePath.substring(0, filePath.lastIndexOf(OSConstant.SEPARATOR));
}
/**
* 获取http文件路径的域名
*
*
* @param fileUrl
* @return
*/
......@@ -450,415 +450,425 @@ public class FileUtils {
return null;
}
/**
* FileUtils工具 File @throws
*/
public static File copyURLToFile(String url, String dir) throws Exception {
try {
URL httpurl = new URL(url);
File f = new File(dir);
org.apache.commons.io.FileUtils.copyURLToFile(httpurl, f);
return f;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 根据路径删除指定的目录或文件,无论存在与否
*
* @param sPath 要删除的目录或文件
* @return 删除成功返回 true,否则返回 false。
*/
public static boolean deleteFolder(String sPath) {
if (StringUtil.isEmpty(sPath)) {
return false;
}
boolean flag = false;
File file = new File(sPath);
// 判断目录或文件是否存在
if (!file.exists()) { // 不存在返回 false
return flag;
} else {
// 判断是否为文件
if (file.isFile()) { // 为文件时调用删除文件方法
return deleteFile(sPath);
} else { // 为目录时调用删除目录方法
return deleteDirectory(sPath);
}
}
}
/**
* 删除单个文件
*
* @param sPath 被删除文件的文件名
* @return 单个文件删除成功返回true,否则返回false
*/
public static boolean deleteFile(String sPath) {
if (StringUtil.isEmpty(sPath)) {
return false;
}
boolean flag = false;
File file = new File(sPath);
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists()) {
file.delete();
flag = true;
}
return flag;
}
/**
* 删除目录(文件夹)以及目录下的文件
*
* @param sPath 被删除目录的文件路径
* @return 目录删除成功返回true,否则返回false
*/
public static boolean deleteDirectory(String sPath) {
if (StringUtil.isEmpty(sPath)) {
return false;
}
// 如果sPath不以文件分隔符结尾,自动添加文件分隔符
if (!sPath.endsWith(File.separator)) {
sPath = sPath + File.separator;
}
File dirFile = new File(sPath);
// 如果dir对应的文件不存在,或者不是一个目录,则退出
if (!dirFile.exists() || !dirFile.isDirectory()) {
return false;
}
boolean flag = true;
// 删除文件夹下的所有文件(包括子目录)
File[] files = dirFile.listFiles();
for (int i = 0; i < files.length; i++) {
// 删除子文件
if (files[i].isFile()) {
flag = deleteFile(files[i].getAbsolutePath());
if (!flag)
break;
} // 删除子目录
else {
flag = deleteDirectory(files[i].getAbsolutePath());
if (!flag)
break;
}
}
if (!flag)
return false;
// 删除当前目录
if (dirFile.delete()) {
return true;
} else {
return false;
}
}
/**
* 检查文件是否存在
*
* @param filePath
* @return
*/
public static boolean checkFile(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
if (!file.isFile()) {
return false;
}
return true;
}
/**
* | FileUtils工具
*/
public static void downloadFileFromUrl(String url, String localFilePath) throws FileException {
LOGGER.info("【文件API】下载文件[本地文件].<START>.[url]=" + url + ",[localFilePath]=" + localFilePath);
creatFiles(localFilePath);
try {
if (StringTools.contains(url, AliyunConstant.OSS_CDN_URLS)) {
OssUtils.downloadFile(url, localFilePath);
// } else if (url.contains("/group")) {
// Map<String, String> paramMap = FdfsUtils.splitFilePath(url);
// FdfsUtils.download(paramMap.get(FdfsEnum.GROUP_NAME.value),
// paramMap.get(FdfsEnum.FILE_ID.value), localFilePath);
} else {
File f = new File(localFilePath);
URL httpurl = new URL(url);
org.apache.commons.io.FileUtils.copyURLToFile(httpurl, f);
}
} catch (Exception e) {
LOGGER.error("【文件API】下载文件.[copyURLToFile]:" + e.getMessage(), e);
throw new FileException(FileException.FILE_DOWNLOAD_FAILURE, "下载文件失败");
}
}
/**
* IOUtils工具
*/
public static byte[] downloadByteFromUrl(String url) throws FileException {
LOGGER.info("【文件API】下载文件[byte].<START>.[url]=" + url);
if (StringUtil.isEmpty(url)) {
return null;
}
byte[] data = null;
try {
if (StringTools.contains(url, AliyunConstant.OSS_CDN_URLS)) {
data = OssUtils.downloadFile2Byte(url);
// } else if (url.contains("/group")) {
// Map<String, String> paramMap = FdfsUtils.splitFilePath(url);
// data =
// FdfsUtils.download(paramMap.get(FdfsEnum.GROUP_NAME.value),
// paramMap.get(FdfsEnum.FILE_ID.value));
} else {
URL httpurl = new URL(url);
data = IOUtils.toByteArray(httpurl);
}
} catch (Exception e) {
LOGGER.error("【文件API】下载文件.[toByteArray]:" + e.getMessage(), e);
throw new FileException(FileException.FILE_DOWNLOAD_FAILURE, "下载文件失败");
}
return data;
}
/**
* InputStream
*/
@Deprecated
public static InputStream downloadStreamFromUrl(String url) throws FileException {
try {
URL httpurl = new URL(url);
return httpurl.openStream();
} catch (Exception e) {
LOGGER.error("【文件API】下载文件.[openStream]:" + e.getMessage(), e);
throw new FileException(FileException.FILE_DOWNLOAD_FAILURE, "下载文件失败");
}
}
/**
* 普通情况下保存字节数据到本地文件
*/
public synchronized static boolean saveBytesTofile(File file, byte[] data) throws BizException {
FileOutputStream fos = null;
// 建立输出字节流
try {
fos = new FileOutputStream(file);
fos.write(data); // 用FileOutputStream 的write方法写入字节数组
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 复制一个文件到另一个目录下
*
* @throws BizException
*/
public static void copyFileToFolder(File inputFile, File outputFile) throws BizException {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(inputFile);
fos = new FileOutputStream(outputFile);
int len = 0;
byte[] buf = new byte[1024];
while ((len = fis.read(buf)) != -1) {
fos.write(buf, 0, len);
}
fis.close();
fos.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
/**
* 合并两个文件
*
* @param outFile 目标文件
* @param leafFile 源文件
*/
public static void mergeFiles(File outFile, File leafFile) {
FileOutputStream fos = null;
FileInputStream fis = null;
if (!outFile.exists()) {
try {
outFile.createNewFile();
} catch (Exception e) {
throw new FileException(FileException.FILE_NOT_EXIST, "创建临时存储文件失败");
}
}
try {
// 合并其实就是文件的续写,写成true
fos = new FileOutputStream(outFile, true);
fis = new FileInputStream(leafFile);
int len = 0;
for (byte[] buf = new byte[1024 * 1024]; (len = fis.read(buf)) != -1; ) {
fos.write(buf, 0, len);
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (fis != null)
fis.close();
if (fos != null)
fos.close();
} catch (Exception e) {
}
}
}
/**
* 合并多个文件
*
* @param outFile 输出文件,
* @param leafFiles 文件碎片集
*/
public static void mergeFileList(File outFile, List<File> leafFiles) {
FileOutputStream fos = null;
FileInputStream fis = null;
if (!outFile.exists()) {
try {
outFile.createNewFile();
} catch (Exception e) {
throw new FileException(FileException.FILE_NOT_EXIST, "创建临时存储文件失败");
}
}
try {
// 合并其实就是文件的续写,写成true
fos = new FileOutputStream(outFile, true);
byte[] buf = new byte[1024 * 1024];
for (File leafFile : leafFiles) {
fis = new FileInputStream(leafFile);
int len = 0;
while ((len = fis.read(buf)) != -1) {
fos.write(buf, 0, len);
}
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (fis != null)
fis.close();
if (fos != null)
fos.close();
} catch (Exception e) {
}
}
}
/**
* 音频文件转换
*
* @param data 音频byte数组
* @param sourExt 原始后缀
* @param ext 新后缀
* @return
* @author PENG
*/
public static String audioFormatConvert(byte[] data, String sourExt, String ext) {
File tmpdir = new File("tempdir/local");
if (!tmpdir.exists()) {
try {
tmpdir.mkdirs();
} catch (SecurityException ex) {
System.out.println("无法创建临时文件夹");
ex.printStackTrace();
}
}
String name = UUID.randomUUID().toString();
File source = new File(tmpdir, name + "." + sourExt);
boolean creat = saveBytesTofile(source, data);
if (creat) {
File target = new File(tmpdir, name + "." + ext);
AudioAttributes audio = new AudioAttributes();
Encoder encoder = new Encoder();
audio.setCodec("libmp3lame");
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat(ext.toLowerCase());
attrs.setAudioAttributes(audio);
try {
encoder.encode(source, target, attrs);
return target.getPath();
} catch (IllegalArgumentException e) {
e.printStackTrace();
return null;
} catch (InputFormatException e) {
e.printStackTrace();
return null;
} catch (EncoderException e) {
e.printStackTrace();
return target.getPath();
}
} else {
return null;
}
}
/**
* 获取文本的内容
*
* @param url
* @return
*/
public static String getTextString(String url) {
LOGGER.info("【文件API】获取文本的内容.<START>.[url]=" + url);
if (StringUtil.isEmpty(url)) {
return null;
}
StringBuilder lrcString = new StringBuilder();
InputStream is = null;
InputStreamReader isr = null;
try {
byte[] bt = downloadByteFromUrl(url);
is = new ByteArrayInputStream(bt);
boolean isUTF8Bom = CpdetectorEncoding.isUTF8Bom(is);
if (isUTF8Bom) {
isr = new InputStreamReader(is, "UTF-8");
} else {
Object charSet = CpdetectorEncoding.getEncoding(bt, false);
if (charSet.toString().equals("UTF-8")) {
isr = new InputStreamReader(is, "UTF-8");
} else {
isr = new InputStreamReader(new ByteArrayInputStream(bt), "GBK");
}
}
BufferedReader br = new BufferedReader(isr);// 构造一个BufferedReader类来读取文件
String s;
while ((s = br.readLine()) != null) {// 使用readLine方法,一次读一行
lrcString.append(System.lineSeparator() + s);
}
} catch (Exception e) {
LOGGER.error("【文件工具】读取文件内容.<ERROR>:" + e.getMessage(), e);
} finally {
try {
if (isr != null)
isr.close();
if (is != null)
is.close();
} catch (Exception e2) {
}
}
LOGGER.info("【文件API】获取文本的内容.<END>");
return lrcString.toString();
}
/**
* FileUtils工具 File @throws
*/
public static File copyURLToFile(String url, String dir) throws Exception {
try {
URL httpurl = new URL(url);
File f = new File(dir);
org.apache.commons.io.FileUtils.copyURLToFile(httpurl, f);
return f;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 根据路径删除指定的目录或文件,无论存在与否
*
* @param sPath
* 要删除的目录或文件
* @return 删除成功返回 true,否则返回 false。
*/
public static boolean deleteFolder(String sPath) {
if (StringUtil.isEmpty(sPath)) {
return false;
}
boolean flag = false;
File file = new File(sPath);
// 判断目录或文件是否存在
if (!file.exists()) { // 不存在返回 false
return flag;
} else {
// 判断是否为文件
if (file.isFile()) { // 为文件时调用删除文件方法
return deleteFile(sPath);
} else { // 为目录时调用删除目录方法
return deleteDirectory(sPath);
}
}
}
/**
* 删除单个文件
*
* @param sPath
* 被删除文件的文件名
* @return 单个文件删除成功返回true,否则返回false
*/
public static boolean deleteFile(String sPath) {
if (StringUtil.isEmpty(sPath)) {
return false;
}
boolean flag = false;
File file = new File(sPath);
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists()) {
file.delete();
flag = true;
}
return flag;
}
/**
* 删除目录(文件夹)以及目录下的文件
*
* @param sPath
* 被删除目录的文件路径
* @return 目录删除成功返回true,否则返回false
*/
public static boolean deleteDirectory(String sPath) {
if (StringUtil.isEmpty(sPath)) {
return false;
}
// 如果sPath不以文件分隔符结尾,自动添加文件分隔符
if (!sPath.endsWith(File.separator)) {
sPath = sPath + File.separator;
}
File dirFile = new File(sPath);
// 如果dir对应的文件不存在,或者不是一个目录,则退出
if (!dirFile.exists() || !dirFile.isDirectory()) {
return false;
}
boolean flag = true;
// 删除文件夹下的所有文件(包括子目录)
File[] files = dirFile.listFiles();
for (int i = 0; i < files.length; i++) {
// 删除子文件
if (files[i].isFile()) {
flag = deleteFile(files[i].getAbsolutePath());
if (!flag)
break;
} // 删除子目录
else {
flag = deleteDirectory(files[i].getAbsolutePath());
if (!flag)
break;
}
}
if (!flag)
return false;
// 删除当前目录
if (dirFile.delete()) {
return true;
} else {
return false;
}
}
/**
* 检查文件是否存在
*
* @param filePath
* @return
*/
public static boolean checkFile(String filePath) {
if (StringUtil.isEmpty(filePath)) {
return false;
}
File file = new File(filePath);
if (!file.isFile()) {
return false;
}
return true;
}
/**
* | FileUtils工具
*/
public static void downloadFileFromUrl(String url, String localFilePath) throws FileException {
LOGGER.info("【文件API】下载文件[本地文件].<START>.[url]=" + url + ",[localFilePath]=" + localFilePath);
creatFiles(localFilePath);
try {
if (StringTools.contains(url, AliyunConstant.OSS_CDN_URLS)) {
OssUtils.downloadFile(url, localFilePath);
// } else if (url.contains("/group")) {
// Map<String, String> paramMap = FdfsUtils.splitFilePath(url);
// FdfsUtils.download(paramMap.get(FdfsEnum.GROUP_NAME.value),
// paramMap.get(FdfsEnum.FILE_ID.value), localFilePath);
} else {
File f = new File(localFilePath);
URL httpurl = new URL(url);
org.apache.commons.io.FileUtils.copyURLToFile(httpurl, f);
}
} catch (Exception e) {
LOGGER.error("【文件API】下载文件.[copyURLToFile]:" + e.getMessage(), e);
throw new FileException(FileException.FILE_DOWNLOAD_FAILURE, "下载文件失败");
}
}
/**
* IOUtils工具
*/
public static byte[] downloadByteFromUrl(String url) throws FileException {
LOGGER.info("【文件API】下载文件[byte].<START>.[url]=" + url);
if (StringUtil.isEmpty(url)) {
return null;
}
byte[] data = null;
try {
if (StringTools.contains(url, AliyunConstant.OSS_CDN_URLS)) {
data = OssUtils.downloadFile2Byte(url);
// } else if (url.contains("/group")) {
// Map<String, String> paramMap = FdfsUtils.splitFilePath(url);
// data =
// FdfsUtils.download(paramMap.get(FdfsEnum.GROUP_NAME.value),
// paramMap.get(FdfsEnum.FILE_ID.value));
} else {
URL httpurl = new URL(url);
data = IOUtils.toByteArray(httpurl);
}
} catch (Exception e) {
LOGGER.error("【文件API】下载文件.[toByteArray]:" + e.getMessage(), e);
throw new FileException(FileException.FILE_DOWNLOAD_FAILURE, "下载文件失败");
}
return data;
}
/**
* InputStream
*/
@Deprecated
public static InputStream downloadStreamFromUrl(String url) throws FileException {
try {
URL httpurl = new URL(url);
return httpurl.openStream();
} catch (Exception e) {
LOGGER.error("【文件API】下载文件.[openStream]:" + e.getMessage(), e);
throw new FileException(FileException.FILE_DOWNLOAD_FAILURE, "下载文件失败");
}
}
/**
* 普通情况下保存字节数据到本地文件
*/
public synchronized static boolean saveBytesTofile(File file, byte[] data) throws BizException {
FileOutputStream fos = null;
// 建立输出字节流
try {
fos = new FileOutputStream(file);
fos.write(data); // 用FileOutputStream 的write方法写入字节数组
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 复制一个文件到另一个目录下
*
* @throws BizException
*/
public static void copyFileToFolder(File inputFile, File outputFile) throws BizException {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(inputFile);
fos = new FileOutputStream(outputFile);
int len = 0;
byte[] buf = new byte[1024];
while ((len = fis.read(buf)) != -1) {
fos.write(buf, 0, len);
}
fis.close();
fos.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
/**
* 合并两个文件
*
* @param outFile
* 目标文件
* @param leafFile
* 源文件
*/
public static void mergeFiles(File outFile, File leafFile) {
FileOutputStream fos = null;
FileInputStream fis = null;
if (!outFile.exists()) {
try {
outFile.createNewFile();
} catch (Exception e) {
throw new FileException(FileException.FILE_NOT_EXIST, "创建临时存储文件失败");
}
}
try {
// 合并其实就是文件的续写,写成true
fos = new FileOutputStream(outFile, true);
fis = new FileInputStream(leafFile);
int len = 0;
for (byte[] buf = new byte[1024 * 1024]; (len = fis.read(buf)) != -1;) {
fos.write(buf, 0, len);
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (fis != null)
fis.close();
if (fos != null)
fos.close();
} catch (Exception e) {
}
}
}
/**
* 合并多个文件
*
* @param outFile
* 输出文件,
* @param leafFiles
* 文件碎片集
*/
public static void mergeFileList(File outFile, List<File> leafFiles) {
FileOutputStream fos = null;
FileInputStream fis = null;
if (!outFile.exists()) {
try {
outFile.createNewFile();
} catch (Exception e) {
throw new FileException(FileException.FILE_NOT_EXIST, "创建临时存储文件失败");
}
}
try {
// 合并其实就是文件的续写,写成true
fos = new FileOutputStream(outFile, true);
byte[] buf = new byte[1024 * 1024];
for (File leafFile : leafFiles) {
fis = new FileInputStream(leafFile);
int len = 0;
while ((len = fis.read(buf)) != -1) {
fos.write(buf, 0, len);
}
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
try {
if (fis != null)
fis.close();
if (fos != null)
fos.close();
} catch (Exception e) {
}
}
}
/**
* 音频文件转换
*
* @param data
* 音频byte数组
* @param sourExt
* 原始后缀
* @param ext
* 新后缀
* @return
* @author PENG
*/
public static String audioFormatConvert(byte[] data, String sourExt, String ext) {
File tmpdir = new File("tempdir/local");
if (!tmpdir.exists()) {
try {
tmpdir.mkdirs();
} catch (SecurityException ex) {
System.out.println("无法创建临时文件夹");
ex.printStackTrace();
}
}
String name = UUID.randomUUID().toString();
File source = new File(tmpdir, name + "." + sourExt);
boolean creat = saveBytesTofile(source, data);
if (creat) {
File target = new File(tmpdir, name + "." + ext);
AudioAttributes audio = new AudioAttributes();
Encoder encoder = new Encoder();
audio.setCodec("libmp3lame");
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat(ext.toLowerCase());
attrs.setAudioAttributes(audio);
try {
encoder.encode(source, target, attrs);
return target.getPath();
} catch (IllegalArgumentException e) {
e.printStackTrace();
return null;
} catch (InputFormatException e) {
e.printStackTrace();
return null;
} catch (EncoderException e) {
e.printStackTrace();
return target.getPath();
}
} else {
return null;
}
}
/**
* 获取文本的内容
*
* @param url
* @return
*/
public static String getTextString(String url) {
LOGGER.info("【文件API】获取文本的内容.<START>.[url]=" + url);
if (StringUtil.isEmpty(url)) {
return null;
}
StringBuilder lrcString = new StringBuilder();
InputStream is = null;
InputStreamReader isr = null;
try {
byte[] bt = downloadByteFromUrl(url);
is = new ByteArrayInputStream(bt);
boolean isUTF8Bom = CpdetectorEncoding.isUTF8Bom(is);
if (isUTF8Bom) {
isr = new InputStreamReader(is, "UTF-8");
} else {
Object charSet = CpdetectorEncoding.getEncoding(bt, false);
if (charSet.toString().equals("UTF-8")) {
isr = new InputStreamReader(is, "UTF-8");
} else {
isr = new InputStreamReader(new ByteArrayInputStream(bt), "GBK");
}
}
BufferedReader br = new BufferedReader(isr);// 构造一个BufferedReader类来读取文件
String s;
while ((s = br.readLine()) != null) {// 使用readLine方法,一次读一行
lrcString.append(System.lineSeparator() + s);
}
} catch (Exception e) {
LOGGER.error("【文件工具】读取文件内容.<ERROR>:" + e.getMessage(), e);
} finally {
try {
if (isr != null)
isr.close();
if (is != null)
is.close();
} catch (Exception e2) {
}
}
LOGGER.info("【文件API】获取文本的内容.<END>");
return lrcString.toString();
}
/**
* java 8 读取文本内容
......@@ -1004,113 +1014,114 @@ public class FileUtils {
return outFilePath;
}
/**
* 将文件转成base64 字符串
*
* @param data
* @return *
* @throws Exception
*/
public static String encodeBase64File(byte[] data) throws BizException {
try {
return new String(Base64.encodeBase64(data));
} catch (Exception e) {
LOGGER.error("【文件工具】将base64字符解码保存文件失败:" + e.getMessage(), e);
return null;
}
}
/**
* 将base64字符解码保存文件
*
* @param base64Code
* @param targetPath
* @throws Exception
*/
public static boolean decoderBase64File(String base64Code, String targetPath) throws BizException {
if (base64Code == null)
return false;
OutputStream out = null;
try {
// Base64解码
byte[] b = Base64.decodeBase64(targetPath);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {// 调整异常数据
b[i] += 256;
}
}
// 生成jpeg图片
out = new FileOutputStream(targetPath);
out.write(b);
out.flush();
} catch (Exception e) {
LOGGER.error("【文件工具】将base64字符解码保存文件失败:" + e.getMessage(), e);
return false;
} finally {
try {
if (out != null)
out.close();
} catch (Exception e) {
}
}
return true;
}
/**
* 本地文件到byte数组
*
* @param path
* @return
*/
public static byte[] file2byte(String path) {
byte[] data = null;
FileInputStream fis = null;
ByteArrayOutputStream os = null;
try {
fis = new FileInputStream(new File(path));
os = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int numBytesRead = 0;
while ((numBytesRead = fis.read(buf)) != -1) {
os.write(buf, 0, numBytesRead);
}
data = os.toByteArray();
} catch (Exception e) {
LOGGER.error("【文件工具】文件到byte数组:" + e.getMessage(), e);
} finally {
try {
if (fis != null)
fis.close();
if (os != null)
os.close();
} catch (IOException e) {
LOGGER.error("【文件工具】文件流关闭失败:" + e.getMessage(), e);
}
}
return data;
}
/**
* 从输入流中获取数据
*
* @param inStream 输入流
* @return
* @throws Exception
*/
public static byte[] readInputStream(InputStream inStream) throws Exception {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
try {
while ((len = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, len);
}
} catch (Exception e) {
LOGGER.error("【文件工具】文件流到byte数组:" + e.getMessage(), e);
} finally {
inStream.close();
}
return outStream.toByteArray();
}
/**
* 将文件转成base64 字符串
*
* @param data
* @return *
* @throws Exception
*/
public static String encodeBase64File(byte[] data) throws BizException {
try {
return new String(Base64.encodeBase64(data));
} catch (Exception e) {
LOGGER.error("【文件工具】将base64字符解码保存文件失败:" + e.getMessage(), e);
return null;
}
}
/**
* 将base64字符解码保存文件
*
* @param base64Code
* @param targetPath
* @throws Exception
*/
public static boolean decoderBase64File(String base64Code, String targetPath) throws BizException {
if (base64Code == null)
return false;
OutputStream out = null;
try {
// Base64解码
byte[] b = Base64.decodeBase64(targetPath);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {// 调整异常数据
b[i] += 256;
}
}
// 生成jpeg图片
out = new FileOutputStream(targetPath);
out.write(b);
out.flush();
} catch (Exception e) {
LOGGER.error("【文件工具】将base64字符解码保存文件失败:" + e.getMessage(), e);
return false;
} finally {
try {
if (out != null)
out.close();
} catch (Exception e) {
}
}
return true;
}
/**
* 本地文件到byte数组
*
* @param path
* @return
*/
public static byte[] file2byte(String path) {
byte[] data = null;
FileInputStream fis = null;
ByteArrayOutputStream os = null;
try {
fis = new FileInputStream(new File(path));
os = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int numBytesRead = 0;
while ((numBytesRead = fis.read(buf)) != -1) {
os.write(buf, 0, numBytesRead);
}
data = os.toByteArray();
} catch (Exception e) {
LOGGER.error("【文件工具】文件到byte数组:" + e.getMessage(), e);
} finally {
try {
if (fis != null)
fis.close();
if (os != null)
os.close();
} catch (IOException e) {
LOGGER.error("【文件工具】文件流关闭失败:" + e.getMessage(), e);
}
}
return data;
}
/**
* 从输入流中获取数据
*
* @param inStream
* 输入流
* @return
* @throws Exception
*/
public static byte[] readInputStream(InputStream inStream) throws Exception {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
try {
while ((len = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, len);
}
} catch (Exception e) {
LOGGER.error("【文件工具】文件流到byte数组:" + e.getMessage(), e);
} finally {
inStream.close();
}
return outStream.toByteArray();
}
}
......@@ -11,10 +11,11 @@ import java.math.BigDecimal;
import javax.imageio.ImageIO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.dcg.util.StringUtils;
import com.itextpdf.text.Image;
import com.pcloud.common.constant.AliyunConstant;
import com.pcloud.common.constant.FilePathConst;
......@@ -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
......@@ -653,29 +691,30 @@ public class ImageUtils {
LOGGER.error("【图片】输出文件流关闭失败:" + e.getMessage(), e);
}
}
/**
* 获取图片的宽度和高度
* 获取图片的宽度和高度(未考虑图片旋转的情况。也就是说,获得的宽可能是宽也可能是高,高可能是高也肯是宽)
*
* @param img
* 图片文件
* @param fileUrl
* @return
*/
public static float[] getWidthHeightSize(String fileUrl) {
public static float[] getWidthHeightNoOrient(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")) {
/*
* if (StringTools.contains(fileUrl, AliyunConstant.OSS_CDN_URLS)) { localFile =
* OssUtils.imageAutoOrient(fileUrl); 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】获取图片的宽度和高度:" + e.getMessage(), e);
LOGGER.error("【IMAGE API】获取图片的宽度和高度[getWidthHeightNoOrient]:" + e.getMessage(), e);
} finally {
if (!StringUtil.isEmpty(localFile)) {
FileUtils.deleteFile(localFile);
......@@ -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
*
* @param localFilePath
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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 {
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 信息處理
* @param userInfo
* @return
......@@ -214,6 +229,26 @@ public class Cookie {
userInfos.put(SECOND_TD, StringUtil.isEmpty(code) || "undefined".equalsIgnoreCase(code) || "null".equalsIgnoreCase(code) ? null
: 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;
}
......
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