🎨 改进结构和代码格式。 修改部分P3C 不规范代码
This commit is contained in:
1 parent
f6a5220c3e
commit
bfa08e6166
6 files changed
+9
-181
No files matched your search
+2
-1
@@ -10,7 +10,8 @@ import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* 基于DB取步长,序列号生成器构建者
|
||||
* Created by xuan on 2018/5/30.
|
||||
*
|
||||
* @author xuan
|
||||
*/
|
||||
public class DbSeqBuilder implements SeqBuilder {
|
||||
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
package com.pig4cloud.pigx.admin.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author: Luckly
|
||||
* @date: 2019-06-18
|
||||
* @description: 文件套件
|
||||
*/
|
||||
public class FileKit {
|
||||
|
||||
private final static String[] TYPE_IMAGE = new String[]{".png", ".jpg", ".jpeg", ".gif", ".bmp"};
|
||||
private final static String[] TYPE_VIDEO = new String[]{".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg", ".ogv", ".mov", ".wmv", ".mp4", ".webm"};
|
||||
private final static String[] TYPE_AUDIO = new String[]{".mp3", ".wav", ".mid", ".ogg"};
|
||||
private final static String[] TYPE_DOC = new String[]{".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf"};
|
||||
|
||||
|
||||
/**
|
||||
* 判断文件大小
|
||||
*
|
||||
* @param len 文件长度
|
||||
* @param size 限制大小
|
||||
* @param unit 限制单位(B,K,M,G)
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkFileSize(Long len, int size, String unit) {
|
||||
double fileSize = 0;
|
||||
if ("B".equals(unit.toUpperCase())) {
|
||||
fileSize = (double) len;
|
||||
} else if ("K".equals(unit.toUpperCase())) {
|
||||
fileSize = (double) len / 1024;
|
||||
} else if ("M".equals(unit.toUpperCase())) {
|
||||
fileSize = (double) len / 1048576;
|
||||
} else if ("G".equals(unit.toUpperCase())) {
|
||||
fileSize = (double) len / 1073741824;
|
||||
} else {
|
||||
fileSize = (double) len;
|
||||
}
|
||||
if (fileSize > size) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换文件大小为友好显示
|
||||
*
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public static String getDisplaySize(long size) {
|
||||
String displaySize = size + "";
|
||||
if (size < 1024) {
|
||||
displaySize = size + "B";
|
||||
} else if (size < 1024 * 1024) {
|
||||
displaySize = getDisplaySizeKB(size);
|
||||
} else if (size < 1024 * 1024 * 1024) {
|
||||
displaySize = getDisplaySizeMB(size);
|
||||
} else if (size < 1024.0 * 1024 * 1024 * 1024) {
|
||||
displaySize = getDisplaySizeGB(size);
|
||||
} else if (size < 1024.0 * 1024 * 1024 * 1024 * 1024) {
|
||||
displaySize = getDisplaySizeTB(size);
|
||||
}
|
||||
return displaySize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换文件大小为友好显示
|
||||
*
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public static String getDisplaySizeKB(long size) {
|
||||
return new BigDecimal(size).divide(new BigDecimal(1024)).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue() + "KB";
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换文件大小为友好显示
|
||||
*
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public static String getDisplaySizeMB(long size) {
|
||||
return new BigDecimal(size).divide(new BigDecimal(1024 * 1024)).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue() + "MB";
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换文件大小为友好显示
|
||||
*
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public static String getDisplaySizeGB(long size) {
|
||||
return new BigDecimal(size).divide(new BigDecimal(1024 * 1024 * 1024.0)).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue() + "GB";
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换文件大小为友好显示
|
||||
*
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public static String getDisplaySizeTB(long size) {
|
||||
return new BigDecimal(size).divide(new BigDecimal(1024.0 * 1024 * 1024 * 1024)).setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue() + "TB";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件类型
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static String getType(String path) {
|
||||
String type = "file";
|
||||
String suffix = getSuffix(path);
|
||||
if (eqSuffix(suffix, TYPE_IMAGE))
|
||||
type = "image";
|
||||
else if (eqSuffix(suffix, TYPE_VIDEO))
|
||||
type = "video";
|
||||
else if (eqSuffix(suffix, TYPE_AUDIO))
|
||||
type = "audio";
|
||||
else if (eqSuffix(suffix, TYPE_DOC))
|
||||
type = "doc";
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件后缀名
|
||||
*
|
||||
* @param path 文件绝对路径
|
||||
* @return
|
||||
*/
|
||||
public static String getSuffix(String path) {
|
||||
int idx = path.lastIndexOf(".");
|
||||
if (idx < 0)
|
||||
return "";
|
||||
return path.substring(path.lastIndexOf(".")).toLowerCase();
|
||||
}
|
||||
|
||||
private static boolean eqSuffix(String suffix, String[] types) {
|
||||
for (String type : types) {
|
||||
if (type.equals(suffix))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件后缀名
|
||||
*
|
||||
* @param file 文件
|
||||
* @return
|
||||
*/
|
||||
public static String getSuffix(File file) {
|
||||
return getSuffix(file.getName());
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -40,6 +40,7 @@ public interface GeneratorService {
|
||||
/**
|
||||
* 分页查询表
|
||||
*
|
||||
* @param page 分页信息
|
||||
* @param tableName 表名
|
||||
* @param id 数据源ID
|
||||
* @return
|
||||
|
||||
-16
@@ -24,22 +24,6 @@ public class MsgHandler extends AbstractHandler {
|
||||
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage,
|
||||
Map<String, Object> context, WxMpService weixinService,
|
||||
WxSessionManager sessionManager) {
|
||||
|
||||
if (!wxMessage.getMsgType().equals(XmlMsgType.EVENT)) {
|
||||
//TODO 可以选择将消息保存到本地
|
||||
}
|
||||
|
||||
//当用户输入关键词如“你好”,“客服”等,并且有客服在线时,把消息转发给在线客服
|
||||
if (StringUtils.startsWithAny(wxMessage.getContent(), "你好", "客服")
|
||||
&& weixinService.getKefuService().kfOnlineList()
|
||||
.getKfOnlineList().size() > 0) {
|
||||
return WxMpXmlOutMessage.TRANSFER_CUSTOMER_SERVICE()
|
||||
.fromUser(wxMessage.getToUser())
|
||||
.toUser(wxMessage.getFromUser()).build();
|
||||
}
|
||||
|
||||
|
||||
//TODO 组装回复消息
|
||||
String content = "收到信息内容:" + wxMessage.getContent();
|
||||
|
||||
return new TextBuilder().build(content, wxMessage, weixinService);
|
||||
|
||||
+2
-4
@@ -34,9 +34,7 @@ public class SubscribeHandler extends AbstractHandler {
|
||||
// TODO 可以添加关注用户到本地数据库
|
||||
}
|
||||
} catch (WxErrorException e) {
|
||||
if (e.getError().getErrorCode() == 48001) {
|
||||
log.info("该公众号没有获取用户信息权限!");
|
||||
}
|
||||
log.error("该公众号没有获取用户信息失败!" , e);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +50,7 @@ public class SubscribeHandler extends AbstractHandler {
|
||||
}
|
||||
|
||||
try {
|
||||
return new TextBuilder().build("感谢关注", wxMessage, weixinService);
|
||||
return new TextBuilder().build("感谢关注" , wxMessage, weixinService);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
@@ -32,11 +32,15 @@ public interface PayOrderHandler {
|
||||
*
|
||||
* @param goodsOrder 商品订单
|
||||
* @param tradeOrder 交易订单
|
||||
* @return obj
|
||||
*/
|
||||
Object pay(PayGoodsOrder goodsOrder, PayTradeOrder tradeOrder);
|
||||
|
||||
/**
|
||||
* 更新订单信息
|
||||
*
|
||||
* @param goodsOrder 商品订单
|
||||
* @param tradeOrder 交易订单
|
||||
*/
|
||||
void updateOrder(PayGoodsOrder goodsOrder, PayTradeOrder tradeOrder);
|
||||
|
||||
|
||||
Reference in new issue
Block a user