对返回结果中以$n结尾的节点的序列化做了优化

This commit is contained in:
jinyu
2015-06-15 09:07:35 +08:00
parent 5ffc7f2a98
commit 692a2b8129
11 changed files with 137 additions and 223 deletions
@@ -443,7 +443,7 @@ public class Pay2Api extends PayApi {
map.put("sign", sign.toLowerCase());
WeixinResponse response = weixinClient.get(refundquery_uri, map);
return ListsuffixResultDeserializer.deserialize(response.getAsString(),
RefundRecord.class, "refundList");
RefundRecord.class);
}
@Override
@@ -81,7 +81,7 @@ public class Pay3Api extends PayApi {
String orderquery_uri = getRequestUri("orderquery_v3_uri");
WeixinResponse response = weixinClient.post(orderquery_uri, param);
return ListsuffixResultDeserializer.deserialize(response.getAsString(),
Order.class, "couponList");
Order.class);
}
/**
@@ -394,9 +394,8 @@ public class Pay3Api extends PayApi {
map.put("sign", sign);
String param = XmlStream.map2xml(map);
WeixinResponse response = weixinClient.post(refundquery_uri, param);
return ListsuffixResultDeserializer.deserializeHasTwoSuffix(
response.getAsString(), RefundRecord.class, "refundList",
"couponList");
return ListsuffixResultDeserializer.deserialize(
response.getAsString(), RefundRecord.class);
}
/**
@@ -6,7 +6,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.xml.ListsuffixResult;
@@ -48,8 +47,6 @@ public class RefundRecord extends ApiResult {
* 退款详情
*/
@ListsuffixResult
@XmlTransient
@JSONField(deserialize = false)
private List<RefundDetail> refundList;
protected RefundRecord() {
@@ -7,7 +7,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.mp.payment.coupon.CouponInfo;
@@ -88,8 +87,6 @@ public class Order extends ApiResult {
* 代金券信息 验证签名有点麻烦
*/
@ListsuffixResult
@XmlTransient
@JSONField(deserialize = false)
private List<CouponInfo> couponList;
/**
* 现金支付金额
@@ -6,7 +6,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.mp.payment.coupon.CouponInfo;
@@ -131,8 +130,6 @@ public class RefundDetail extends ApiResult {
* @see com.foxinmy.weixin4j.mp.payment.coupon.CouponInfo
*/
@ListsuffixResult
@XmlTransient
@JSONField(deserialize = false)
private List<CouponInfo> couponList;
protected RefundDetail() {
@@ -6,7 +6,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.mp.type.CurrencyType;
@@ -89,9 +88,7 @@ public class RefundRecord extends ApiResult {
*
* @see com.foxinmy.weixin4j.mp.payment.v3.RefundDetail
*/
@ListsuffixResult
@XmlTransient
@JSONField(deserialize = false)
@ListsuffixResult({ "out_refund_no(_\\d)$", "^refund_.*(_\\d)$" })
private List<RefundDetail> refundList;
protected RefundRecord() {
@@ -6,11 +6,9 @@ import java.util.HashMap;
import java.util.Map;
import com.foxinmy.weixin4j.model.Token;
import com.foxinmy.weixin4j.mp.payment.PayUtil;
import com.foxinmy.weixin4j.mp.payment.v2.RefundRecord;
import com.foxinmy.weixin4j.mp.payment.v3.Order;
import com.foxinmy.weixin4j.xml.ListsuffixResultDeserializer;
import com.foxinmy.weixin4j.xml.ListsuffixResultSerializer;
import com.foxinmy.weixin4j.xml.XmlStream;
public class XmlstreamTest {
@@ -63,7 +61,7 @@ public class XmlstreamTest {
}
System.err.println(ListsuffixResultDeserializer.deserialize(
sb.toString(), Order.class, "couponList"));
sb.toString(), Order.class));
}
public static RefundRecord xml2refundRecordV2() throws Exception {
@@ -80,7 +78,7 @@ public class XmlstreamTest {
}
return ListsuffixResultDeserializer.deserialize(sb.toString(),
RefundRecord.class, "refundList");
RefundRecord.class);
}
public static void xml2refundRecordV3() throws Exception {
@@ -96,26 +94,27 @@ public class XmlstreamTest {
} catch (Exception e) {
}
System.err.println(ListsuffixResultDeserializer
.deserializeHasTwoSuffix(sb.toString(),
com.foxinmy.weixin4j.mp.payment.v3.RefundRecord.class,
"refundList", "couponList"));
System.err.println(ListsuffixResultDeserializer.deserialize(
sb.toString(),
com.foxinmy.weixin4j.mp.payment.v3.RefundRecord.class));
}
public static void main(String[] args) throws Exception {
// map2xml();
// xml2map();
// xml2order();
// xml2refundRecordV2();
// System.err.println(xml2refundRecordV2());
xml2refundRecordV3();
// object2xmlWithoutRootElement();
RefundRecord refundRecord = xml2refundRecordV2();
/*RefundRecord refundRecord = xml2refundRecordV2();
System.err.println(refundRecord);
String sign = refundRecord.getSign();
refundRecord.setSign(null);
String validSign = PayUtil.paysignMd5(refundRecord, "paysignkey");
System.err.println("sign=" + sign + ",validSign=" + validSign);
System.err.println(ListsuffixResultSerializer
.serializeToXML(refundRecord));
.serializeToXML(refundRecord));*/
}
}