Skip to content

Commit 00a45e1

Browse files
authored
🎨 #2785【小程序】获取直播间分享二维码接口优化,支持分享路径和海报
1 parent dde8e38 commit 00a45e1

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

Diff for: weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLiveService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public interface WxMaLiveService {
8484
* @return .
8585
* @throws WxErrorException .
8686
*/
87-
String getSharedCode(Integer roomId, String params) throws WxErrorException;
87+
WxMaLiveSharedCode getSharedCode(Integer roomId, String params) throws WxErrorException;
8888

8989
/**
9090
* 获取直播房间列表.(分页)

Diff for: weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public String getPushUrl(Integer roomId) throws WxErrorException {
8787
}
8888

8989
@Override
90-
public String getSharedCode(Integer roomId, String params) throws WxErrorException {
90+
public WxMaLiveSharedCode getSharedCode(Integer roomId, String params) throws WxErrorException {
9191
Map<String, Object> map = new HashMap<>(2);
9292
map.put(ROOM_ID, roomId);
9393
if (null != params) {
@@ -98,7 +98,7 @@ public String getSharedCode(Integer roomId, String params) throws WxErrorExcepti
9898
if (jsonObject.get(ERR_CODE).getAsInt() != 0) {
9999
throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp));
100100
}
101-
return jsonObject.get("cdnUrl").getAsString();
101+
return WxMaGsonBuilder.create().fromJson(responseContent, WxMaLiveSharedCode.class);
102102
}
103103

104104
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cn.binarywang.wx.miniapp.bean.live;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
6+
import java.io.Serializable;
7+
8+
public class WxMaLiveSharedCode implements Serializable {
9+
private static final long serialVersionUID = 8525117884393611947L;
10+
/**
11+
* 分享二维码
12+
*/
13+
@SerializedName("cdnUrl")
14+
private String cdnUrl;
15+
/**
16+
* 分享路径
17+
*/
18+
@SerializedName("pagePath")
19+
private String pagePath;
20+
/**
21+
* 分享海报
22+
*/
23+
@SerializedName("posterUrl")
24+
private String posterUrl;
25+
}

Diff for: weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLiveServiceImplTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import cn.binarywang.wx.miniapp.bean.live.WxMaCreateRoomResult;
55
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveResult;
66
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveRoomInfo;
7+
import cn.binarywang.wx.miniapp.bean.live.WxMaLiveSharedCode;
78
import cn.binarywang.wx.miniapp.test.ApiTestModule;
89
import com.google.inject.Inject;
910
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
@@ -95,7 +96,7 @@ public void getPushUrl() throws Exception {
9596

9697
@Test
9798
public void getSharedCode() throws Exception {
98-
String result = this.wxService.getLiveService().getSharedCode(39, null);
99+
WxMaLiveSharedCode result = this.wxService.getLiveService().getSharedCode(39, null);
99100
System.out.println(result);
100101
}
101102

0 commit comments

Comments
 (0)