mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-04 04:37:46 +08:00
🎨 优化代码,把签名工具类里面的常量提取出来
This commit is contained in:
parent
d43876a6a4
commit
010464e399
@ -1,18 +1,5 @@
|
|||||||
package com.github.binarywang.wxpay.util;
|
package com.github.binarywang.wxpay.util;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.SortedMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
|
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
|
||||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
|
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
|
||||||
import com.github.binarywang.wxpay.constant.WxPayConstants.SignType;
|
import com.github.binarywang.wxpay.constant.WxPayConstants.SignType;
|
||||||
@ -20,6 +7,13 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
@ -31,6 +25,12 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SignUtils {
|
public class SignUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签名的时候不携带的参数
|
||||||
|
*/
|
||||||
|
private static List<String> NO_SIGN_PARAMS = Lists.newArrayList("sign", "key", "xmlString", "xmlDoc", "couponList");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请参考并使用 {@link #createSign(Object, String, String, String[])}.
|
* 请参考并使用 {@link #createSign(Object, String, String, String[])}.
|
||||||
*
|
*
|
||||||
@ -85,7 +85,7 @@ public class SignUtils {
|
|||||||
String value = params.get(key);
|
String value = params.get(key);
|
||||||
boolean shouldSign = false;
|
boolean shouldSign = false;
|
||||||
if (StringUtils.isNotEmpty(value) && !ArrayUtils.contains(ignoredParams, key)
|
if (StringUtils.isNotEmpty(value) && !ArrayUtils.contains(ignoredParams, key)
|
||||||
&& !Lists.newArrayList("sign", "key", "xmlString", "xmlDoc", "couponList").contains(key)) {
|
&& !NO_SIGN_PARAMS.contains(key)) {
|
||||||
shouldSign = true;
|
shouldSign = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user