Commit 02711d27512e4fe143f03b05ec8aad6780c6e01e
1 parent
7c4f4998
修改审核信息返回接口和视频送审接口
Showing
4 changed files
with
76 additions
and
35 deletions
src/main/java/com/cnlive/shenhe/controller/VideosController.java
| ... | ... | @@ -7,10 +7,12 @@ import com.cnlive.shenhe.bean.ResponseBean; |
| 7 | 7 | import com.cnlive.shenhe.entity.ShySites; |
| 8 | 8 | import com.cnlive.shenhe.entity.ShyVideos; |
| 9 | 9 | import com.cnlive.shenhe.serviceImpl.VideosServiceImpl; |
| 10 | +import com.cnlive.shenhe.utils.AuditPass; | |
| 10 | 11 | import com.cnlive.shenhe.utils.CommonConst; |
| 11 | 12 | import com.cnlive.shenhe.utils.CommonUtils; |
| 12 | 13 | import com.cnlive.shenhe.utils.HttpUtil; |
| 13 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | +import org.springframework.beans.factory.annotation.Value; | |
| 14 | 16 | import org.springframework.stereotype.Controller; |
| 15 | 17 | import org.springframework.web.bind.annotation.*; |
| 16 | 18 | |
| ... | ... | @@ -29,6 +31,8 @@ import java.util.Map; |
| 29 | 31 | @Controller |
| 30 | 32 | @RequestMapping("/videos") |
| 31 | 33 | public class VideosController { |
| 34 | + | |
| 35 | + | |
| 32 | 36 | @Autowired |
| 33 | 37 | VideosServiceImpl videosService; |
| 34 | 38 | @PostMapping("/import") |
| ... | ... | @@ -47,12 +51,11 @@ public class VideosController { |
| 47 | 51 | List<String> asList = Arrays.asList(business); |
| 48 | 52 | if(asList.contains(CommonConst.BUSINESS_VIDEO+"")){ |
| 49 | 53 | shyVideos.setState(CommonConst.AUDIT_SUCCESS); |
| 50 | - getInfo("",0,"",""); | |
| 51 | - | |
| 54 | + AuditPass.auditPass(json.getString("videoId"),CommonConst.AUDIT_SUCCESS,"",""); | |
| 55 | + }else { | |
| 56 | + shyVideos.setState(CommonConst.AUDIT_INTT); | |
| 52 | 57 | } |
| 53 | 58 | } |
| 54 | - }else { | |
| 55 | - return new ResponseBean(ErrorEnum.PARAM_ERROR); | |
| 56 | 59 | } |
| 57 | 60 | //封装数据入库 |
| 58 | 61 | shyVideos.setVideo_id(json.getString("videoId")); |
| ... | ... | @@ -66,37 +69,28 @@ public class VideosController { |
| 66 | 69 | shyVideos.setSpid(Integer.parseInt(json.getString("spId"))); |
| 67 | 70 | int i = videosService.impotVideo(shyVideos); |
| 68 | 71 | if(i>0){ |
| 69 | - return new ResponseBean(); | |
| 72 | + return new ResponseBean(ErrorEnum.SUCCESS); | |
| 70 | 73 | }else { |
| 71 | 74 | return new ResponseBean(ErrorEnum.ERROR); |
| 72 | 75 | } |
| 73 | 76 | } |
| 74 | 77 | |
| 75 | - public String getInfo(String activity_id,int state,String attr_tags,String msg){ | |
| 76 | - String url ="http://mam.innerapi.cnlive.com/v1/inner/ShenHeInfo/shenheNotify"; | |
| 77 | - String platformKey ="AUDIT"; | |
| 78 | - String platformValue="10011438"; | |
| 79 | - String token = null; | |
| 80 | - try { | |
| 81 | - token = CommonUtils.md5(url+platformKey+platformValue); | |
| 82 | - } catch (NoSuchAlgorithmException e) { | |
| 83 | - e.printStackTrace(); | |
| 84 | - } catch (UnsupportedEncodingException e) { | |
| 85 | - e.printStackTrace(); | |
| 78 | + @RequestMapping("/shenheNotify") | |
| 79 | + @ResponseBody | |
| 80 | + public ResponseBean shenheInfo(String activity_id,int state,String attr_tags,String msg){ | |
| 81 | + String code = AuditPass.auditPass(activity_id, state, attr_tags, msg); | |
| 82 | + if(code.equals("-1")){ | |
| 83 | + return new ResponseBean(ErrorEnum.ERROR); | |
| 86 | 84 | } |
| 87 | - Map<String, String> params = new HashMap<>(); | |
| 88 | - params.put("activity_id",activity_id); | |
| 89 | - params.put("state",state+""); | |
| 90 | - params.put("attr_tags",attr_tags); | |
| 91 | - params.put("msg",msg); | |
| 92 | - HttpUtil httpUtil = HttpUtil.init(); | |
| 93 | - String URL =url+"platform="+platformKey+"&token="+token; | |
| 94 | - httpUtil.setParamMap(params); | |
| 95 | - Map<String, String> post = httpUtil.post(URL); | |
| 96 | - String result = JSON.toJSONString(post); | |
| 97 | - videosService.updateVideo(activity_id,state,attr_tags,msg); | |
| 98 | - return result; | |
| 85 | + int i = videosService.updateVideo(activity_id, state, attr_tags, msg); | |
| 86 | + if(i==0){ | |
| 87 | + return new ResponseBean(ErrorEnum.ERROR); | |
| 88 | + } | |
| 89 | + return new ResponseBean(ErrorEnum.SUCCESS); | |
| 99 | 90 | } |
| 100 | 91 | |
| 101 | 92 | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 102 | 96 | } | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/VideosServiceImpl.java
| 1 | 1 | package com.cnlive.shenhe.serviceImpl; |
| 2 | -import com.alibaba.fastjson.JSONObject; | |
| 3 | 2 | import com.cnlive.shenhe.entity.ShySites; |
| 4 | 3 | import com.cnlive.shenhe.entity.ShyVideos; |
| 5 | 4 | import com.cnlive.shenhe.mapper.ShySitesMapper; |
| 6 | 5 | import com.cnlive.shenhe.mapper.ShyVideosMapper; |
| 7 | -import com.cnlive.shenhe.utils.CommonConst; | |
| 8 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | -import org.springframework.data.domain.Example; | |
| 10 | 7 | import org.springframework.stereotype.Service; |
| 11 | 8 | |
| 12 | 9 | import java.util.List; |
| ... | ... | @@ -31,13 +28,14 @@ public class VideosServiceImpl { |
| 31 | 28 | List<ShySites> sitesList = shySitesMapper.select(shySites); |
| 32 | 29 | return sitesList; |
| 33 | 30 | } |
| 34 | - public void updateVideo(String activity_id,int state,String attr_tags,String msg){ | |
| 31 | + public int updateVideo(String activity_id,int state,String attr_tags,String msg){ | |
| 35 | 32 | ShyVideos shyVideos = new ShyVideos(); |
| 36 | 33 | shyVideos.setVideo_id(activity_id); |
| 34 | + Integer id = shyVideosMapper.select(shyVideos).get(0).getId(); | |
| 35 | + shyVideos.setId(id); | |
| 37 | 36 | shyVideos.setState(state); |
| 38 | 37 | shyVideos.setVideo_tags(attr_tags); |
| 39 | 38 | shyVideos.setMsg(msg); |
| 40 | - Example<ShyVideos> example = Example.of(shyVideos); | |
| 41 | - shyVideosMapper.updateByExample(shyVideos,example); | |
| 39 | + return shyVideosMapper.updateByPrimaryKey(shyVideos); | |
| 42 | 40 | } |
| 43 | 41 | } | ... | ... |
src/main/java/com/cnlive/shenhe/utils/AuditPass.java
0 → 100644
| 1 | +package com.cnlive.shenhe.utils; | |
| 2 | + | |
| 3 | +import org.springframework.beans.factory.annotation.Value; | |
| 4 | + | |
| 5 | +import java.io.UnsupportedEncodingException; | |
| 6 | +import java.security.NoSuchAlgorithmException; | |
| 7 | +import java.util.HashMap; | |
| 8 | +import java.util.Map; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * @Auther: chenhao | |
| 12 | + * @Date: 2018/12/3 16:00 | |
| 13 | + * @Description:如果是白名单直接审核通过 | |
| 14 | + */ | |
| 15 | +public class AuditPass { | |
| 16 | + | |
| 17 | + @Value("http://mam.innerapi.cnlive.com/v1/inner/ShenHeInfo/shenheNotify") | |
| 18 | + private static String url; | |
| 19 | + @Value("AUDIT") | |
| 20 | + private static String platformKey; | |
| 21 | + @Value("10011438") | |
| 22 | + private static String platformValue; | |
| 23 | + public static String auditPass(String activity_id,int state,String attr_tags,String msg){ | |
| 24 | + String token = null; | |
| 25 | + try { | |
| 26 | + token = CommonUtils.md5(url+platformKey+platformValue); | |
| 27 | + } catch (NoSuchAlgorithmException e) { | |
| 28 | + e.printStackTrace(); | |
| 29 | + } catch (UnsupportedEncodingException e) { | |
| 30 | + e.printStackTrace(); | |
| 31 | + } | |
| 32 | + Map<String, String> params = new HashMap<>(); | |
| 33 | + params.put("activity_id",activity_id); | |
| 34 | + params.put("state",state+""); | |
| 35 | + params.put("attr_tags",attr_tags); | |
| 36 | + params.put("msg",msg); | |
| 37 | + HttpUtil httpUtil = HttpUtil.init(); | |
| 38 | + String URL =url+"platform="+platformKey+"&token="+token; | |
| 39 | + httpUtil.setParamMap(params); | |
| 40 | + Map<String, String> post = httpUtil.post(URL); | |
| 41 | + String code = post.get("code"); | |
| 42 | + return code; | |
| 43 | + } | |
| 44 | +} | ... | ... |
src/main/resources/application.properties
| ... | ... | @@ -13,4 +13,9 @@ mybatis.type-aliases-package=com.cnlive.shenhe.entity |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | sync_users_api=http://api.cnlive.com/open/api2/inner2/shenhe/getuser |
| 16 | -sync_users_app_key=314a9dd4-a9b7-4c12-bbbe-1150a36491ae | |
| 17 | 16 | \ No newline at end of file |
| 17 | +sync_users_app_key=314a9dd4-a9b7-4c12-bbbe-1150a36491ae | |
| 18 | + | |
| 19 | + | |
| 20 | +url=http://mam.innerapi.cnlive.com/v1/inner/ShenHeInfo/shenheNotify | |
| 21 | +SplatformKey =AUDIT; | |
| 22 | +platformValue=10011438; | |
| 18 | 23 | \ No newline at end of file | ... | ... |