|
@@ -2,6 +2,10 @@ package cn.com.ctop.toutiao.modules.material.controller;
|
|
|
|
|
|
import cn.com.ctop.toutiao.modules.material.entity.ByteDanceVideoInfo;
|
|
import cn.com.ctop.toutiao.modules.material.entity.ByteDanceVideoInfo;
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceVideoInfoService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceVideoInfoService;
|
|
|
|
+import cn.com.ctop.toutiao.modules.tool.callback.AuthTokenUtil;
|
|
|
|
+import cn.com.ctop.toutiao.modules.tool.callback.BaseResponse;
|
|
|
|
+import cn.com.ctop.toutiao.modules.tool.callback.CallbackResponse;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -12,9 +16,18 @@ import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.io.IOException;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -162,4 +175,33 @@ public class ByteDanceVideoInfoController {
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 广告违规素材推送
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/illegalVideosPush", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
|
+ public CallbackResponse illegalVideosPush(HttpServletRequest request,
|
|
|
|
+ @RequestParam(value = "challenge", defaultValue = "0") int challenge,
|
|
|
|
+ @RequestParam(value = "event", defaultValue = "") String event) throws IOException {
|
|
|
|
+ log.info("广告违规素材推送--------------------------challenge= " + challenge + ";event= " + event);
|
|
|
|
+ // 处理 verify 事件
|
|
|
|
+ if (null != event && event.equals("verify_webhook")) {
|
|
|
|
+ return new CallbackResponse(BaseResponse.ok(), challenge);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 订阅任务配置页面的 "验证密钥"
|
|
|
|
+ String secretKey = "156a5d76ad354b43865ef57e5e416ca7";
|
|
|
|
+ // 数据接收,验证消息
|
|
|
|
+ AuthTokenUtil.InputStreamCacher cacher = new AuthTokenUtil.InputStreamCacher(request.getInputStream());
|
|
|
|
+ boolean isValidToken = AuthTokenUtil.isValidToken(secretKey, cacher, request.getHeader("X-Open-Signature"));
|
|
|
|
+ log.info("isValidToken=" + isValidToken);
|
|
|
|
+ if (!isValidToken) {
|
|
|
|
+ return new CallbackResponse(new BaseResponse(400, "invalid token"), 0);
|
|
|
|
+ }
|
|
|
|
+ JSONObject result = JSONObject.parseObject(new String(AuthTokenUtil.readAsBytes(cacher)));
|
|
|
|
+ System.out.println("返回结果:" + result.toJSONString());
|
|
|
|
+ // 数据处理流程...
|
|
|
|
+ return new CallbackResponse(BaseResponse.ok(), 0);
|
|
|
|
+ }
|
|
}
|
|
}
|