Commit 2eec04965f0d0458c698ad5a2799093e903e5969
1 parent
cff389be
点播回调参数修改
Showing
2 changed files
with
16 additions
and
5 deletions
src/main/java/com/cnlive/shenhe/api/VideosControllerApi.java
| ... | ... | @@ -10,6 +10,8 @@ import com.cnlive.shenhe.serviceImpl.VideosServiceImpl; |
| 10 | 10 | import com.cnlive.shenhe.utils.AuditPass; |
| 11 | 11 | import com.cnlive.shenhe.utils.CommonConst; |
| 12 | 12 | import com.cnlive.shenhe.utils.CommonUtils; |
| 13 | +import org.slf4j.Logger; | |
| 14 | +import org.slf4j.LoggerFactory; | |
| 13 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | 16 | import org.springframework.stereotype.Controller; |
| 15 | 17 | import org.springframework.web.bind.annotation.PostMapping; |
| ... | ... | @@ -28,6 +30,7 @@ import java.util.List; |
| 28 | 30 | @Controller |
| 29 | 31 | @RequestMapping("/api/videos") |
| 30 | 32 | public class VideosControllerApi { |
| 33 | + private static Logger logger = LoggerFactory.getLogger(VideosControllerApi.class); | |
| 31 | 34 | @Autowired |
| 32 | 35 | AuditPass Pass; |
| 33 | 36 | @Autowired |
| ... | ... | @@ -38,19 +41,22 @@ public class VideosControllerApi { |
| 38 | 41 | @PostMapping("/import") |
| 39 | 42 | @ResponseBody |
| 40 | 43 | public ResponseBean impotVideo(@RequestBody JSONObject json) { |
| 44 | + logger.info("点播入库,json====="+json.toJSONString()); | |
| 41 | 45 | ShySites shySites = new ShySites(); |
| 42 | 46 | ShyVideos shyVideos = new ShyVideos(); |
| 43 | 47 | shyVideos.setState(CommonConst.AUDIT_INTT); |
| 44 | 48 | //判断是否白名单 |
| 45 | 49 | shySites.setSpid(json.getInteger("spId")); |
| 46 | 50 | List<ShySites> shySitesList = videosService.getBusiness(shySites); |
| 51 | + String videoId = json.getString("videoId"); | |
| 47 | 52 | if (!shySitesList.isEmpty()) { |
| 48 | 53 | if (CommonUtils.isNotEmpty(shySitesList.get(0).getWrite_business())) { |
| 49 | 54 | String write_business = shySitesList.get(0).getWrite_business(); |
| 50 | 55 | String[] business = write_business.split(","); |
| 51 | 56 | List<String> asList = Arrays.asList(business); |
| 52 | 57 | if (asList.contains(CommonConst.BUSINESS_VIDEO + "")) { |
| 53 | - JSONObject result = Pass.auditPass(json.getString("videoId"), 3, "", ""); | |
| 58 | + logger.info("白名单回调通过:videoId==="+videoId); | |
| 59 | + JSONObject result = Pass.auditPass(videoId, 3, "", ""); | |
| 54 | 60 | Integer code = result.getInteger("code"); |
| 55 | 61 | if (code != 0) { |
| 56 | 62 | return new ResponseBean(code, result.getString("msg")); |
| ... | ... | @@ -60,7 +66,7 @@ public class VideosControllerApi { |
| 60 | 66 | } |
| 61 | 67 | } |
| 62 | 68 | //封装数据入库 |
| 63 | - shyVideos.setVideo_id(json.getString("videoId")); | |
| 69 | + shyVideos.setVideo_id(videoId); | |
| 64 | 70 | shyVideos.setVideo_title(json.getString("videoTitle")); |
| 65 | 71 | shyVideos.setVideo_url(json.getString("videoUrl")); |
| 66 | 72 | String videoCoverUrl = json.getString("videoCoverUrl"); | ... | ... |
src/main/java/com/cnlive/shenhe/utils/AuditPass.java
| 1 | 1 | package com.cnlive.shenhe.utils; |
| 2 | 2 | |
| 3 | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | +import org.slf4j.Logger; | |
| 5 | +import org.slf4j.LoggerFactory; | |
| 4 | 6 | import org.springframework.beans.factory.annotation.Value; |
| 5 | 7 | import org.springframework.stereotype.Component; |
| 6 | 8 | |
| ... | ... | @@ -16,7 +18,7 @@ import java.util.Map; |
| 16 | 18 | */ |
| 17 | 19 | @Component |
| 18 | 20 | public class AuditPass { |
| 19 | - | |
| 21 | + private static Logger logger = LoggerFactory.getLogger(AuditPass.class); | |
| 20 | 22 | @Value("${url}") |
| 21 | 23 | private String url;//点播url |
| 22 | 24 | @Value("${platformKey}") |
| ... | ... | @@ -35,6 +37,7 @@ public class AuditPass { |
| 35 | 37 | * @return |
| 36 | 38 | */ |
| 37 | 39 | public JSONObject auditPass(String video_id,int state,String attr_tags,String msg){ |
| 40 | + logger.info("点播回调:video_id:{},state:{},attr_tags:{},msg:{}",video_id,state,attr_tags,msg); | |
| 38 | 41 | String token = null; |
| 39 | 42 | try { |
| 40 | 43 | token = CommonUtils.md5(url+platformKey+platformValue); |
| ... | ... | @@ -43,14 +46,16 @@ public class AuditPass { |
| 43 | 46 | } catch (UnsupportedEncodingException e) { |
| 44 | 47 | e.printStackTrace(); |
| 45 | 48 | } |
| 46 | - Map<String, String> params = new HashMap<>(); | |
| 49 | + Map<String, String> paramsMap = new HashMap<>(); | |
| 50 | + JSONObject params = new JSONObject(); | |
| 47 | 51 | params.put("video_id",video_id); |
| 48 | 52 | params.put("state",state+""); |
| 49 | 53 | params.put("attr_tags",attr_tags); |
| 50 | 54 | params.put("msg",msg); |
| 55 | + paramsMap.put("params",params.toJSONString()); | |
| 51 | 56 | HttpUtil httpUtil = HttpUtil.init(); |
| 52 | 57 | String URL =url+"?platform="+platformKey+"&token="+token; |
| 53 | - httpUtil.setParamMap(params); | |
| 58 | + httpUtil.setParamMap(paramsMap); | |
| 54 | 59 | Map<String, String> post = httpUtil.post(URL); |
| 55 | 60 | return JSONObject.parseObject(post.get("result")); |
| 56 | 61 | } | ... | ... |