VideosControllerApi.java
3.69 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
package com.cnlive.shenhe.api;
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.UsersServiceImpl;
import com.cnlive.shenhe.serviceImpl.VideosServiceImpl;
import com.cnlive.shenhe.utils.AuditPass;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.CommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Arrays;
import java.util.List;
/**
* @Auther: chenhao
* @Date: 2018/12/6 11:17
* @Description: 视频送审接口
*/
@Controller
@RequestMapping("/api/videos")
public class VideosControllerApi {
private static Logger logger = LoggerFactory.getLogger(VideosControllerApi.class);
@Autowired
AuditPass Pass;
@Autowired
VideosServiceImpl videosService;
@Autowired
UsersServiceImpl usersService;
@PostMapping("/import")
@ResponseBody
public ResponseBean impotVideo(@RequestBody JSONObject json) {
logger.info("点播入库,json====="+json.toJSONString());
ShySites shySites = new ShySites();
ShyVideos shyVideos = new ShyVideos();
shyVideos.setState(CommonConst.AUDIT_INTT);
//判断是否白名单
shySites.setSpid(json.getInteger("spId"));
List<ShySites> shySitesList = videosService.getBusiness(shySites);
String videoId = json.getString("videoId");
if (!shySitesList.isEmpty()) {
if (CommonUtils.isNotEmpty(shySitesList.get(0).getWrite_business())) {
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 + "")) {
logger.info("白名单回调通过:videoId==="+videoId);
JSONObject result = Pass.auditPass(videoId, 3, "", "");
Integer code = result.getInteger("code");
if (code != 0) {
return new ResponseBean(code, result.getString("msg"));
}
shyVideos.setState(CommonConst.AUDIT_SUCCESS);
}
}
}
//封装数据入库
shyVideos.setVideo_id(videoId);
shyVideos.setVideo_title(json.getString("videoTitle"));
shyVideos.setVideo_url(json.getString("videoUrl"));
String videoCoverUrl = json.getString("videoCoverUrl");
shyVideos.setVideo_imgs(videoCoverUrl);
if(CommonUtils.isNotEmpty(videoCoverUrl)){
String poster = json.getJSONObject("videoCoverUrl").getString("224*126");
shyVideos.setVideo_poster(poster);
}
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(ErrorEnum.SUCCESS);
} else {
return new ResponseBean(ErrorEnum.ERROR);
}
}
}