com.gitlab.summercattle.addons.wechat.officialaccounts.menu.MenuBar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cattle-addons-wechat-starter Show documentation
Show all versions of cattle-addons-wechat-starter Show documentation
Cattle Framework Addons WeChat Component
The newest version!
/*
* Copyright (C) 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gitlab.summercattle.addons.wechat.officialaccounts.menu;
import java.io.Serializable;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.gitlab.summercattle.commons.exception.CommonException;
/**
* 公众号菜单
* @author orange
*
*/
public class MenuBar implements Serializable {
private static final long serialVersionUID = 1L;
private AbstractButton leftButton;
private AbstractButton middenButton;
private AbstractButton rightButton;
public MenuBar(AbstractButton leftButton, AbstractButton middenButton, AbstractButton rightButton) {
this.leftButton = leftButton;
this.middenButton = middenButton;
this.rightButton = rightButton;
}
public JSONObject toJson() throws CommonException {
if (null == leftButton && null == middenButton && null == rightButton) {
throw new CommonException("一级菜单为空");
}
JSONArray buttons = new JSONArray();
if (null != leftButton) {
buttons.add(leftButton.toJson());
}
if (null != middenButton) {
buttons.add(middenButton.toJson());
}
if (null != rightButton) {
buttons.add(rightButton.toJson());
}
JSONObject jsonObj = new JSONObject();
jsonObj.put("button", buttons);
return jsonObj;
}
public AbstractButton getLeftButton() {
return leftButton;
}
public AbstractButton getMiddenButton() {
return middenButton;
}
public AbstractButton getRightButton() {
return rightButton;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy