forked from binarywang/WxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🆕 binarywang#3115【小程序】增加短剧媒资管理相关接口支持
- Loading branch information
1 parent
88a781b
commit af8928f
Showing
23 changed files
with
881 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaVodService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<WxMaVodMediaInfo> listMedia(WxMaVodListMediaRequest request) throws WxErrorException; | ||
|
||
List<WxMaVodDramaInfo> 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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaVodServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<WxMaVodMediaInfo> 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<List<WxMaVodMediaInfo>>() { | ||
}.getType()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public List<WxMaVodDramaInfo> 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<List<WxMaVodDramaInfo>>() { | ||
}.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(); | ||
|
||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...ava-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Integer> 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); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...va-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodAuditDramaResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...va-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDeleteMediaRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodDramaInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DramaMediaInfo> 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; | ||
|
||
|
||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/vod/WxMaVodGetDramaResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
Oops, something went wrong.