AuditPass.java
10.3 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
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);
/**
* //点播platformKey
*/
@Value("${platformKey}")
private String platformKey;
/**
* //点播platformValue
*/
@Value("${platformValue}")
private String platformValue;
/**
* //直播同步信息
*/
@Value("${live_url}")
private String live_url;
/**
* //用户云查网家家用户信息(通过手机号)
*/
@Value("${queryUserByMobile}")
private String queryUserByMobile;
/**
* //用户云查网家家用户信息(通过用户id)
*/
@Value("${queryUserByUserId}")
private String queryUserByUserId;
public static void main(String[] args) {
JSONObject map = new JSONObject();
map.put("platform", "a");
map.put("commentUserAvatar", "http://yweb0.cnliveimg.com/images/headImg/2019/1129/1575022593286.jpg");
map.put("appId", "60#iqw7flx829");
map.put("commentUserIP", null);
map.put("type", "topic");
map.put("activityId", "802:video:comets:604_ab79303bd0074a24965a92dd6514681a#20939");
HttpUtil httpUtil = HttpUtil.init();
httpUtil.setParam("param", map.toJSONString());
Map<String, String> post = httpUtil.post("http://test.shen.cnlive.com/api/comments/import");
}
/**
* 点播视频回调
*
* @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);
String result = post.get("result");
logger.info("点播回调result:{}", result);
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);
String result = post.get("result");
logger.info("直播回调result:{}", result);
return JSONObject.parseObject(post.get("result"));
}
/**
* 直播视频回调
*
* @param activity_id
* @param state
* @param attr_tags
* @param msg
* @return
*/
public JSONObject liveApplyPass(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"));
}
/**
* 直播云信息同步
*
* @return
*/
public JSONObject syncLive(String activity_id) {
logger.info("直播云信息同步:activity_id:{}", activity_id);
HttpUtil httpUtil = HttpUtil.init();
httpUtil.setParam("activityId", activity_id);
Map<String, String> post = httpUtil.post(live_url);
return JSONObject.parseObject(post.get("result"));
}
/**
* 评论审核回调
*
* @param json
* @param callBack
* @return
*/
public JSONObject commentPass(JSONObject json, String callBack) {
logger.info("评论审核回调:param:{}", json);
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 commentSpeak(JSONObject json, String callBack) {
logger.info("评论禁言:param:{}", json);
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) {
logger.info("频道审核回调:param:{}", json);
Map<String, String> map = new HashMap<>();
map.put("param", json.toJSONString());
String result = HttpUtil.form(callBack, map);
return JSONObject.parseObject(result);
}
/**
* 图文审核回调
*
* @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;
}
/**
* cms审核回调
*
* @param content_id
* @param state
* @param msg
* @param callback
* @param userId
* @return
*/
public JSONObject cmsCommonContentPass(String content_id, Integer state, String msg, String callback, String userId) {
logger.info("cms审核回调:content_id:{},state:{},msg:{},userId:{}", content_id, state, msg, userId);
JSONObject json = new JSONObject();
json.put("userId", userId);
json.put("contentId", content_id);
json.put("status", state);
json.put("msg", msg);
String httpUtilResult = HttpClientUtils.HttpPostWithJson(callback, json.toString());
logger.info("cms审核返回数据,httpUtilResult====={}===请求参数:{}", httpUtilResult, json.toString());
return JSONObject.parseObject(httpUtilResult);
}
public JSONObject queryUser(String userId, String userMobile) {
logger.info("用户云查询用户:userId:{},userMobile:{}", userId, userMobile);
HttpUtil httpUtil = HttpUtil.init();
String URL = "";
if (CommonUtils.isNotEmpty(userId)) {
URL = queryUserByUserId + userId;
} else {
URL = queryUserByMobile + userMobile;
}
logger.info("用户云查询用户使用url:" + URL);
Map<String, String> post = httpUtil.post(URL);
return JSONObject.parseObject(post.get("result"));
}
//音频回调
public JSONObject audioPass(String audioId, int state, String attr_tags, String msg, String callBack) {
logger.info("点播音频回调:audioId:{},state:{},attr_tags:{},msg:{}", audioId, state, attr_tags, msg);
JSONObject params = new JSONObject();
params.put("video_id", audioId);
//3-成功 4-失败
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"));
}
}