AuditPass.java
4.74 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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 activity_id
* @param state
* @param attr_tags
* @param msg
* @return
*/
public JSONObject livePass(String activity_id, int state, String attr_tags, String msg, String callBack) {
logger.info("直播回调:id:{},state:{},attr_tags:{},exceptionMessage:{}", activity_id, state, attr_tags, msg);
JSONObject params = new JSONObject();
params.put("id", activity_id);
params.put("state", state);
params.put("attr_tags", attr_tags);
params.put("exceptionMessage", msg);
HttpUtil httpUtil = HttpUtil.init();
httpUtil.setParam("param", params.toJSONString());
Map<String, String> post = httpUtil.post(callBack);
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);
}
/**
* 频道审核回调
* @param json
* @param callBack
* @return
*/
public JSONObject channelPass(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);
}
/**
* 图文审核回调
* @param ids
* @param type 1(fabu),2(xiaxian),3(shanchu)
* @param shenheStatus 1
* @param msg
* @param callBack
* @return
*/
public JSONObject contentPass(String contentId, String type,String msg, String callBack) {
logger.info("图文回调:ids:{},type:{},msg:{}", contentId, type, msg);
HttpUtil httpUtil = HttpUtil.init();
String URL = callBack + "?contentId=" + contentId + "&type=" + type+ "&shenMsg=" + msg;
Map<String, String> post = httpUtil.post(URL);
return JSONObject.parseObject(post.get("result"));
}
public JSONObject momentPass(String content_id, Integer state, String msg, String callback, String userId) {
logger.info("朋友圈回调:content_id:{},state:{},msg:{},userId:{}", content_id, state, msg,userId);
JSONObject json=new JSONObject();
json.put("userId",userId );
json.put("momentId",content_id );
json.put("status",state );
json.put("msg", msg);
String httpUtilResult = HttpClientUtils.HttpPostWithJson(callback, json.toString());
logger.info("朋友圈返回数据,httpUtilResult=====" + httpUtilResult);
JSONObject result = JSONObject.parseObject(httpUtilResult);
return result;
}
}