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