From 0f9e75acb29954f7abbba750807dd566c76992d2 Mon Sep 17 00:00:00 2001 From: linlinjava Date: Sun, 21 Aug 2022 14:56:49 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20#2785=E3=80=90=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E3=80=91=E8=8E=B7=E5=8F=96=E7=9B=B4=E6=92=AD=E9=97=B4?= =?UTF-8?q?=E5=88=86=E4=BA=AB=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E6=94=AF=E6=8C=81=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=92=8C=E6=B5=B7=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wx/miniapp/api/WxMaLiveService.java | 2 +- .../miniapp/api/impl/WxMaLiveServiceImpl.java | 4 +-- .../miniapp/bean/live/WxMaLiveSharedCode.java | 25 +++++++++++++++++++ .../api/impl/WxMaLiveServiceImplTest.java | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveSharedCode.java 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 2d7751948d..1473b54a17 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 @@ -84,7 +84,7 @@ public interface WxMaLiveService { * @return . * @throws WxErrorException . */ - String getSharedCode(Integer roomId, String params) throws WxErrorException; + WxMaLiveSharedCode getSharedCode(Integer roomId, String params) 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 56c744f6d4..68c1c092b9 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 @@ -87,7 +87,7 @@ public String getPushUrl(Integer roomId) throws WxErrorException { } @Override - public String getSharedCode(Integer roomId, String params) throws WxErrorException { + public WxMaLiveSharedCode getSharedCode(Integer roomId, String params) throws WxErrorException { Map map = new HashMap<>(2); map.put(ROOM_ID, roomId); if (null != params) { @@ -98,7 +98,7 @@ public String getSharedCode(Integer roomId, String params) throws WxErrorExcepti if (jsonObject.get(ERR_CODE).getAsInt() != 0) { throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); } - return jsonObject.get("cdnUrl").getAsString(); + return WxMaGsonBuilder.create().fromJson(responseContent, WxMaLiveSharedCode.class); } @Override diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveSharedCode.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveSharedCode.java new file mode 100644 index 0000000000..f27dba87b0 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/live/WxMaLiveSharedCode.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.live; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.io.Serializable; + +public class WxMaLiveSharedCode implements Serializable { + private static final long serialVersionUID = 8525117884393611947L; + /** + * 分享二维码 + */ + @SerializedName("cdnUrl") + private String cdnUrl; + /** + * 分享路径 + */ + @SerializedName("pagePath") + private String pagePath; + /** + * 分享海报 + */ + @SerializedName("posterUrl") + private String posterUrl; +} \ No newline at end of file diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java index b9a5b94121..2f497935c7 100644 --- a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java @@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.bean.live.WxMaCreateRoomResult; import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult; import cn.binarywang.wx.miniapp.bean.live.WxMaLiveRoomInfo; +import cn.binarywang.wx.miniapp.bean.live.WxMaLiveSharedCode; import cn.binarywang.wx.miniapp.test.ApiTestModule; import com.google.inject.Inject; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; @@ -95,7 +96,7 @@ public void getPushUrl() throws Exception { @Test public void getSharedCode() throws Exception { - String result = this.wxService.getLiveService().getSharedCode(39, null); + WxMaLiveSharedCode result = this.wxService.getLiveService().getSharedCode(39, null); System.out.println(result); }