VideosController.java
3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.cnlive.shenhe.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.bean.ErrorEnum;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.entity.ShySites;
import com.cnlive.shenhe.entity.ShyVideos;
import com.cnlive.shenhe.serviceImpl.VideosServiceImpl;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.CommonUtils;
import com.cnlive.shenhe.utils.HttpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Auther: chenhao
* @Date: 2018/11/30 14:22
* @Description:视频送审接口
*/
@Controller
@RequestMapping("/videos")
public class VideosController {
@Autowired
VideosServiceImpl videosService;
@PostMapping("/import")
@ResponseBody
public ResponseBean impotVideo(@RequestBody JSONObject json){
ShySites shySites = new ShySites();
ShyVideos shyVideos = new ShyVideos();
shyVideos.setState(CommonConst.AUDIT_INTT);
//判断是否白名单
shySites.setSpid(json.getInteger("spId"));
List<ShySites> shySitesList = videosService.getBusiness(shySites);
if(!shySitesList.isEmpty()){
if(!shySitesList.get(0).getWrite_business().isEmpty()){
String write_business = shySitesList.get(0).getWrite_business();
String[] business = write_business.split(",");
List<String> asList = Arrays.asList(business);
if(asList.contains(CommonConst.BUSINESS_VIDEO+"")){
shyVideos.setState(CommonConst.AUDIT_SUCCESS);
getInfo("",0,"","");
}
}
}else {
return new ResponseBean(ErrorEnum.PARAM_ERROR);
}
//封装数据入库
shyVideos.setVideo_id(json.getString("videoId"));
shyVideos.setVideo_title(json.getString("videoTitle"));
shyVideos.setVideo_url(json.getString("videoUrl"));
shyVideos.setVideo_imgs(json.getString("videoCoverUrl"));
shyVideos.setVideo_desc(json.getString("videoIntro"));
shyVideos.setVideo_keyword(json.getString("videoKeyword"));
shyVideos.setVideo_priority(json.getString("priority"));
shyVideos.setCallback(json.getString("callback"));
shyVideos.setSpid(Integer.parseInt(json.getString("spId")));
int i = videosService.impotVideo(shyVideos);
if(i>0){
return new ResponseBean();
}else {
return new ResponseBean(ErrorEnum.ERROR);
}
}
public String getInfo(String activity_id,int state,String attr_tags,String msg){
String url ="http://mam.innerapi.cnlive.com/v1/inner/ShenHeInfo/shenheNotify";
String platformKey ="AUDIT";
String platformValue="10011438";
String token = null;
try {
token = CommonUtils.md5(url+platformKey+platformValue);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
Map<String, String> params = new HashMap<>();
params.put("activity_id",activity_id);
params.put("state",state+"");
params.put("attr_tags",attr_tags);
params.put("msg",msg);
HttpUtil httpUtil = HttpUtil.init();
String URL =url+"platform="+platformKey+"&token="+token;
httpUtil.setParamMap(params);
Map<String, String> post = httpUtil.post(URL);
String result = JSON.toJSONString(post);
videosService.updateVideo(activity_id,state,attr_tags,msg);
return result;
}
}