mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、sonar代码规范问题修复;2、Aes对称加解密算法替换;
This commit is contained in:
+14
-43
@@ -1,13 +1,12 @@
|
||||
package com.cf.imes.framework.common.util.encrypt;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import java.security.GeneralSecurityException;
|
||||
import javax.crypto.spec.GCMParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Base64;
|
||||
@@ -23,7 +22,7 @@ public class AesUtils {
|
||||
|
||||
private static final String AES_ALG = "AES";
|
||||
|
||||
private static final String AES_CBC_PCK_ALG = "AES/CBC/PKCS5Padding";
|
||||
private static final String DEFAULT_CIPHER_ALGORITHM = "AES/GCM/NoPadding";
|
||||
|
||||
|
||||
/**
|
||||
@@ -34,14 +33,14 @@ public class AesUtils {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String decrypt(String content, String aesKey) {
|
||||
public static String decrypt(String base64Content, String aesKey) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance(AES_CBC_PCK_ALG);
|
||||
IvParameterSpec iv = new IvParameterSpec(initIv(AES_CBC_PCK_ALG));
|
||||
cipher.init(Cipher.DECRYPT_MODE, generateKey(aesKey.getBytes()), iv);
|
||||
|
||||
byte[] cleanBytes = cipher.doFinal(Base64.getDecoder().decode(content.getBytes()));
|
||||
return new String(cleanBytes, CharsetUtil.UTF_8);
|
||||
byte[] content = Base64.getDecoder().decode(base64Content);
|
||||
GCMParameterSpec params = new GCMParameterSpec(128, content, 0, 12);
|
||||
Cipher cipher = Cipher.getInstance(DEFAULT_CIPHER_ALGORITHM);
|
||||
cipher.init(Cipher.DECRYPT_MODE, getSecretKey(aesKey), params);
|
||||
byte[] decryptData = cipher.doFinal(content, 12, content.length - 12);
|
||||
return new String(decryptData);
|
||||
} catch (Exception e) {
|
||||
log.error("[AesUtils][decrypt]解密失败:{}", e.getMessage(), e);
|
||||
// nacos热发布配置,空字符串会导致nacos轮训刷新配置
|
||||
@@ -56,44 +55,16 @@ public class AesUtils {
|
||||
* @return
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static SecretKey generateKey(byte[] bytes) throws NoSuchAlgorithmException {
|
||||
private static SecretKey getSecretKey(String key) throws NoSuchAlgorithmException {
|
||||
// 生成随机数
|
||||
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||
// 设置随机数种子
|
||||
random.setSeed(bytes);
|
||||
random.setSeed(key.getBytes());
|
||||
|
||||
// aes算法生成器
|
||||
KeyGenerator keyGen = KeyGenerator.getInstance(AES_ALG);
|
||||
keyGen.init(128, random); // 使用128位的密钥
|
||||
return keyGen.generateKey();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始向量的方法, 全部为0. 这里的写法适合于其它算法,针对AES算法的话,IV值一定是128位的(16字节).
|
||||
*
|
||||
* @param fullAlg
|
||||
* @return
|
||||
* @throws GeneralSecurityException
|
||||
*/
|
||||
private static byte[] initIv(String fullAlg) {
|
||||
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance(fullAlg);
|
||||
int blockSize = cipher.getBlockSize();
|
||||
byte[] iv = new byte[blockSize];
|
||||
for (int i = 0; i < blockSize; ++i) {
|
||||
iv[i] = 0;
|
||||
}
|
||||
return iv;
|
||||
} catch (Exception e) {
|
||||
|
||||
int blockSize = 16;
|
||||
byte[] iv = new byte[blockSize];
|
||||
for (int i = 0; i < blockSize; ++i) {
|
||||
iv[i] = 0;
|
||||
}
|
||||
return iv;
|
||||
}
|
||||
SecretKey secretKey = keyGen.generateKey();
|
||||
return new SecretKeySpec(secretKey.getEncoded(), AES_ALG);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.common.util.object.ObjectUtils;
|
||||
@@ -98,7 +98,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
|
||||
status = PayOrderStatusRespEnum.REFUND.getStatus();
|
||||
}
|
||||
Assert.notNull(status, (Supplier<Throwable>) () -> {
|
||||
throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", body));
|
||||
throw new IllegalArgumentException(CharSequenceUtil.format("body({}) 的 trade_status 不正确", body));
|
||||
});
|
||||
return PayOrderRespDTO.of(status, bodyObj.get("trade_no"), bodyObj.get("seller_id"), parseTime(params.get("gmt_payment")),
|
||||
bodyObj.get("out_trade_no"), body);
|
||||
@@ -126,7 +126,7 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
|
||||
// 2.2 解析订单的状态
|
||||
Integer status = parseStatus(response.getTradeStatus());
|
||||
Assert.notNull(status, () -> {
|
||||
throw new IllegalArgumentException(StrUtil.format("body({}) 的 trade_status 不正确", response.getBody()));
|
||||
throw new IllegalArgumentException(CharSequenceUtil.format("body({}) 的 trade_status 不正确", response.getBody()));
|
||||
});
|
||||
return PayOrderRespDTO.of(status, response.getTradeNo(), response.getBuyerUserId(), LocalDateTimeUtil.of(response.getSendPayDate()),
|
||||
outTradeNo, response);
|
||||
@@ -248,11 +248,11 @@ public abstract class AbstractAlipayPayClient extends AbstractPayClient<AlipayPa
|
||||
Participant payeeInfo = new Participant();
|
||||
payeeInfo.setIdentityType("ALIPAY_LOGON_ID");
|
||||
String logonId = MapUtil.getStr(reqDTO.getPayeeInfo(), "ALIPAY_LOGON_ID");
|
||||
if (StrUtil.isEmpty(logonId)) {
|
||||
if (CharSequenceUtil.isEmpty(logonId)) {
|
||||
throw exception0(BAD_REQUEST.getCode(), "支付包登录 ID 不能为空");
|
||||
}
|
||||
String accountName = MapUtil.getStr(reqDTO.getPayeeInfo(), "ALIPAY_ACCOUNT_NAME");
|
||||
if (StrUtil.isEmpty(accountName)) {
|
||||
if (CharSequenceUtil.isEmpty(accountName)) {
|
||||
throw exception0(BAD_REQUEST.getCode(), "支付包账户名称不能为空");
|
||||
}
|
||||
payeeInfo.setIdentity(logonId); // 支付宝登录号
|
||||
|
||||
+32
-26
@@ -5,7 +5,7 @@ import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.date.TemporalAccessorUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.cf.imes.framework.common.util.io.FileUtils;
|
||||
import com.cf.imes.framework.common.util.object.ObjectUtils;
|
||||
import com.cf.imes.framework.pay.core.client.dto.order.PayOrderRespDTO;
|
||||
@@ -43,6 +43,12 @@ import static cn.hutool.core.date.DatePattern.*;
|
||||
@Slf4j
|
||||
public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientConfig> {
|
||||
|
||||
private static final String UNKOWN_API_VERSION_NOTIFICATION = "未知的 API 版本(%s)";
|
||||
|
||||
private static final String SUCCESS_CODE = "SUCCESS";
|
||||
|
||||
private static final String PROCESSING_STATUS_CODE = "PROCESSING";
|
||||
|
||||
protected WxPayService client;
|
||||
|
||||
public AbstractWxPayClient(Long channelId, String channelCode, WxPayClientConfig config) {
|
||||
@@ -63,10 +69,10 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
if (Base64.isBase64(config.getKeyContent())) {
|
||||
payConfig.setKeyPath(FileUtils.createTempFile(Base64.decode(config.getKeyContent())).getPath());
|
||||
}
|
||||
if (StrUtil.isNotEmpty(config.getPrivateKeyContent())) {
|
||||
if (CharSequenceUtil.isNotEmpty(config.getPrivateKeyContent())) {
|
||||
payConfig.setPrivateKeyPath(FileUtils.createTempFile(config.getPrivateKeyContent()).getPath());
|
||||
}
|
||||
if (StrUtil.isNotEmpty(config.getPrivateCertContent())) {
|
||||
if (CharSequenceUtil.isNotEmpty(config.getPrivateCertContent())) {
|
||||
payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath());
|
||||
}
|
||||
|
||||
@@ -86,7 +92,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
case WxPayClientConfig.API_VERSION_V3:
|
||||
return doUnifiedOrderV3(reqDTO);
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
throw new IllegalArgumentException(String.format(UNKOWN_API_VERSION_NOTIFICATION, config.getApiVersion()));
|
||||
}
|
||||
} catch (WxPayException e) {
|
||||
String errorCode = getErrorCode(e);
|
||||
@@ -157,7 +163,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
case WxPayClientConfig.API_VERSION_V3:
|
||||
return doParseOrderNotifyV3(body);
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
throw new IllegalArgumentException(String.format(UNKOWN_API_VERSION_NOTIFICATION, config.getApiVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +172,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
WxPayOrderNotifyResult response = client.parseOrderNotifyResult(body);
|
||||
// 2. 构建结果
|
||||
// V2 微信支付的回调,只有 SUCCESS 支付成功、CLOSED 支付失败两种情况,无需像支付宝一样解析的比较复杂
|
||||
Integer status = Objects.equals(response.getResultCode(), "SUCCESS") ?
|
||||
Integer status = Objects.equals(response.getResultCode(), SUCCESS_CODE) ?
|
||||
PayOrderStatusRespEnum.SUCCESS.getStatus() : PayOrderStatusRespEnum.CLOSED.getStatus();
|
||||
return PayOrderRespDTO.of(status, response.getTransactionId(), response.getOpenid(), parseDateV2(response.getTimeEnd()),
|
||||
response.getOutTradeNo(), body);
|
||||
@@ -192,7 +198,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
case WxPayClientConfig.API_VERSION_V3:
|
||||
return doGetOrderV3(outTradeNo);
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
throw new IllegalArgumentException(String.format(UNKOWN_API_VERSION_NOTIFICATION, config.getApiVersion()));
|
||||
}
|
||||
} catch (WxPayException e) {
|
||||
if (ObjectUtils.equalsAny(e.getErrCode(), "ORDERNOTEXIST", "ORDER_NOT_EXIST")) {
|
||||
@@ -237,7 +243,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
case "NOTPAY":
|
||||
case "USERPAYING": // 支付中,等待用户输入密码(条码支付独有)
|
||||
return PayOrderStatusRespEnum.WAITING.getStatus();
|
||||
case "SUCCESS":
|
||||
case SUCCESS_CODE:
|
||||
return PayOrderStatusRespEnum.SUCCESS.getStatus();
|
||||
case "REFUND":
|
||||
return PayOrderStatusRespEnum.REFUND.getStatus();
|
||||
@@ -246,7 +252,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
case "PAYERROR": // 支付失败(其它原因,如银行返回失败)
|
||||
return PayOrderStatusRespEnum.CLOSED.getStatus();
|
||||
default:
|
||||
throw new IllegalArgumentException(StrUtil.format("未知的支付状态({})", tradeState));
|
||||
throw new IllegalArgumentException(CharSequenceUtil.format("未知的支付状态({})", tradeState));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +267,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
case WxPayClientConfig.API_VERSION_V3:
|
||||
return doUnifiedRefundV3(reqDTO);
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
throw new IllegalArgumentException(String.format(UNKOWN_API_VERSION_NOTIFICATION, config.getApiVersion()));
|
||||
}
|
||||
} catch (WxPayException e) {
|
||||
String errorCode = getErrorCode(e);
|
||||
@@ -283,7 +289,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
// 2.1 执行请求
|
||||
WxPayRefundResult response = client.refundV2(request);
|
||||
// 2.2 创建返回结果
|
||||
if (Objects.equals("SUCCESS", response.getResultCode())) { // V2 情况下,不直接返回退款成功,而是等待异步通知
|
||||
if (Objects.equals(SUCCESS_CODE, response.getResultCode())) { // V2 情况下,不直接返回退款成功,而是等待异步通知
|
||||
return PayRefundRespDTO.waitingOf(response.getRefundId(),
|
||||
reqDTO.getOutRefundNo(), response);
|
||||
}
|
||||
@@ -302,11 +308,11 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
// 2.1 执行请求
|
||||
WxPayRefundV3Result response = client.refundV3(request);
|
||||
// 2.2 创建返回结果
|
||||
if (Objects.equals("SUCCESS", response.getStatus())) {
|
||||
if (Objects.equals(SUCCESS_CODE, response.getStatus())) {
|
||||
return PayRefundRespDTO.successOf(response.getRefundId(), parseDateV3(response.getSuccessTime()),
|
||||
reqDTO.getOutRefundNo(), response);
|
||||
}
|
||||
if (Objects.equals("PROCESSING", response.getStatus())) {
|
||||
if (Objects.equals(PROCESSING_STATUS_CODE, response.getStatus())) {
|
||||
return PayRefundRespDTO.waitingOf(response.getRefundId(),
|
||||
reqDTO.getOutRefundNo(), response);
|
||||
}
|
||||
@@ -321,7 +327,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
case WxPayClientConfig.API_VERSION_V3:
|
||||
return parseRefundNotifyV3(body);
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
throw new IllegalArgumentException(String.format(UNKOWN_API_VERSION_NOTIFICATION, config.getApiVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +336,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
WxPayRefundNotifyResult response = client.parseRefundNotifyResult(body);
|
||||
WxPayRefundNotifyResult.ReqInfo result = response.getReqInfo();
|
||||
// 2. 构建结果
|
||||
if (Objects.equals("SUCCESS", result.getRefundStatus())) {
|
||||
if (Objects.equals(SUCCESS_CODE, result.getRefundStatus())) {
|
||||
return PayRefundRespDTO.successOf(result.getRefundId(), parseDateV2B(result.getSuccessTime()),
|
||||
result.getOutRefundNo(), response);
|
||||
}
|
||||
@@ -342,7 +348,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
WxPayRefundNotifyV3Result response = client.parseRefundNotifyV3Result(body, null);
|
||||
WxPayRefundNotifyV3Result.DecryptNotifyResult result = response.getResult();
|
||||
// 2. 构建结果
|
||||
if (Objects.equals("SUCCESS", result.getRefundStatus())) {
|
||||
if (Objects.equals(SUCCESS_CODE, result.getRefundStatus())) {
|
||||
return PayRefundRespDTO.successOf(result.getRefundId(), parseDateV3(result.getSuccessTime()),
|
||||
result.getOutRefundNo(), response);
|
||||
}
|
||||
@@ -358,7 +364,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
case WxPayClientConfig.API_VERSION_V3:
|
||||
return doGetRefundV3(outTradeNo, outRefundNo);
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("未知的 API 版本(%s)", config.getApiVersion()));
|
||||
throw new IllegalArgumentException(String.format(UNKOWN_API_VERSION_NOTIFICATION, config.getApiVersion()));
|
||||
}
|
||||
} catch (WxPayException e) {
|
||||
if (ObjectUtils.equalsAny(e.getErrCode(), "REFUNDNOTEXIST", "RESOURCE_NOT_EXISTS")) {
|
||||
@@ -380,7 +386,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
// 2.1 执行请求
|
||||
WxPayRefundQueryResult response = client.refundQuery(request);
|
||||
// 2.2 创建返回结果
|
||||
if (!Objects.equals("SUCCESS", response.getResultCode())) {
|
||||
if (!Objects.equals(SUCCESS_CODE, response.getResultCode())) {
|
||||
return PayRefundRespDTO.waitingOf(null,
|
||||
outRefundNo, response);
|
||||
}
|
||||
@@ -390,10 +396,10 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
return PayRefundRespDTO.failureOf(outRefundNo, response);
|
||||
}
|
||||
switch (refund.getRefundStatus()) {
|
||||
case "SUCCESS":
|
||||
case SUCCESS_CODE:
|
||||
return PayRefundRespDTO.successOf(refund.getRefundId(), parseDateV2B(refund.getRefundSuccessTime()),
|
||||
outRefundNo, response);
|
||||
case "PROCESSING":
|
||||
case PROCESSING_STATUS_CODE:
|
||||
return PayRefundRespDTO.waitingOf(refund.getRefundId(),
|
||||
outRefundNo, response);
|
||||
case "CHANGE": // 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,资金回流到商户的现金帐号,需要商户人工干预,通过线下或者财付通转账的方式进行退款
|
||||
@@ -412,10 +418,10 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
WxPayRefundQueryV3Result response = client.refundQueryV3(request);
|
||||
// 2.2 创建返回结果
|
||||
switch (response.getStatus()) {
|
||||
case "SUCCESS":
|
||||
case SUCCESS_CODE:
|
||||
return PayRefundRespDTO.successOf(response.getRefundId(), parseDateV3(response.getSuccessTime()),
|
||||
outRefundNo, response);
|
||||
case "PROCESSING":
|
||||
case PROCESSING_STATUS_CODE:
|
||||
return PayRefundRespDTO.waitingOf(response.getRefundId(),
|
||||
outRefundNo, response);
|
||||
case "ABNORMAL": // 退款异常
|
||||
@@ -453,20 +459,20 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
}
|
||||
|
||||
static String getErrorCode(WxPayException e) {
|
||||
if (StrUtil.isNotEmpty(e.getErrCode())) {
|
||||
if (CharSequenceUtil.isNotEmpty(e.getErrCode())) {
|
||||
return e.getErrCode();
|
||||
}
|
||||
if (StrUtil.isNotEmpty(e.getCustomErrorMsg())) {
|
||||
if (CharSequenceUtil.isNotEmpty(e.getCustomErrorMsg())) {
|
||||
return "CUSTOM_ERROR";
|
||||
}
|
||||
return e.getReturnCode();
|
||||
}
|
||||
|
||||
static String getErrorMessage(WxPayException e) {
|
||||
if (StrUtil.isNotEmpty(e.getErrCode())) {
|
||||
if (CharSequenceUtil.isNotEmpty(e.getErrCode())) {
|
||||
return e.getErrCodeDes();
|
||||
}
|
||||
if (StrUtil.isNotEmpty(e.getCustomErrorMsg())) {
|
||||
if (CharSequenceUtil.isNotEmpty(e.getCustomErrorMsg())) {
|
||||
return e.getCustomErrorMsg();
|
||||
}
|
||||
return e.getReturnMsg();
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.cf.imes.framework.file.core.client;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
|
||||
* @return URL 访问地址
|
||||
*/
|
||||
protected String formatFileUrl(String domain, String path) {
|
||||
return StrUtil.format("{}/admin-api/infra/file/{}/get/{}", domain, getId(), path);
|
||||
return CharSequenceUtil.format("{}/admin-api/infra/file/{}/get/{}", domain, getId(), path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.framework.websocket.core.sender;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.websocket.core.message.JsonWebSocketMessage;
|
||||
import com.cf.imes.framework.websocket.core.session.WebSocketSessionManager;
|
||||
@@ -53,7 +53,7 @@ public abstract class AbstractWebSocketMessageSender implements WebSocketMessage
|
||||
public void send(String sessionId, Integer userType, Long userId, String messageType, String messageContent) {
|
||||
// 1. 获得 Session 列表
|
||||
List<WebSocketSession> sessions = Collections.emptyList();
|
||||
if (StrUtil.isNotEmpty(sessionId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(sessionId)) {
|
||||
WebSocketSession session = sessionManager.getSession(sessionId);
|
||||
if (session != null) {
|
||||
sessions = Collections.singletonList(session);
|
||||
|
||||
Reference in New Issue
Block a user