diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java index 380c3bfc5..cb30cea1f 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpLivingService.java @@ -48,7 +48,7 @@ public interface WxCpLivingService { * @return * @throws WxErrorException */ - WxCpWatchStat getWatchStat(@NonNull String livingId, Integer nextKey) throws WxErrorException; + WxCpWatchStat getWatchStat(@NonNull String livingId, String nextKey) throws WxErrorException; /** * 获取成员直播ID列表 diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java index 1a4366491..5f05ae0c1 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpSchoolService.java @@ -1,10 +1,9 @@ package me.chanjar.weixin.cp.api; +import lombok.NonNull; import me.chanjar.weixin.common.error.WxErrorException; -import me.chanjar.weixin.cp.bean.school.WxCpCustomizeHealthInfo; -import me.chanjar.weixin.cp.bean.school.WxCpPaymentResult; -import me.chanjar.weixin.cp.bean.school.WxCpResultList; -import me.chanjar.weixin.cp.bean.school.WxCpTrade; +import me.chanjar.weixin.cp.bean.living.WxCpLivingResult; +import me.chanjar.weixin.cp.bean.school.*; import javax.validation.constraints.NotNull; import java.util.List; @@ -82,4 +81,68 @@ public interface WxCpSchoolService { */ WxCpTrade getTrade(@NotNull String paymentId, @NotNull String tradeNo) throws WxErrorException; + /** + * 获取直播详情 + * 请求方式:GET(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_living_info?access_token=ACCESS_TOKEN&livingid=LIVINGID + * + * @param livingId + * @return + */ + WxCpSchoolLivingInfo getLivingInfo(@NotNull String livingId) throws WxErrorException; + + /** + * 获取老师直播ID列表 + * 通过此接口可以获取指定老师的所有直播ID + *
+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/living/get_user_all_livingid?access_token=ACCESS_TOKEN + * + * @param userId + * @param cursor + * @param limit + * @return + * @throws WxErrorException + */ + WxCpLivingResult.LivingIdResult getUserAllLivingId(@NonNull String userId, String cursor, Integer limit) throws WxErrorException; + + /** + * 获取观看直播统计 + * 通过该接口可以获取所有观看直播的人员统计 + *
+ * 请求方式:POST(HTTPS) + * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_watch_stat?access_token=ACCESS_TOKEN + * + * @param livingId + * @param nextKey + * @return + * @throws WxErrorException + */ + WxCpSchoolWatchStat getWatchStat(@NonNull String livingId, String nextKey) throws WxErrorException; + + /** + * 获取未观看直播统计 + * 通过该接口可以获取未观看直播的学生统计,学生的家长必须是已经关注「学校通知」才会纳入统计范围。 + *
+ * 请求方式:POST(HTTPS)
+ * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/living/get_unwatch_stat?access_token=ACCESS_TOKEN
+ *
+ * @param livingId
+ * @param nextKey
+ * @return
+ * @throws WxErrorException
+ */
+ WxCpSchoolUnwatchStat getUnwatchStat(@NonNull String livingId, String nextKey) throws WxErrorException;
+
+ /**
+ * 删除直播回放
+ * 请求方式: POST(HTTPS)
+ * 请求地址: https://qyapi.weixin.qq.com/cgi-bin/living/delete_replay_data?access_token=ACCESS_TOKEN
+ *
+ * @param livingId
+ * @return
+ * @throws WxErrorException
+ */
+ WxCpLivingResult deleteReplayData(@NonNull String livingId) throws WxErrorException;
+
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpLivingServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpLivingServiceImpl.java
index 5fdf18cf8..03ad270e6 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpLivingServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpLivingServiceImpl.java
@@ -12,13 +12,15 @@ import me.chanjar.weixin.cp.api.WxCpLivingService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.living.*;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
+import org.apache.commons.lang3.StringUtils;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Living.*;
/**
* 企业微信直播接口实现类.
+ * https://developer.work.weixin.qq.com/document/path/93633
*
- * @author Wang_Wong
+ * @author Wang_Wong
* @date 2021-12-21
*/
@Slf4j
@@ -48,11 +50,11 @@ public class WxCpLivingServiceImpl implements WxCpLivingService {
}
@Override
- public WxCpWatchStat getWatchStat(String livingId, Integer nextKey) throws WxErrorException {
+ public WxCpWatchStat getWatchStat(String livingId, String nextKey) throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_WATCH_STAT);
JsonObject jsonObject = new JsonObject();
- if (nextKey != null) {
- jsonObject.addProperty("next_key", String.valueOf(nextKey));
+ if (StringUtils.isNotBlank(nextKey)) {
+ jsonObject.addProperty("next_key", nextKey);
}
jsonObject.addProperty("livingid", livingId);
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolServiceImpl.java
index 023ee6056..30500a205 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpSchoolServiceImpl.java
@@ -1,15 +1,15 @@
package me.chanjar.weixin.cp.api.impl;
import com.google.gson.JsonObject;
+import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpSchoolService;
import me.chanjar.weixin.cp.api.WxCpService;
-import me.chanjar.weixin.cp.bean.school.WxCpCustomizeHealthInfo;
-import me.chanjar.weixin.cp.bean.school.WxCpPaymentResult;
-import me.chanjar.weixin.cp.bean.school.WxCpResultList;
-import me.chanjar.weixin.cp.bean.school.WxCpTrade;
+import me.chanjar.weixin.cp.bean.living.WxCpLivingResult;
+import me.chanjar.weixin.cp.bean.school.*;
+import org.apache.commons.lang3.StringUtils;
import javax.validation.constraints.NotNull;
import java.util.List;
@@ -85,4 +85,45 @@ public class WxCpSchoolServiceImpl implements WxCpSchoolService {
return WxCpTrade.fromJson(responseContent);
}
+ @Override
+ public WxCpSchoolLivingInfo getLivingInfo(@NotNull String livingId) throws WxErrorException {
+ String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_LIVING_INFO) + livingId;
+ String responseContent = this.cpService.get(apiUrl, null);
+ return WxCpSchoolLivingInfo.fromJson(responseContent);
+ }
+
+ @Override
+ public WxCpLivingResult.LivingIdResult getUserAllLivingId(@NonNull String userId, String cursor, Integer limit) throws WxErrorException {
+ return this.cpService.getLivingService().getUserAllLivingId(userId, cursor, limit);
+ }
+
+ @Override
+ public WxCpSchoolWatchStat getWatchStat(@NonNull String livingId, String nextKey) throws WxErrorException {
+ String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_WATCH_STAT);
+ JsonObject jsonObject = new JsonObject();
+ if (StringUtils.isNotBlank(nextKey)) {
+ jsonObject.addProperty("next_key", nextKey);
+ }
+ jsonObject.addProperty("livingid", livingId);
+ String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
+ return WxCpSchoolWatchStat.fromJson(responseContent);
+ }
+
+ @Override
+ public WxCpSchoolUnwatchStat getUnwatchStat(@NonNull String livingId, String nextKey) throws WxErrorException {
+ String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_UNWATCH_STAT);
+ JsonObject jsonObject = new JsonObject();
+ if (StringUtils.isNotBlank(nextKey)) {
+ jsonObject.addProperty("next_key", nextKey);
+ }
+ jsonObject.addProperty("livingid", livingId);
+ String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
+ return WxCpSchoolUnwatchStat.fromJson(responseContent);
+ }
+
+ @Override
+ public WxCpLivingResult deleteReplayData(@NonNull String livingId) throws WxErrorException {
+ return cpService.getLivingService().deleteReplayData(livingId);
+ }
+
}
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingInfo.java
index b7010e57e..59ba35cd1 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingInfo.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingInfo.java
@@ -22,7 +22,7 @@ public class WxCpLivingInfo implements Serializable {
private Long livingStart;
@SerializedName("living_duration")
- private Long livingDurationme;
+ private Long livingDuration;
@SerializedName("status")
private Integer status;
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingResult.java
index 3312eec77..09c912ad8 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingResult.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/living/WxCpLivingResult.java
@@ -32,7 +32,7 @@ public class WxCpLivingResult implements Serializable {
private String nextCursor;
@SerializedName("livingid_list")
- private String[] livingidList;
+ private String[] livingIdList;
public static LivingIdResult fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, LivingIdResult.class);
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/school/WxCpSchoolLivingInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/school/WxCpSchoolLivingInfo.java
new file mode 100644
index 000000000..2206cfcc2
--- /dev/null
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/school/WxCpSchoolLivingInfo.java
@@ -0,0 +1,94 @@
+package me.chanjar.weixin.cp.bean.school;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+import me.chanjar.weixin.cp.bean.WxCpBaseResp;
+import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 获取直播详情.
+ *
+ * @author Wang_Wong
+ */
+@Data
+public class WxCpSchoolLivingInfo extends WxCpBaseResp implements Serializable {
+ private static final long serialVersionUID = -5028321625140879571L;
+
+ @SerializedName("living_info")
+ private LivingInfo livingInfo;
+
+ @Getter
+ @Setter
+ public static class LivingInfo implements Serializable {
+
+ @SerializedName("theme")
+ private String theme;
+
+ @SerializedName("living_start")
+ private Long livingStart;
+
+ @SerializedName("living_duration")
+ private Long livingDuration;
+
+ @SerializedName("anchor_userid")
+ private String anchorUserId;
+
+ @SerializedName("living_range")
+ private LivingRange livingRange;
+
+ @SerializedName("viewer_num")
+ private Integer viewerNum;
+
+ @SerializedName("comment_num")
+ private Integer commentNum;
+
+ @SerializedName("open_replay")
+ private Integer openReplay;
+
+ @SerializedName("push_stream_url")
+ private String pushStreamUrl;
+
+ public static LivingInfo fromJson(String json) {
+ return WxCpGsonBuilder.create().fromJson(json, LivingInfo.class);
+ }
+
+ public String toJson() {
+ return WxCpGsonBuilder.create().toJson(this);
+ }
+
+ }
+
+ @Getter
+ @Setter
+ public static class LivingRange implements Serializable {
+
+ @SerializedName("partyids")
+ private List