AuditPass.java
2.35 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
package com.cnlive.shenhe.utils;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
/**
* @Auther: chenhao
* @Date: 2018/12/3 16:00
* @Description:如果是白名单直接审核通过
*/
@Component
public class AuditPass {
private static Logger logger = LoggerFactory.getLogger(AuditPass.class);
@Value("${platformKey}")
private String platformKey;//点播platformKey
@Value("${platformValue}")
private String platformValue;//点播platformValue
/**
* 点播视频回调
*
* @param video_id
* @param state
* @param attr_tags
* @param msg
* @return
*/
public JSONObject auditPass(String video_id, int state, String attr_tags, String msg, String callBack) {
logger.info("点播回调:video_id:{},state:{},attr_tags:{},msg:{}", video_id, state, attr_tags, msg);
JSONObject params = new JSONObject();
params.put("video_id", video_id);
params.put("state", state + "");
params.put("attr_tags", attr_tags);
params.put("msg", msg);
HttpUtil httpUtil = HttpUtil.init();
httpUtil.setParam("param", params.toJSONString());
String token = "";
try {
String cb = callBack.replace("//", "");
cb = cb.substring(cb.indexOf("/"));
token = CommonUtils.md5(cb + platformKey + platformValue);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String URL = callBack + "?platform=" + platformKey + "&token=" + token;
Map<String, String> post = httpUtil.post(URL);
return JSONObject.parseObject(post.get("result"));
}
/**
* 评论打回回调
* @param json
* @param callBack
* @return
*/
public JSONObject commentPass(JSONObject json, String callBack) {
Map<String, String> map = new HashMap<>();
map.put("param", json.toJSONString());
String result = HttpUtil.form(callBack, map);
return JSONObject.parseObject(result);
}
}