|
18 | 18 | import java.util.List;
|
19 | 19 | import java.util.Map;
|
20 | 20 |
|
21 |
| -import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.GET_LIVE_INFO; |
22 | 21 | import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Room;
|
23 | 22 |
|
24 | 23 | /**
|
@@ -152,7 +151,7 @@ private JsonObject getLiveInfo(Integer start, Integer limit, Map<String, Object>
|
152 | 151 | }
|
153 | 152 | map.put("start", start);
|
154 | 153 | map.put("limit", limit);
|
155 |
| - String responseContent = wxMaService.post(GET_LIVE_INFO, WxMaGsonBuilder.create().toJson(map)); |
| 154 | + String responseContent = wxMaService.post(Room.GET_LIVE_INFO, WxMaGsonBuilder.create().toJson(map)); |
156 | 155 | JsonObject jsonObject = GsonParser.parse(responseContent);
|
157 | 156 | if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
|
158 | 157 | throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
|
@@ -231,4 +230,172 @@ public List<WxMaAssistantResult.Assistant> getAssistantList(Integer roomId) thro
|
231 | 230 | return WxMaAssistantResult.fromJson(responseContent).getList();
|
232 | 231 | }
|
233 | 232 |
|
| 233 | + @Override |
| 234 | + public boolean addSubanchor(Integer roomId, String username) throws WxErrorException { |
| 235 | + Map<String, Object> map = new HashMap<>(2); |
| 236 | + map.put(ROOM_ID, roomId); |
| 237 | + map.put("username", username); |
| 238 | + String responseContent = this.wxMaService.post(Room.ADD_SUBANCHOR, WxMaGsonBuilder.create().toJson(map)); |
| 239 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 240 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 241 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 242 | + } |
| 243 | + return true; |
| 244 | + } |
| 245 | + |
| 246 | + @Override |
| 247 | + public boolean modifySubanchor(Integer roomId, String username) throws WxErrorException { |
| 248 | + Map<String, Object> map = new HashMap<>(2); |
| 249 | + map.put(ROOM_ID, roomId); |
| 250 | + map.put("username", username); |
| 251 | + String responseContent = this.wxMaService.post(Room.MODIFY_SUBANCHOR, WxMaGsonBuilder.create().toJson(map)); |
| 252 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 253 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 254 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 255 | + } |
| 256 | + return true; |
| 257 | + } |
| 258 | + |
| 259 | + @Override |
| 260 | + public boolean deleteSubanchor(Integer roomId) throws WxErrorException { |
| 261 | + Map<String, Object> map = new HashMap<>(1); |
| 262 | + map.put(ROOM_ID, roomId); |
| 263 | + String responseContent = this.wxMaService.post(Room.DELETE_SUBANCHOR, WxMaGsonBuilder.create().toJson(map)); |
| 264 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 265 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 266 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 267 | + } |
| 268 | + return true; |
| 269 | + } |
| 270 | + |
| 271 | + @Override |
| 272 | + public String getSubanchor(Integer roomId) throws WxErrorException { |
| 273 | + Map<String, Object> map = new HashMap<>(1); |
| 274 | + map.put(ROOM_ID, roomId); |
| 275 | + String responseContent = this.wxMaService.get(Room.GET_SUBANCHOR, WxMaGsonBuilder.create().toJson(map)); |
| 276 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 277 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 278 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 279 | + } |
| 280 | + return jsonObject.get("username").getAsString(); |
| 281 | + } |
| 282 | + |
| 283 | + @Override |
| 284 | + public boolean updatefeedpublic(Integer roomId, Integer isFeedsPublic) throws WxErrorException { |
| 285 | + Map<String, Object> map = new HashMap<>(2); |
| 286 | + map.put(ROOM_ID, roomId); |
| 287 | + map.put("isFeedsPublic", isFeedsPublic); |
| 288 | + String responseContent = this.wxMaService.post(Room.UPDATE_FEED_PUBLIC, WxMaGsonBuilder.create().toJson(map)); |
| 289 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 290 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 291 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 292 | + } |
| 293 | + return true; |
| 294 | + } |
| 295 | + |
| 296 | + @Override |
| 297 | + public boolean updatereplay(Integer roomId, Integer closeReplay) throws WxErrorException { |
| 298 | + Map<String, Object> map = new HashMap<>(2); |
| 299 | + map.put(ROOM_ID, roomId); |
| 300 | + map.put("closeReplay", closeReplay); |
| 301 | + String responseContent = this.wxMaService.post(Room.UPDATE_REPLAY, WxMaGsonBuilder.create().toJson(map)); |
| 302 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 303 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 304 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 305 | + } |
| 306 | + return true; |
| 307 | + } |
| 308 | + |
| 309 | + @Override |
| 310 | + public boolean updatekf(Integer roomId, Integer closeKf) throws WxErrorException { |
| 311 | + Map<String, Object> map = new HashMap<>(2); |
| 312 | + map.put(ROOM_ID, roomId); |
| 313 | + map.put("closeKf", closeKf); |
| 314 | + String responseContent = this.wxMaService.post(Room.UPDATE_KF, WxMaGsonBuilder.create().toJson(map)); |
| 315 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 316 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 317 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 318 | + } |
| 319 | + return true; |
| 320 | + } |
| 321 | + |
| 322 | + @Override |
| 323 | + public boolean updatecomment(Integer roomId, Integer banComment) throws WxErrorException { |
| 324 | + Map<String, Object> map = new HashMap<>(2); |
| 325 | + map.put(ROOM_ID, roomId); |
| 326 | + map.put("banComment", banComment); |
| 327 | + String responseContent = this.wxMaService.post(Room.UPDATE_COMMENT, WxMaGsonBuilder.create().toJson(map)); |
| 328 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 329 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 330 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 331 | + } |
| 332 | + return true; |
| 333 | + } |
| 334 | + |
| 335 | + @Override |
| 336 | + public boolean onsale(Integer roomId, Integer goodsId, Integer onSale) throws WxErrorException { |
| 337 | + Map<String, Object> map = new HashMap<>(3); |
| 338 | + map.put(ROOM_ID, roomId); |
| 339 | + map.put("goodsId", goodsId); |
| 340 | + map.put("onSale", onSale); |
| 341 | + String responseContent = this.wxMaService.post(Room.ONSALE, WxMaGsonBuilder.create().toJson(map)); |
| 342 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 343 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 344 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 345 | + } |
| 346 | + return true; |
| 347 | + } |
| 348 | + |
| 349 | + @Override |
| 350 | + public boolean deleteInRoom(Integer roomId, Integer goodsId) throws WxErrorException { |
| 351 | + Map<String, Object> map = new HashMap<>(2); |
| 352 | + map.put(ROOM_ID, roomId); |
| 353 | + map.put("goodsId", goodsId); |
| 354 | + String responseContent = this.wxMaService.post(Room.DELETE_IN_ROOM, WxMaGsonBuilder.create().toJson(map)); |
| 355 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 356 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 357 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 358 | + } |
| 359 | + return true; |
| 360 | + } |
| 361 | + |
| 362 | + @Override |
| 363 | + public boolean push(Integer roomId, Integer goodsId) throws WxErrorException { |
| 364 | + Map<String, Object> map = new HashMap<>(2); |
| 365 | + map.put(ROOM_ID, roomId); |
| 366 | + map.put("goodsId", goodsId); |
| 367 | + String responseContent = this.wxMaService.post(Room.PUSH, WxMaGsonBuilder.create().toJson(map)); |
| 368 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 369 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 370 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 371 | + } |
| 372 | + return true; |
| 373 | + } |
| 374 | + |
| 375 | + @Override |
| 376 | + public boolean sort(Integer roomId, List<Map<String,String>> goods) throws WxErrorException { |
| 377 | + Map<String, Object> map = new HashMap<>(2); |
| 378 | + map.put(ROOM_ID, roomId); |
| 379 | + map.put("goods", goods); |
| 380 | + String responseContent = this.wxMaService.post(Room.SORT, WxMaGsonBuilder.create().toJson(map)); |
| 381 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 382 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 383 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 384 | + } |
| 385 | + return true; |
| 386 | + } |
| 387 | + |
| 388 | + @Override |
| 389 | + public String getVideo(Integer roomId, Integer goodsId) throws WxErrorException { |
| 390 | + Map<String, Object> map = new HashMap<>(2); |
| 391 | + map.put(ROOM_ID, roomId); |
| 392 | + map.put("goodsId", goodsId); |
| 393 | + String responseContent = this.wxMaService.get(Room.GET_VIDEO, WxMaGsonBuilder.create().toJson(map)); |
| 394 | + JsonObject jsonObject = GsonParser.parse(responseContent); |
| 395 | + if (jsonObject.get(ERR_CODE).getAsInt() != 0) { |
| 396 | + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); |
| 397 | + } |
| 398 | + return jsonObject.get("url").getAsString(); |
| 399 | + } |
| 400 | + |
234 | 401 | }
|
0 commit comments