本文整理汇总了Java中org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity类的典型用法代码示例。如果您正苦于以下问题:Java WxMenuBtnEntity类的具体用法?Java WxMenuBtnEntity怎么用?Java WxMenuBtnEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WxMenuBtnEntity类属于org.hamster.weixinmp.dao.entity.menu包,在下文中一共展示了WxMenuBtnEntity类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recursiveParse
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public JsonObject recursiveParse(WxMenuBtnEntity parentEntity) {
JsonObject parent = new JsonObject();
parent.addProperty("type", parentEntity.getType());
parent.addProperty("name", parentEntity.getName());
WxMenuBtnTypeEnum type = WxMenuBtnTypeEnum.valueOf(parentEntity
.getType());
switch (type) {
case CLICK:
parent.addProperty("key", parentEntity.getKey());
break;
case VIEW:
parent.addProperty("url", parentEntity.getUrl());
break;
default:
break;
}
if (!CollectionUtils.isEmpty(parentEntity.getSubButtons())) {
JsonArray children = new JsonArray();
for (WxMenuBtnEntity child : parentEntity.getSubButtons()) {
children.add(recursiveParse(child));
}
parent.add("sub_button", children);
}
return parent;
}
示例2: menuCreate
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public WxRespCode menuCreate(String accessToken, List<WxMenuBtnEntity> entities)
throws WxException {
Map<String, String> params = getAccessTokenParams(accessToken);
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(WxUserEntity.class,
new WxMenuBtnSerializer());
Gson gson = gsonBuilder.create();
WxMenuCreateJson wrapper = new WxMenuCreateJson(entities);
wrapper.setButton(entities);
try {
return sendRequest(config.getMenuCreateUrl(), HttpMethod.POST, params,
new StringEntity(gson.toJson(wrapper)),
WxRespCode.class);
} catch (UnsupportedEncodingException e) {
throw new WxException(e);
}
}
示例3: menuCreate
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public WxRespCode menuCreate(String accessToken, List<WxMenuBtnEntity> entities)
throws WxException {
Map<String, String> params = getAccessTokenParams(accessToken);
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(WxUserEntity.class,
new WxMenuBtnSerializer());
Gson gson = gsonBuilder.create();
WxMenuCreateJson wrapper = new WxMenuCreateJson();
wrapper.setButton(entities);
try {
return sendRequest(config.getMenuCreateUrl(), HttpMethod.POST, params,
new StringEntity(gson.toJson(wrapper)),
WxRespCode.class);
} catch (UnsupportedEncodingException e) {
throw new WxException(e);
}
}
示例4: serialize
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public JsonElement serialize(WxMenuBtnEntity src, Type typeOfSrc,
JsonSerializationContext context) {
return recursiveParse(src);
}
示例5: toMenuCreateReqBody
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public static final String toMenuCreateReqBody(List<WxMenuBtnEntity> wxMenuBtnList) {
Gson gson = new Gson();
return gson.toJson(new WxMenuCreateJson(wxMenuBtnList));
}
示例6: menuGet
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public List<WxMenuBtnEntity> menuGet(String accessToken) throws WxException {
Map<String, String> params = getAccessTokenParams(accessToken);
return sendRequest(config.getMenuGetUrl(), HttpMethod.GET, params, null,
WxMenuGetJson.class).getMenu().getButton();
}
示例7: toMenuCreateReqBody
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public static final String toMenuCreateReqBody(List<WxMenuBtnEntity> wxMenuBtnList) {
Gson gson = new Gson();
WxMenuCreateJson wxMenuCreateJson = new WxMenuCreateJson();
wxMenuCreateJson.setButton(wxMenuBtnList);
return gson.toJson(wxMenuCreateJson);
}
示例8: getButton
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public List<WxMenuBtnEntity> getButton() {
return button;
}
示例9: setButton
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public void setButton(List<WxMenuBtnEntity> button) {
this.button = button;
}
示例10: WxMenuCreateJson
import org.hamster.weixinmp.dao.entity.menu.WxMenuBtnEntity; //导入依赖的package包/类
public WxMenuCreateJson(List<WxMenuBtnEntity> button) {
super();
this.button = button;
}