fixed menu create null type bug
This commit is contained in:
parent
df9ef56bad
commit
e1beceb5aa
@ -18,6 +18,7 @@ import com.foxinmy.weixin4j.mp.model.Menu;
|
|||||||
import com.foxinmy.weixin4j.mp.model.MenuMatchRule;
|
import com.foxinmy.weixin4j.mp.model.MenuMatchRule;
|
||||||
import com.foxinmy.weixin4j.token.TokenManager;
|
import com.foxinmy.weixin4j.token.TokenManager;
|
||||||
import com.foxinmy.weixin4j.type.ButtonType;
|
import com.foxinmy.weixin4j.type.ButtonType;
|
||||||
|
import com.foxinmy.weixin4j.util.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单相关API
|
* 菜单相关API
|
||||||
@ -59,9 +60,9 @@ public class MenuApi extends MpApi {
|
|||||||
JSON.toJSONString(data, new NameFilter() {
|
JSON.toJSONString(data, new NameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public String process(Object object, String name, Object value) {
|
public String process(Object object, String name, Object value) {
|
||||||
if (object instanceof Button && name.equals("content")) {
|
if (object instanceof Button && name.equals("content")
|
||||||
|
&& StringUtil.isNotBlank(((Button) object).getType())) {
|
||||||
ButtonType buttonType = ButtonType.valueOf(((Button) object).getType());
|
ButtonType buttonType = ButtonType.valueOf(((Button) object).getType());
|
||||||
if (buttonType != null) {
|
|
||||||
if (ButtonType.view == buttonType || ButtonType.miniprogram == buttonType) {
|
if (ButtonType.view == buttonType || ButtonType.miniprogram == buttonType) {
|
||||||
return "url";
|
return "url";
|
||||||
} else if (ButtonType.media_id == buttonType || ButtonType.view_limited == buttonType) {
|
} else if (ButtonType.media_id == buttonType || ButtonType.view_limited == buttonType) {
|
||||||
@ -70,7 +71,6 @@ public class MenuApi extends MpApi {
|
|||||||
return "key";
|
return "key";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import com.foxinmy.weixin4j.model.Button;
|
|||||||
import com.foxinmy.weixin4j.model.Token;
|
import com.foxinmy.weixin4j.model.Token;
|
||||||
import com.foxinmy.weixin4j.token.TokenManager;
|
import com.foxinmy.weixin4j.token.TokenManager;
|
||||||
import com.foxinmy.weixin4j.type.ButtonType;
|
import com.foxinmy.weixin4j.type.ButtonType;
|
||||||
|
import com.foxinmy.weixin4j.util.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 菜单相关API
|
* 菜单相关API
|
||||||
@ -57,9 +58,9 @@ public class MenuApi extends QyApi {
|
|||||||
JSON.toJSONString(obj, new NameFilter() {
|
JSON.toJSONString(obj, new NameFilter() {
|
||||||
@Override
|
@Override
|
||||||
public String process(Object object, String name, Object value) {
|
public String process(Object object, String name, Object value) {
|
||||||
if (object instanceof Button && name.equals("content")) {
|
if (object instanceof Button && name.equals("content")
|
||||||
|
&& StringUtil.isNotBlank(((Button) object).getType())) {
|
||||||
ButtonType buttonType = ButtonType.valueOf(((Button) object).getType());
|
ButtonType buttonType = ButtonType.valueOf(((Button) object).getType());
|
||||||
if (buttonType != null) {
|
|
||||||
if (ButtonType.view == buttonType) {
|
if (ButtonType.view == buttonType) {
|
||||||
return "url";
|
return "url";
|
||||||
} else if (ButtonType.media_id == buttonType || ButtonType.view_limited == buttonType) {
|
} else if (ButtonType.media_id == buttonType || ButtonType.view_limited == buttonType) {
|
||||||
@ -68,7 +69,6 @@ public class MenuApi extends QyApi {
|
|||||||
return "key";
|
return "key";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user