posting-task commit

This commit is contained in:
danmo 2024-04-11 14:24:07 +08:00
parent ef38a2f990
commit d782e9cc17
14 changed files with 786 additions and 5 deletions

View File

@ -1,6 +1,6 @@
package com.dyj.common.enums;
public enum DyConfigEnum {
public enum DyUrlPathEnum {
/**
* 域名
@ -266,6 +266,23 @@ public enum DyConfigEnum {
*/
SCHEMA_GET_LIVE("schemaGetLive","/api/douyin/v1/schema/get_live"),
/**
* 创建投稿任务
*/
CREATE_POSTING_TASK("createPostingTask","/task/posting/create"),
/**
* 绑定视频
*/
POSTING_TASK_BIND_VIDEO("postingTaskBindVideo","/task/posting/bind_video"),
/**
* 核销投稿任务
*/
POSTING_TASK_CONFIRM("postingTaskConfirm","/task/posting/user"),
/**
* 查询视频基础信息
*/
QUERY_VIDEO_BASIC_INFO("queryVideoBasicInfo","/api/douyin/v1/video/video_basic_info"),
;
@ -273,7 +290,7 @@ public enum DyConfigEnum {
private String key;
private String value;
DyConfigEnum(String key, String value) {
DyUrlPathEnum(String key, String value) {
this.key = key;
this.value = value;
}
@ -295,7 +312,7 @@ public enum DyConfigEnum {
}
public static String getValueByKey(String key) {
for (DyConfigEnum e : DyConfigEnum.values()) {
for (DyUrlPathEnum e : DyUrlPathEnum.values()) {
if (e.getKey().equals(key)) {
return e.getValue();
}

View File

@ -2,7 +2,7 @@ package com.dyj.spring;
import com.dtflys.forest.config.ForestConfiguration;
import com.dyj.common.config.DyConfiguration;
import com.dyj.common.enums.DyConfigEnum;
import com.dyj.common.enums.DyUrlPathEnum;
import com.dyj.common.handler.RequestHandler;
import com.dyj.common.service.IAgentConfigService;
import com.dyj.common.service.IAgentTokenService;
@ -110,7 +110,7 @@ public class DyConfigurationRegister implements ResourceLoaderAware, BeanPostPro
forestConfiguration.setLogResponseStatus(forestProperties.isLogResponseStatus());
forestConfiguration.setLogResponseContent(forestProperties.isLogResponseContent());
forestConfiguration.setAsyncMode(forestProperties.getAsyncMode());
for (DyConfigEnum value : DyConfigEnum.values()) {
for (DyUrlPathEnum value : DyUrlPathEnum.values()) {
forestProperties.getVariables().put(value.getKey(), value.getValue());
}
forestConfiguration.setVariables(forestProperties.getVariables());

View File

@ -601,4 +601,38 @@ public class DyWebClient {
return new SchemaHandler(configuration().getAgentConfigService().loadAgentByTenantId(tenantId, clientKey)).getLive(openId, account, expireAt);
}
/**
* 创建投稿任务
*
* @param query 入参
* @return DyResult<PostingTaskVo>
*/
public DyResult<PostingTaskVo> createPostingTask(CreatePostingTaskQuery query){
return new PostingTaskHandler(configuration().getAgentConfigService().loadAgentByTenantId(tenantId, clientKey)).createPostingTask(query);
}
/**
* 绑定视频
* @param query 入参
* @return DyResult<BaseVo>
*/
public DyResult<BaseVo> postingTaskBindVideo(PostingTaskQuery query){
return new PostingTaskHandler(configuration().getAgentConfigService().loadAgentByTenantId(tenantId, clientKey)).postingTaskBindVideo(query);
}
/**
* 核销投稿任务
* @param query 入参
* @return DyResult<ConfirmPostingTaskVo>
*/
public DyResult<ConfirmPostingTaskVo> confirmPostingTask(ConfirmPostingTaskQuery query){
return new PostingTaskHandler(configuration().getAgentConfigService().loadAgentByTenantId(tenantId, clientKey)).confirmPostingTask(query);
}
/**
* 查询视频基础信息
* @param query 入参
* @return DyResult<VideoBasicListVo>
*/
public DyResult<VideoBasicListVo> queryVideoBasicInfo(VideoDataQuery query){
return new PostingTaskHandler(configuration().getAgentConfigService().loadAgentByTenantId(tenantId, clientKey)).queryVideoBasicInfo(query);
}
}

View File

@ -0,0 +1,60 @@
package com.dyj.web.client;
import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.JSONBody;
import com.dtflys.forest.annotation.Post;
import com.dtflys.forest.backend.ContentType;
import com.dyj.common.domain.DyResult;
import com.dyj.web.domain.query.ConfirmPostingTaskQuery;
import com.dyj.web.domain.query.CreatePostingTaskQuery;
import com.dyj.web.domain.query.PostingTaskQuery;
import com.dyj.web.domain.query.VideoDataQuery;
import com.dyj.web.domain.vo.BaseVo;
import com.dyj.web.domain.vo.ConfirmPostingTaskVo;
import com.dyj.web.domain.vo.PostingTaskVo;
import com.dyj.web.domain.vo.VideoBasicListVo;
import com.dyj.web.interceptor.ClientTokenInterceptor;
import com.dyj.web.interceptor.TokenHeaderInterceptor;
/**
* 投稿任务
*
* @author danmo
* @date 2024/04/09 14:08
*/
@BaseRequest(baseURL = "${domain}", contentType = ContentType.APPLICATION_JSON)
public interface PostingTaskClient {
/**
* 创建投稿任务
*
* @param query 入参
* @return DyResult<PostingTaskVo>
*/
@Post(value = "${createPostingTask}", interceptor = ClientTokenInterceptor.class)
DyResult<PostingTaskVo> createPostingTask(@JSONBody CreatePostingTaskQuery query);
/**
* 绑定视频
* @param query 入参
* @return DyResult<BaseVo>
*/
@Post(value = "${postingTaskBindVideo}", interceptor = TokenHeaderInterceptor.class)
DyResult<BaseVo> postingTaskBindVideo(@JSONBody PostingTaskQuery query);
/**
* 核销投稿任务
* @param query 入参
* @return DyResult<ConfirmPostingTaskVo>
*/
@Post(value = "${postingTaskConfirm}", interceptor = ClientTokenInterceptor.class)
DyResult<ConfirmPostingTaskVo> postingTaskConfirm(@JSONBody ConfirmPostingTaskQuery query);
/**
* 查询视频基础信息
* @param query 入参
* @return DyResult<VideoBasicListVo>
*/
@Post(value = "${queryVideoBasicInfo}", interceptor = TokenHeaderInterceptor.class)
DyResult<VideoBasicListVo> queryVideoBasicInfo(@JSONBody VideoDataQuery query);
}

View File

@ -0,0 +1,123 @@
package com.dyj.web.domain;
/**
* @author danmo
* @date 2024-04-11 14:12
**/
public class VideoBasicInfo {
/**
* 视频id
*/
private String item_id;
/**
* 视频真实id
*/
private String video_id;
/**
* 媒体类型
* NONE=0
* TEXT=1
* PIC=2
* GIF=3
* VIDEO=4
* PIC_LIST=5
* STORY=1
* 1VR=12
* FORWARD=21
* STORY_LIVE=22
* STORY_PIC=23
*/
private Integer media_type;
/**
* 视频标题
*/
private String title;
/**
* 视频状态2:不适宜公开;4:审核中;5:公开视频
*/
private Integer video_status;
/**
* 视频封面
*/
private String cover;
/**
* 视频创建时间戳
*/
private Long create_time;
public String getItem_id() {
return item_id;
}
public void setItem_id(String item_id) {
this.item_id = item_id;
}
public String getVideo_id() {
return video_id;
}
public void setVideo_id(String video_id) {
this.video_id = video_id;
}
public Integer getMedia_type() {
return media_type;
}
public void setMedia_type(Integer media_type) {
this.media_type = media_type;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Integer getVideo_status() {
return video_status;
}
public void setVideo_status(Integer video_status) {
this.video_status = video_status;
}
public String getCover() {
return cover;
}
public void setCover(String cover) {
this.cover = cover;
}
public Long getCreate_time() {
return create_time;
}
public void setCreate_time(Long create_time) {
this.create_time = create_time;
}
@Override
public String toString() {
return "VideoBasicInfo{" +
"item_id='" + item_id + '\'' +
", video_id='" + video_id + '\'' +
", media_type=" + media_type +
", title='" + title + '\'' +
", video_status=" + video_status +
", cover='" + cover + '\'' +
", create_time=" + create_time +
'}';
}
}

View File

@ -0,0 +1,107 @@
package com.dyj.web.domain.query;
/**
* @author danmo
* @date 2024-04-11 14:00
**/
public class ConfirmPostingTaskQuery extends UserInfoQuery{
/**
* 任务ID
*/
private String task_id;
/**
* 目标用户open_id
*/
private String target_open_id;
/**
* 视频ID
*/
private String video_id;
public String getTask_id() {
return task_id;
}
public void setTask_id(String task_id) {
this.task_id = task_id;
}
public String getTarget_open_id() {
return target_open_id;
}
public void setTarget_open_id(String target_open_id) {
this.target_open_id = target_open_id;
}
public String getVideo_id() {
return video_id;
}
public void setVideo_id(String video_id) {
this.video_id = video_id;
}
public static ConfirmPostingTaskQueryBuild builder() {
return new ConfirmPostingTaskQueryBuild();
}
public static class ConfirmPostingTaskQueryBuild {
private String taskId;
private String targetOpenId;
private String videoId;
private Integer tenantId;
private String clientKey;
private String openId;
public ConfirmPostingTaskQueryBuild taskId(String taskId) {
this.taskId = taskId;
return this;
}
public ConfirmPostingTaskQueryBuild targetOpenId(String targetOpenId) {
this.targetOpenId = targetOpenId;
return this;
}
public ConfirmPostingTaskQueryBuild videoId(String videoId) {
this.videoId = videoId;
return this;
}
public ConfirmPostingTaskQueryBuild tenantId(Integer tenantId) {
this.tenantId = tenantId;
return this;
}
public ConfirmPostingTaskQueryBuild clientKey(String clientKey) {
this.clientKey = clientKey;
return this;
}
public ConfirmPostingTaskQueryBuild openId(String openId) {
this.openId = openId;
return this;
}
public ConfirmPostingTaskQuery build() {
ConfirmPostingTaskQuery postingTaskQuery = new ConfirmPostingTaskQuery();
postingTaskQuery.setTask_id(taskId);
postingTaskQuery.setTarget_open_id(targetOpenId);
postingTaskQuery.setVideo_id(videoId);
postingTaskQuery.setTenantId(tenantId);
postingTaskQuery.setClientKey(clientKey);
postingTaskQuery.setOpen_id(openId);
return postingTaskQuery;
}
}
@Override
public String toString() {
return "ConfirmPostingTaskQuery{" +
"task_id='" + task_id + '\'' +
", target_open_id='" + target_open_id + '\'' +
", video_id='" + video_id + '\'' +
", open_id='" + open_id + '\'' +
", tenantId=" + tenantId +
", clientKey='" + clientKey + '\'' +
'}';
}
}

View File

@ -0,0 +1,123 @@
package com.dyj.web.domain.query;
/**
* @author danmo
* @date 2024-04-11 13:51
**/
public class CreatePostingTaskQuery extends BaseQuery {
/**
* 开始时间秒级时间戳
*/
private Long start_time;
/**
* 开始时间秒级时间戳
*/
private Long end_time;
/**
* 任务名称长度不超过50个字符
*/
private String task_name;
/**
* 任务条件
*/
private PostingTaskCondition task_condition;
public Long getStart_time() {
return start_time;
}
public void setStart_time(Long start_time) {
this.start_time = start_time;
}
public Long getEnd_time() {
return end_time;
}
public void setEnd_time(Long end_time) {
this.end_time = end_time;
}
public String getTask_name() {
return task_name;
}
public void setTask_name(String task_name) {
this.task_name = task_name;
}
public PostingTaskCondition getTask_condition() {
return task_condition;
}
public void setTask_condition(PostingTaskCondition task_condition) {
this.task_condition = task_condition;
}
public static CreatePostingTaskQueryBuild builder(){
return new CreatePostingTaskQueryBuild();
}
public static class CreatePostingTaskQueryBuild{
private String taskName;
private Long startTime;
private Long endTime;
private PostingTaskCondition taskCondition;
private String clientKey;
private Integer tenantId;
public CreatePostingTaskQueryBuild taskName(String taskName) {
this.taskName = taskName;
return this;
}
public CreatePostingTaskQueryBuild startTime(Long startTime) {
this.startTime = startTime;
return this;
}
public CreatePostingTaskQueryBuild endTime(Long endTime) {
this.endTime = endTime;
return this;
}
public CreatePostingTaskQueryBuild taskCondition(PostingTaskCondition taskCondition) {
this.taskCondition = taskCondition;
return this;
}
public CreatePostingTaskQueryBuild clientKey(String clientKey) {
this.clientKey = clientKey;
return this;
}
public CreatePostingTaskQueryBuild tenantId(Integer tenantId) {
this.tenantId = tenantId;
return this;
}
public CreatePostingTaskQuery build(){
CreatePostingTaskQuery createPostingTaskQuery = new CreatePostingTaskQuery();
createPostingTaskQuery.setStart_time(startTime);
createPostingTaskQuery.setEnd_time(endTime);
createPostingTaskQuery.setTask_name(taskName);
createPostingTaskQuery.setTask_condition(taskCondition);
createPostingTaskQuery.setTenantId(tenantId);
createPostingTaskQuery.setClientKey(clientKey);
return createPostingTaskQuery;
}
}
@Override
public String toString() {
return "CreatePostingTaskQuery{" +
"start_time=" + start_time +
", end_time=" + end_time +
", task_name='" + task_name + '\'' +
", task_condition=" + task_condition +
", tenantId=" + tenantId +
", clientKey='" + clientKey + '\'' +
'}';
}
}

View File

@ -0,0 +1,60 @@
package com.dyj.web.domain.query;
/**
* @author danmo
* @date 2024-04-11 13:52
**/
public class PostingTaskCondition {
/**
* 收藏:collection
* 评论:comment
* 点赞:digg
* 播放:play
* 分享:share
* 下载:download
*/
private String condition;
/**
* 右区间, 播放数:最大为1000w, 其他:最大10w
*/
private Integer max_value;
/**
* 左区间, 最小为0
*/
private Integer min_value;
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
public Integer getMax_value() {
return max_value;
}
public void setMax_value(Integer max_value) {
this.max_value = max_value;
}
public Integer getMin_value() {
return min_value;
}
public void setMin_value(Integer min_value) {
this.min_value = min_value;
}
@Override
public String toString() {
return "PostingTaskCondition{" +
"condition='" + condition + '\'' +
", max_value=" + max_value +
", min_value=" + min_value +
'}';
}
}

View File

@ -0,0 +1,87 @@
package com.dyj.web.domain.query;
/**
* @author danmo
* @date 2024-04-11 14:00
**/
public class PostingTaskQuery extends UserInfoQuery{
/**
* 任务ID
*/
private String task_id;
/**
* 视频ID
*/
private String video_id;
public String getTask_id() {
return task_id;
}
public void setTask_id(String task_id) {
this.task_id = task_id;
}
public String getVideo_id() {
return video_id;
}
public void setVideo_id(String video_id) {
this.video_id = video_id;
}
public static PostingTaskQueryBuild builder() {
return new PostingTaskQueryBuild();
}
public static class PostingTaskQueryBuild {
private String taskId;
private String videoId;
private Integer tenantId;
private String clientKey;
private String openId;
public PostingTaskQueryBuild taskId(String taskId) {
this.taskId = taskId;
return this;
}
public PostingTaskQueryBuild videoId(String videoId) {
this.videoId = videoId;
return this;
}
public PostingTaskQueryBuild tenantId(Integer tenantId) {
this.tenantId = tenantId;
return this;
}
public PostingTaskQueryBuild clientKey(String clientKey) {
this.clientKey = clientKey;
return this;
}
public PostingTaskQueryBuild openId(String openId) {
this.openId = openId;
return this;
}
public PostingTaskQuery build() {
PostingTaskQuery postingTaskQuery = new PostingTaskQuery();
postingTaskQuery.setTask_id(taskId);
postingTaskQuery.setVideo_id(videoId);
postingTaskQuery.setTenantId(tenantId);
postingTaskQuery.setClientKey(clientKey);
postingTaskQuery.setOpen_id(openId);
return postingTaskQuery;
}
}
@Override
public String toString() {
return "PostingTaskQuery{" +
"task_id='" + task_id + '\'' +
", video_id='" + video_id + '\'' +
", open_id='" + open_id + '\'' +
", tenantId=" + tenantId +
", clientKey='" + clientKey + '\'' +
'}';
}
}

View File

@ -0,0 +1,27 @@
package com.dyj.web.domain.vo;
/**
* @author danmo
* @date 2024-04-11 14:08
**/
public class ConfirmPostingTaskVo extends BaseVo{
private Boolean result;
public Boolean getResult() {
return result;
}
public void setResult(Boolean result) {
this.result = result;
}
@Override
public String toString() {
return "ConfirmPostingTaskVo{" +
"result=" + result +
", description='" + description + '\'' +
", error_code=" + error_code +
'}';
}
}

View File

@ -0,0 +1,44 @@
package com.dyj.web.domain.vo;
/**
* @author danmo
* @date 2024-04-11 13:57
**/
public class PostingTaskVo extends BaseVo{
/**
* 任务id
*/
private String task_id;
/**
* 任务状态 1-进行中2-未开始3-已过期
*/
private String task_status;
public String getTask_id() {
return task_id;
}
public void setTask_id(String task_id) {
this.task_id = task_id;
}
public String getTask_status() {
return task_status;
}
public void setTask_status(String task_status) {
this.task_status = task_status;
}
@Override
public String toString() {
return "PostingTaskVo{" +
"task_id='" + task_id + '\'' +
", task_status='" + task_status + '\'' +
", description='" + description + '\'' +
", error_code=" + error_code +
'}';
}
}

View File

@ -0,0 +1,31 @@
package com.dyj.web.domain.vo;
import com.dyj.web.domain.VideoBasicInfo;
import java.util.List;
/**
* @author danmo
* @date 2024-04-11 14:11
**/
public class VideoBasicListVo extends BaseVo {
private List<VideoBasicInfo> list;
public List<VideoBasicInfo> getList() {
return list;
}
public void setList(List<VideoBasicInfo> list) {
this.list = list;
}
@Override
public String toString() {
return "VideoBasicListVo{" +
"list=" + list +
", description='" + description + '\'' +
", error_code=" + error_code +
'}';
}
}

View File

@ -52,6 +52,10 @@ public abstract class AbstractWebHandler {
return SpringUtils.getBean(SchemaClient.class);
}
protected PostingTaskClient getPostingTaskClient() {
return SpringUtils.getBean(PostingTaskClient.class);
}
void setBaseQuery(BaseQuery query){
query.setTenantId(agentConfiguration.getTenantId());
query.setClientKey(agentConfiguration.getClientKey());

View File

@ -0,0 +1,64 @@
package com.dyj.web.handler;
import com.dtflys.forest.annotation.JSONBody;
import com.dyj.common.config.AgentConfiguration;
import com.dyj.common.domain.DyResult;
import com.dyj.web.domain.query.ConfirmPostingTaskQuery;
import com.dyj.web.domain.query.CreatePostingTaskQuery;
import com.dyj.web.domain.query.PostingTaskQuery;
import com.dyj.web.domain.query.VideoDataQuery;
import com.dyj.web.domain.vo.BaseVo;
import com.dyj.web.domain.vo.ConfirmPostingTaskVo;
import com.dyj.web.domain.vo.PostingTaskVo;
import com.dyj.web.domain.vo.VideoBasicListVo;
/**
* @author danmo
* @date 2024-04-11 14:18
**/
public class PostingTaskHandler extends AbstractWebHandler{
public PostingTaskHandler(AgentConfiguration agentConfiguration) {
super(agentConfiguration);
}
/**
* 创建投稿任务
*
* @param query 入参
* @return DyResult<PostingTaskVo>
*/
public DyResult<PostingTaskVo> createPostingTask(CreatePostingTaskQuery query){
setBaseQuery(query);
return getPostingTaskClient().createPostingTask(query);
}
/**
* 绑定视频
* @param query 入参
* @return DyResult<BaseVo>
*/
public DyResult<BaseVo> postingTaskBindVideo(PostingTaskQuery query){
setBaseQuery(query);
return getPostingTaskClient().postingTaskBindVideo(query);
}
/**
* 核销投稿任务
* @param query 入参
* @return DyResult<ConfirmPostingTaskVo>
*/
public DyResult<ConfirmPostingTaskVo> confirmPostingTask(ConfirmPostingTaskQuery query){
setBaseQuery(query);
return getPostingTaskClient().postingTaskConfirm(query);
}
/**
* 查询视频基础信息
* @param query 入参
* @return DyResult<VideoBasicListVo>
*/
public DyResult<VideoBasicListVo> queryVideoBasicInfo(VideoDataQuery query){
setBaseQuery(query);
return getPostingTaskClient().queryVideoBasicInfo(query);
}
}