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);
/**
* 值
......
......@@ -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);
}
}
......@@ -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