1
0
mirror of synced 2025-12-16 20:28:11 +08:00

🎨 优化小程序直播间创建接口

This commit is contained in:
Binary Wang
2021-03-30 20:46:17 +08:00
parent 59d8cc6d57
commit d16ea7d4de

View File

@@ -18,7 +18,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.*;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.GET_LIVE_INFO;
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Broadcast.Room;
/**
* <pre>
@@ -36,13 +37,20 @@ public class WxMaLiveServiceImpl implements WxMaLiveService {
@Override
public WxMaCreateRoomResult createRoom(WxMaLiveRoomInfo roomInfo) throws WxErrorException {
String responseContent = this.wxMaService.post(Room.CREATE_ROOM, WxMaGsonBuilder.create().toJson(roomInfo));
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
try {
String responseContent = this.wxMaService.post(Room.CREATE_ROOM, WxMaGsonBuilder.create().toJson(roomInfo));
JsonObject jsonObject = GsonParser.parse(responseContent);
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaCreateRoomResult.class);
} catch (WxErrorException e) {
if (e.getError().getErrorCode() == 300036) {
return WxMaGsonBuilder.create().fromJson(e.getError().getJson(), WxMaCreateRoomResult.class);
} else {
throw e;
}
}
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaCreateRoomResult.class);
}
@Override