diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveService.java index a90f4756b..3b0ccc390 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveService.java @@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.bean.live.*; import me.chanjar.weixin.common.error.WxErrorException; import java.util.List; +import java.util.Map; /** *
@@ -207,4 +208,190 @@ public interface WxMaLiveService {
* @throws WxErrorException .
*/
List getAssistantList(Integer roomId) throws WxErrorException;
+
+ /**
+ * 添加主播副号
+ *
+ * 调用接口添加主播副号
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/addsubanchor?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param username 用户微信号
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean addSubanchor(Integer roomId, String username) throws WxErrorException;
+
+ /**
+ * 修改主播副号
+ *
+ * 调用接口修改主播副号
+ *
+ * 调用频率: 10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/modifyassistant?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param username 小助手微信号
+ * @param username 用户微信号
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean modifySubanchor(Integer roomId, String username) throws WxErrorException;
+
+ /**
+ * 删除主播副号
+ *
+ * 调用频率: 10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/deletesubanchor?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean deleteSubanchor(Integer roomId) throws WxErrorException;
+
+ /**
+ * 获取主播副号
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:GET https://api.weixin.qq.com/wxaapi/broadcast/room/getsubanchor?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 直播间id
+ * @return .
+ * @throws WxErrorException .
+ */
+ String getSubanchor(Integer roomId) throws WxErrorException;
+
+ /**
+ * 开启/关闭直播间官方收录
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatefeedpublic?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param isFeedsPublic 是否开启官方收录 【1: 开启,0:关闭】
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean updatefeedpublic(Integer roomId, Integer isFeedsPublic) throws WxErrorException;
+
+ /**
+ * 开启/关闭回放功能
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatereplay?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param closeReplay 是否关闭回放 【0:开启,1:关闭】
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean updatereplay(Integer roomId, Integer closeReplay) throws WxErrorException;
+
+ /**
+ * 开启/关闭客服功能
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatekf?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param closeKf 是否关闭客服 【0:开启,1:关闭】
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean updatekf(Integer roomId, Integer closeKf) throws WxErrorException;
+
+ /**
+ * 开启/关闭直播间全局禁言
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/room/updatecomment?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param banComment 1-禁言,0-取消禁言
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean updatecomment(Integer roomId, Integer banComment) throws WxErrorException;
+
+ /**
+ * 上下架商品
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/onsale?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param goodsId 商品ID
+ * @param onSale 上下架 【0:下架,1:上架】
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean onsale(Integer roomId, Integer goodsId, Integer onSale) throws WxErrorException;
+
+ /**
+ * 删除直播间商品
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param goodsId 商品ID
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean deleteInRoom(Integer roomId, Integer goodsId) throws WxErrorException;
+
+ /**
+ * 推送商品
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/push?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param goodsId 商品ID
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean push(Integer roomId, Integer goodsId) throws WxErrorException;
+
+ /**
+ * 直播间商品排序
+ *
+ * 调用额度:10000次/一天
+ *
+ * http请求方式:POST https://api.weixin.qq.com/wxaapi/broadcast/goods/sort?access_token=ACCESS_TOKEN
+ *
+ * @param roomId 房间ID
+ * @param goods 商品ID列表, 例如: [{"goodsId":"123"}, {"goodsId":"234"}]
+ * @return 是否成功
+ * @throws WxErrorException .
+ */
+ boolean sort(Integer roomId, List
+ * @param roomId 直播间id
+ * @param goodsId 商品ID
+ * @return .
+ * @throws WxErrorException .
+ */
+ String getVideo(Integer roomId, Integer goodsId) throws WxErrorException;
}
diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java
index b71e58653..abda4faa6 100644
--- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java
+++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java
@@ -18,7 +18,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.GET_LIVE_INFO;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Room;
/**
@@ -152,7 +151,7 @@ public class WxMaLiveServiceImpl implements WxMaLiveService {
}
map.put("start", start);
map.put("limit", limit);
- String responseContent = wxMaService.post(GET_LIVE_INFO, WxMaGsonBuilder.create().toJson(map));
+ String responseContent = wxMaService.post(Room.GET_LIVE_INFO, WxMaGsonBuilder.create().toJson(map));
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
@@ -231,4 +230,172 @@ public class WxMaLiveServiceImpl implements WxMaLiveService {
return WxMaAssistantResult.fromJson(responseContent).getList();
}
+ @Override
+ public boolean addSubanchor(Integer roomId, String username) throws WxErrorException {
+ Map map = new HashMap<>(2);
+ map.put(ROOM_ID, roomId);
+ map.put("username", username);
+ String responseContent = this.wxMaService.post(Room.ADD_SUBANCHOR, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public boolean modifySubanchor(Integer roomId, String username) throws WxErrorException {
+ Map map = new HashMap<>(2);
+ map.put(ROOM_ID, roomId);
+ map.put("username", username);
+ String responseContent = this.wxMaService.post(Room.MODIFY_SUBANCHOR, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public boolean deleteSubanchor(Integer roomId) throws WxErrorException {
+ Map map = new HashMap<>(1);
+ map.put(ROOM_ID, roomId);
+ String responseContent = this.wxMaService.post(Room.DELETE_SUBANCHOR, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public String getSubanchor(Integer roomId) throws WxErrorException {
+ Map map = new HashMap<>(1);
+ map.put(ROOM_ID, roomId);
+ String responseContent = this.wxMaService.get(Room.GET_SUBANCHOR, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return jsonObject.get("username").getAsString();
+ }
+
+ @Override
+ public boolean updatefeedpublic(Integer roomId, Integer isFeedsPublic) throws WxErrorException {
+ Map map = new HashMap<>(2);
+ map.put(ROOM_ID, roomId);
+ map.put("isFeedsPublic", isFeedsPublic);
+ String responseContent = this.wxMaService.post(Room.UPDATE_FEED_PUBLIC, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updatereplay(Integer roomId, Integer closeReplay) throws WxErrorException {
+ Map map = new HashMap<>(2);
+ map.put(ROOM_ID, roomId);
+ map.put("closeReplay", closeReplay);
+ String responseContent = this.wxMaService.post(Room.UPDATE_REPLAY, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updatekf(Integer roomId, Integer closeKf) throws WxErrorException {
+ Map map = new HashMap<>(2);
+ map.put(ROOM_ID, roomId);
+ map.put("closeKf", closeKf);
+ String responseContent = this.wxMaService.post(Room.UPDATE_KF, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updatecomment(Integer roomId, Integer banComment) throws WxErrorException {
+ Map map = new HashMap<>(2);
+ map.put(ROOM_ID, roomId);
+ map.put("banComment", banComment);
+ String responseContent = this.wxMaService.post(Room.UPDATE_COMMENT, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public boolean onsale(Integer roomId, Integer goodsId, Integer onSale) throws WxErrorException {
+ Map map = new HashMap<>(3);
+ map.put(ROOM_ID, roomId);
+ map.put("goodsId", goodsId);
+ map.put("onSale", onSale);
+ String responseContent = this.wxMaService.post(Room.ONSALE, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public boolean deleteInRoom(Integer roomId, Integer goodsId) throws WxErrorException {
+ Map map = new HashMap<>(2);
+ map.put(ROOM_ID, roomId);
+ map.put("goodsId", goodsId);
+ String responseContent = this.wxMaService.post(Room.DELETE_IN_ROOM, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public boolean push(Integer roomId, Integer goodsId) throws WxErrorException {
+ Map map = new HashMap<>(2);
+ map.put(ROOM_ID, roomId);
+ map.put("goodsId", goodsId);
+ String responseContent = this.wxMaService.post(Room.PUSH, WxMaGsonBuilder.create().toJson(map));
+ JsonObject jsonObject = GsonParser.parse(responseContent);
+ if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
+ throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
+ }
+ return true;
+ }
+
+ @Override
+ public boolean sort(Integer roomId, List