diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java index ad1dc1506..472d5299a 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java @@ -542,4 +542,10 @@ public interface WxMaService extends WxService { * @return getWxMaOpenApiService */ WxMaOpenApiService getWxMaOpenApiService(); + /** + * 小程序短剧管理 + * + * @return getWxMaVodService + */ + WxMaVodService getWxMaVodService(); } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaVodService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaVodService.java new file mode 100644 index 000000000..958b61efe --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaVodService.java @@ -0,0 +1,23 @@ +package cn.binarywang.wx.miniapp.api; + +import cn.binarywang.wx.miniapp.bean.vod.*; +import me.chanjar.weixin.common.error.WxErrorException; + +import java.util.List; + +public interface WxMaVodService { + List listMedia(WxMaVodListMediaRequest request) throws WxErrorException; + + List listDrama(WxMaVodListDramaRequest request) throws WxErrorException; + + WxMaVodMediaPlaybackInfo getMediaLink(WxMaVodGetMediaLinkRequest request) throws WxErrorException; + + WxMaVodMediaInfo getMedia(WxMaVodGetMediaRequest request) throws WxErrorException; + + boolean deleteMedia(WxMaVodDeleteMediaRequest request) throws WxErrorException; + + WxMaVodDramaInfo getDrama(WxMaVodGetDramaRequest request) throws WxErrorException; + + Integer auditDrama(WxMaVodAuditDramaRequest request) throws WxErrorException; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java index 3847b397e..f8e9ea07f 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java @@ -89,6 +89,7 @@ public abstract class BaseWxMaServiceImpl implements WxMaService, RequestH private final WxMaOrderShippingService wxMaOrderShippingService = new WxMaOrderShippingServiceImpl(this); private final WxMaOpenApiService wxMaOpenApiService = new WxMaOpenApiServiceImpl(this); + private final WxMaVodService wxMaVodService = new WxMaVodServiceImpl(this); private Map configMap = new HashMap<>(); private int retrySleepMillis = 1000; @@ -664,4 +665,9 @@ public abstract class BaseWxMaServiceImpl implements WxMaService, RequestH public WxMaOpenApiService getWxMaOpenApiService() { return this.wxMaOpenApiService; } + @Override + public WxMaVodService getWxMaVodService() { + return this.wxMaVodService; + } + } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImpl.java new file mode 100644 index 000000000..ae4618cf5 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImpl.java @@ -0,0 +1,127 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.api.WxMaVodService; +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.bean.vod.*; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.common.enums.WxType; +import me.chanjar.weixin.common.error.WxError; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; + +import java.util.List; + +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Vod.*; + + +@RequiredArgsConstructor +@Slf4j +public class WxMaVodServiceImpl implements WxMaVodService { + + private final WxMaService service; + + @Override + public List listMedia(WxMaVodListMediaRequest mediaRequest) throws WxErrorException { + String responseContent = this.service.post(LIST_MEDIA_URL, mediaRequest.toJson()); + + JsonObject jsonObject = GsonParser.parse(responseContent); + boolean hasMediaInfoList = jsonObject.has("media_info_list"); + if (hasMediaInfoList) { + return WxMaGsonBuilder.create().fromJson(jsonObject.getAsJsonArray("media_info_list"), + new TypeToken>() { + }.getType()); + } else { + return null; + } + } + + + @Override + public List listDrama(WxMaVodListDramaRequest mediaRequest) throws WxErrorException { + String responseContent = this.service.post(LIST_DRAMAS_URL, mediaRequest.toJson()); + JsonObject jsonObject = GsonParser.parse(responseContent); + boolean hasMediaInfoList = jsonObject.has("drama_info_list"); + if (hasMediaInfoList) { + return WxMaGsonBuilder.create().fromJson(jsonObject.getAsJsonArray("drama_info_list"), + new TypeToken>() { + }.getType()); + } else { + return null; + } + } + + + @Override + public WxMaVodMediaPlaybackInfo getMediaLink(WxMaVodGetMediaLinkRequest request) throws WxErrorException { + String responseContent = this.service.post(GET_MEDIA_LINK_URL, request.toJson()); + WxMaVodGetMediaLinkResponse getDetailResponse = WxMaGsonBuilder.create() + .fromJson(responseContent, WxMaVodGetMediaLinkResponse.class); + + if (getDetailResponse.getErrcode() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return getDetailResponse.getMediaInfo(); + } + + + @Override + public WxMaVodMediaInfo getMedia(WxMaVodGetMediaRequest request) throws WxErrorException { + String responseContent = this.service.post(GET_MEDIA_URL, request.toJson()); + WxMaVodGetMediaResponse getDetailResponse = WxMaGsonBuilder.create() + .fromJson(responseContent, WxMaVodGetMediaResponse.class); + + if (getDetailResponse.getErrcode() != 0) { + throw new WxErrorException(WxError.fromJson(responseContent, WxType.MiniApp)); + } + return getDetailResponse.getMediaInfo(); + } + + @Override + public boolean deleteMedia(WxMaVodDeleteMediaRequest request) throws WxErrorException { + String responseContent = this.service.post(DELETE_MEDIA_URL, request.toJson()); + WxMaBaseResponse getDetailResponse = WxMaGsonBuilder.create() + .fromJson(responseContent, WxMaBaseResponse.class); + + if (getDetailResponse.getErrcode() != 0) { + throw new WxErrorException( + new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg())); + } + + return true; + } + + @Override + public WxMaVodDramaInfo getDrama(WxMaVodGetDramaRequest request) throws WxErrorException { + String responseContent = this.service.post(GET_DRAMA_URL, request.toJson()); + WxMaVodGetDramaResponse getDetailResponse = WxMaGsonBuilder.create() + .fromJson(responseContent, WxMaVodGetDramaResponse.class); + + if (getDetailResponse.getErrcode() != 0) { + throw new WxErrorException( + new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg())); + } + + return getDetailResponse.getDramaInfo(); + + } + + @Override + public Integer auditDrama(WxMaVodAuditDramaRequest request) throws WxErrorException { + String responseContent = this.service.post(AUDIT_DRAMA_URL, request.toJson()); + WxMaVodAuditDramaResponse getDetailResponse = WxMaGsonBuilder.create() + .fromJson(responseContent, WxMaVodAuditDramaResponse.class); + + if (getDetailResponse.getErrcode() != 0) { + throw new WxErrorException( + new WxError(getDetailResponse.getErrcode(), getDetailResponse.getErrmsg())); + } + + return getDetailResponse.getDramaId(); + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaRequest.java new file mode 100644 index 000000000..87d53fcc6 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaRequest.java @@ -0,0 +1,46 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodAuditDramaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("drama_id") + private Integer dramaId; + @SerializedName("name") + private String name; + @SerializedName("media_count") + private Long mediaCount; + @SerializedName("media_id_list") + private List mediaIdList; + @SerializedName("producer") + private String producer; + @SerializedName("cover_material_id") + private String coverMaterialId; + @SerializedName("authorized_material_id") + private String authorizedMaterialId; + @SerializedName("registration_number") + private String registrationNumber; + @SerializedName("publish_license") + private String publishLicense; + @SerializedName("publish_license_material_id") + private String publishLicenseMaterialId; + @SerializedName("expedited") + private Long expedited; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaResponse.java new file mode 100644 index 000000000..b45644341 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaResponse.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodAuditDramaResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("drama_id") + private Integer dramaId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDeleteMediaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDeleteMediaRequest.java new file mode 100644 index 000000000..a553e2109 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDeleteMediaRequest.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodDeleteMediaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_id") + private Integer mediaId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDramaInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDramaInfo.java new file mode 100644 index 000000000..405f8e37c --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDramaInfo.java @@ -0,0 +1,64 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodDramaInfo implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + + private String name; + private String producer; + private String playwright; + + @SerializedName("drama_id") + private Integer dramaId; + @SerializedName("create_time") + private Long createTime; + @SerializedName("cover_url") + private String coverUrl; + @SerializedName("media_count") + private Long mediaCount; + @SerializedName("expedited") + private Long expedited; + @SerializedName("production_license") + private String productionLicense; + @SerializedName("description") + private String description; + + @SerializedName("audit_detail") + private DramaAuditDetail auditDetail; + @SerializedName("media_list") + private List mediaList; + + @Data + public static class DramaAuditDetail { + + @SerializedName("status") + private Integer status; + @SerializedName("create_time") + private Long createTime; + @SerializedName("audit_time") + private Long auditTime; + } + + @Data + public static class DramaMediaInfo { + + @SerializedName("media_id") + private Integer mediaId; + + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaRequest.java new file mode 100644 index 000000000..58c902f18 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaRequest.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetDramaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("drama_id") + private Integer dramaId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaResponse.java new file mode 100644 index 000000000..eaffa6782 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaResponse.java @@ -0,0 +1,26 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetDramaResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("drama_info") + private WxMaVodDramaInfo dramaInfo; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkRequest.java new file mode 100644 index 000000000..81200c8ff --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkRequest.java @@ -0,0 +1,39 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetMediaLinkRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_id") + private Integer mediaId; + @SerializedName("t") + private Long t; + + @SerializedName("expr") + private Long expr; + @SerializedName("rlimit") + private Long rlimit; + + @SerializedName("us") + private String us; + @SerializedName("whref") + private String whRef; + @SerializedName("bkref") + private String bkRef; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkResponse.java new file mode 100644 index 000000000..044e6268a --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaLinkResponse.java @@ -0,0 +1,27 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetMediaLinkResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_info") + private WxMaVodMediaPlaybackInfo mediaInfo; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaRequest.java new file mode 100644 index 000000000..175617134 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaRequest.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetMediaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_id") + private Integer mediaId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaResponse.java new file mode 100644 index 000000000..f33b822fe --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetMediaResponse.java @@ -0,0 +1,27 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetMediaResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("media_info") + private WxMaVodMediaInfo mediaInfo; + + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskRequest.java new file mode 100644 index 000000000..5609442bb --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskRequest.java @@ -0,0 +1,25 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetTaskRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("task_id") + private Integer taskId; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskResponse.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskResponse.java new file mode 100644 index 000000000..b2cac0561 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetTaskResponse.java @@ -0,0 +1,45 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.bean.WxMaBaseResponse; +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodGetTaskResponse extends WxMaBaseResponse implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + @SerializedName("task_info") + private TaskInfo taskInfo; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } + + @Data + public static class TaskInfo { + + @SerializedName("task_type") + private Integer taskType; + @SerializedName("status") + private Integer status; + @SerializedName("errcode") + private Integer errCode; + @SerializedName("errmsg") + private String errMsg; + @SerializedName("create_time") + private Long createTime; + @SerializedName("finish_time") + private Long finish_time; + @SerializedName("media_id") + private Integer mediaId; + + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListDramaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListDramaRequest.java new file mode 100644 index 000000000..55dc79d4b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListDramaRequest.java @@ -0,0 +1,28 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodListDramaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + + @SerializedName("offset") + private Integer offset; + @SerializedName("limit") + private Integer limit; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListMediaRequest.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListMediaRequest.java new file mode 100644 index 000000000..ace2c3b74 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodListMediaRequest.java @@ -0,0 +1,37 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class WxMaVodListMediaRequest implements Serializable { + private static final long serialVersionUID = 7495157056049312108L; + + @SerializedName("drama_id") + private Integer dramaId; + @SerializedName("media_name") + private String mediaName; + + @SerializedName("start_time") + private Long startTime; + @SerializedName("end_time") + private Long endTime; + + @SerializedName("offset") + private Integer offset; + @SerializedName("limit") + private Integer limit; + + public String toJson() { + return WxMaGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaInfo.java new file mode 100644 index 000000000..53b4f1c0b --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaInfo.java @@ -0,0 +1,76 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.List; + +/** + * 小程序帐号的可选类目,其中 address / tag / title 是提交审核会用到的 + *

+ * media_id number 媒资文件id。 + * create_time number 上传时间,时间戳。 + * expire_time number 过期时间,时间戳。 + * drama_id number 所属剧目id。 + * file_size string 媒资文件大小,单位:字节。 + * duration number 播放时长,单位:秒。 + * name string 媒资文件名。 + * description string 描述。 + * cover_url string 封面图临时链接。 + * original_url string 原始视频临时链接。 + * mp4_url string mp4格式临时链接 。 + * hls_url string hls格式临时链接。 + * audit_detail MediaAuditDetail 审核信息。 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodMediaInfo implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + private String name; + private String description; + @SerializedName("media_id") + private Integer mediaId; + @SerializedName("drama_id") + private Integer dramaId; + @SerializedName("create_time") + private Long createTime; + @SerializedName("file_size") + private String fileSize; + @SerializedName("duration") + private Long duration; + @SerializedName("expire_time") + private Long expireTime; + @SerializedName("cover_url") + private String coverUrl; + @SerializedName("original_url") + private String originalUrl; + @SerializedName("mp4_url") + private String mp4Url; + @SerializedName("hls_url") + private String hlsUrl; + @SerializedName("audit_detail") + private MediaAuditDetail auditDetail; + + @Data + public static class MediaAuditDetail { + + @SerializedName("status") + private Integer status; + @SerializedName("create_time") + private Long createTime; + @SerializedName("audit_time") + private Long auditTime; + @SerializedName("reason") + private String reason; + @SerializedName("evidence_material_id_list") + private List evidenceMaterialIdList; + } +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaPlaybackInfo.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaPlaybackInfo.java new file mode 100644 index 000000000..a4746d5e5 --- /dev/null +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodMediaPlaybackInfo.java @@ -0,0 +1,35 @@ +package cn.binarywang.wx.miniapp.bean.vod; + +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.io.Serializable; + + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Accessors(chain = true) +public class WxMaVodMediaPlaybackInfo implements Serializable { + private static final long serialVersionUID = -7663757440028175135L; + + private String name; + private String description; + @SerializedName("media_id") + private Integer mediaId; + @SerializedName("duration") + private Long duration; + + @SerializedName("cover_url") + private String coverUrl; + @SerializedName("mp4_url") + private String mp4Url; + @SerializedName("hls_url") + private String hlsUrl; + +} diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java index 10ac835c9..f946b70c2 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java @@ -830,4 +830,24 @@ public class WxMaApiUrlConstants { String SET_MSG_JUMP_PATH = "https://api.weixin.qq.com/wxa/sec/order/set_msg_jump_path"; } + + public interface Vod { + String LIST_MEDIA_URL = "https://api.weixin.qq.com/wxa/sec/vod/listmedia"; + String GET_MEDIA_URL = "https://api.weixin.qq.com/wxa/sec/vod/getmedia"; + String GET_MEDIA_LINK_URL = "https://api.weixin.qq.com/wxa/sec/vod/getmedialink"; + String DELETE_MEDIA_URL = "https://api.weixin.qq.com/wxa/sec/vod/deletemedia"; + String AUDIT_DRAMA_URL = "https://api.weixin.qq.com/wxa/sec/vod/auditdrama"; + String LIST_DRAMAS_URL = "https://api.weixin.qq.com/wxa/sec/vod/listdramas"; + String GET_DRAMA_URL = "https://api.weixin.qq.com/wxa/sec/vod/getdrama"; + String SINGLE_FILE_UPLOAD_URL = "https://api.weixin.qq.com/wxa/sec/vod/singlefileupload"; + String PULL_UPLOAD_URL = "https://api.weixin.qq.com/wxa/sec/vod/pullupload"; + String GET_TASK_URL = "https://api.weixin.qq.com/wxa/sec/vod/gettask"; + String APPLY_UPLOAD_URL = "https://api.weixin.qq.com/wxa/sec/vod/applyupload"; + String UPLOAD_PART_URL = "https://api.weixin.qq.com/wxa/sec/vod/uploadpart"; + String COMMIT_UPLOAD_URL = "https://api.weixin.qq.com/wxa/sec/vod/commitupload"; + String GET_CDN_USAGE_DATA_URL = "https://api.weixin.qq.com/wxa/sec/vod/getcdnusagedata"; + String GET_CDN_LOGS_URL = "https://api.weixin.qq.com/wxa/sec/vod/getcdnlogs"; + + + } } diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java index b9ada8759..149c723e7 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaConstants.java @@ -181,4 +181,41 @@ public class WxMaConstants { */ public static final String ZH_TW = "zh_TW"; } + + @UtilityClass + public static final class AuditStatus { + public static final int INVALID = 0; + public static final int ONGOING = 1; + public static final int REJECTED = 2; + public static final int APPROVED = 3; + public static final int RECOMMIT = 4; + } + + + @UtilityClass + public static final class ExpeditedType { + + /** + * 非加急 + */ + public static final int NORMAL = 0; + + /** + * 加急 + */ + public static final int HIGH_PRIORITY = 1; + } + + @UtilityClass + public static final class UploadTaskType { + public static final int PULL_UPLOAD = 1; + } + + @UtilityClass + public static final class UploadTaskStatus { + public static final int WAITING = 1; + public static final int WORKING = 2; + public static final int DONE = 3; + public static final int FAILED = 4; + } } diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImplTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImplTest.java new file mode 100644 index 000000000..73797ab7c --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImplTest.java @@ -0,0 +1,87 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.bean.vod.*; +import cn.binarywang.wx.miniapp.test.ApiTestModule; +import com.google.inject.Inject; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +import java.util.List; + +import static org.testng.Assert.assertNotNull; + +@Test +@Guice(modules = ApiTestModule.class) +public class WxMaVodServiceImplTest { + @Inject + private WxMaService wxService; + + @Test + public void testListMedia() throws Exception { + WxMaVodListMediaRequest request = WxMaVodListMediaRequest.builder() + .dramaId(100000) + .offset(0) + .limit(100) + .build(); + List response = this.wxService.getWxMaVodService().listMedia(request); + assertNotNull(response); + } + + @Test + public void testListDrama() throws Exception { + WxMaVodListDramaRequest request = WxMaVodListDramaRequest.builder() + .offset(0) + .limit(100) + .build(); + List response = this.wxService.getWxMaVodService().listDrama(request); + assertNotNull(response); + + } + + @Test + public void testGetMediaLink() throws Exception { + WxMaVodGetMediaLinkRequest request = WxMaVodGetMediaLinkRequest.builder() + .mediaId(10000) + .build(); + WxMaVodMediaPlaybackInfo response = this.wxService.getWxMaVodService().getMediaLink(request); + assertNotNull(response); + } + + @Test + public void testGetMedia() throws Exception { + WxMaVodGetMediaRequest request = WxMaVodGetMediaRequest.builder() + .mediaId(0) + .build(); + WxMaVodMediaInfo response = this.wxService.getWxMaVodService().getMedia(request); + assertNotNull(response); + } + + @Test + public void testDeleteMedia() throws Exception { + WxMaVodDeleteMediaRequest request = WxMaVodDeleteMediaRequest.builder() + .mediaId(0) + .build(); + boolean response = this.wxService.getWxMaVodService().deleteMedia(request); + assertNotNull(response); + } + + @Test + public void testGetDrama() throws Exception { + WxMaVodGetDramaRequest request = WxMaVodGetDramaRequest.builder() + .dramaId(0) + .build(); + WxMaVodDramaInfo response = this.wxService.getWxMaVodService().getDrama(request); + assertNotNull(response); + } + + @Test + public void testAuditDrama() throws Exception { + WxMaVodAuditDramaRequest request = WxMaVodAuditDramaRequest.builder() + .dramaId(0) + .name("name") + .build(); + Integer response = this.wxService.getWxMaVodService().auditDrama(request); + assertNotNull(response); + } +}