Skip to content

Commit

Permalink
🆕 binarywang#3115【小程序】增加短剧媒资管理相关接口支持
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinzhwl authored and zhongjun96 committed Oct 18, 2023
1 parent 88a781b commit af8928f
Show file tree
Hide file tree
Showing 23 changed files with 881 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,10 @@ public interface WxMaService extends WxService {
* @return getWxMaOpenApiService
*/
WxMaOpenApiService getWxMaOpenApiService();
/**
* 小程序短剧管理
*
* @return getWxMaVodService
*/
WxMaVodService getWxMaVodService();
}
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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public abstract class BaseWxMaServiceImpl<H, P> 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<String, WxMaConfig> configMap = new HashMap<>();
private int retrySleepMillis = 1000;
Expand Down Expand Up @@ -664,4 +665,9 @@ public WxMaOrderShippingService getWxMaOrderShippingService() {
public WxMaOpenApiService getWxMaOpenApiService() {
return this.wxMaOpenApiService;
}
@Override
public WxMaVodService getWxMaVodService() {
return this.wxMaVodService;
}

}
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();

}
}
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);
}
}
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);
}
}
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);
}
}
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;


}
}
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);
}
}
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);
}
}
Loading

0 comments on commit af8928f

Please sign in to comment.