mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🎨 优化重构微信小程序订阅消息相关类
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package cn.binarywang.wx.miniapp.util.json;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeData;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
@@ -9,8 +8,12 @@ import com.google.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* .
|
||||
*
|
||||
* @author S
|
||||
*/
|
||||
public class WxMaSubscribeMessageGsonAdapter implements JsonSerializer<WxMaSubscribeMessage> {
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(WxMaSubscribeMessage message, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject messageJson = new JsonObject();
|
||||
@@ -20,7 +23,6 @@ public class WxMaSubscribeMessageGsonAdapter implements JsonSerializer<WxMaSubsc
|
||||
messageJson.addProperty("page", message.getPage());
|
||||
}
|
||||
|
||||
|
||||
JsonObject data = new JsonObject();
|
||||
messageJson.add("data", data);
|
||||
|
||||
@@ -28,7 +30,7 @@ public class WxMaSubscribeMessageGsonAdapter implements JsonSerializer<WxMaSubsc
|
||||
return messageJson;
|
||||
}
|
||||
|
||||
for (WxMaSubscribeData datum : message.getData()) {
|
||||
for (WxMaSubscribeMessage.Data datum : message.getData()) {
|
||||
JsonObject dataJson = new JsonObject();
|
||||
dataJson.addProperty("value", datum.getValue());
|
||||
data.add(datum.getName(), dataJson);
|
||||
|
||||
Reference in New Issue
Block a user