Commit 6463811160c8cb0790b3f87968f3cc0ec8699658

Authored by 王言钊
1 parent c7f10d56

优化工具类、删减未被引用的类和方法

src/main/java/com/cnlive/shenhe/mapper/ShyVideofilterMapper.java deleted 100644 → 0
1 -package com.cnlive.shenhe.mapper;  
2 -  
3 -import com.cnlive.shenhe.entity.ShyVideofilter;  
4 -import tk.mybatis.mapper.common.Mapper;  
5 -  
6 -public interface ShyVideofilterMapper extends Mapper<ShyVideofilter> {  
7 -}  
8 \ No newline at end of file 0 \ No newline at end of file
src/main/java/com/cnlive/shenhe/service/serviceImpl/VideofilterServiceImpl.java deleted 100644 → 0
1 -package com.cnlive.shenhe.service.serviceImpl;  
2 -  
3 -import com.cnlive.shenhe.entity.ShyVideofilter;  
4 -import com.cnlive.shenhe.mapper.ShyVideofilterMapper;  
5 -import org.springframework.beans.factory.annotation.Autowired;  
6 -import org.springframework.stereotype.Service;  
7 -  
8 -/**  
9 - * @Auther: liwei  
10 - * @Date: 2019/04/22 14:23  
11 - * @Description:  
12 - */  
13 -@Service  
14 -public class VideofilterServiceImpl {  
15 - @Autowired  
16 - ShyVideofilterMapper shyVideofilterMapper;  
17 -  
18 - /**  
19 - * 根据主键id查询视频详情  
20 - *  
21 - * @param id  
22 - * @return  
23 - */  
24 - public ShyVideofilter get(Integer id) {  
25 - return shyVideofilterMapper.selectByPrimaryKey(id);  
26 - }  
27 -  
28 - /**  
29 - * 修改视频详情  
30 - *  
31 - * @param videofilter  
32 - * @return  
33 - */  
34 - public boolean update(ShyVideofilter videofilter) {  
35 - return shyVideofilterMapper.updateByPrimaryKeySelective(videofilter) == 1;  
36 - }  
37 -}  
src/main/java/com/cnlive/shenhe/utils/AntiFraudUtil.java deleted 100644 → 0
1 -package com.cnlive.shenhe.utils;  
2 -  
3 -import com.alibaba.fastjson.JSON;  
4 -import com.alibaba.fastjson.JSONArray;  
5 -import com.alibaba.fastjson.JSONObject;  
6 -import org.apache.commons.lang3.StringUtils;  
7 -  
8 -import java.util.UUID;  
9 -  
10 -  
11 -/**  
12 - * 数美 反欺诈工具类  
13 - *  
14 - * @author GuoYaqi  
15 - */  
16 -public class AntiFraudUtil {  
17 -  
18 - //把变量配置到属性文件  
19 -  
20 - private static final String ACCESSKEY = "DU0tyaqrO5Vuiuiq4i8E"; // 商户的 accessKey  
21 - private static final String REQUEST_URL_TEXT = "http://api.fengkongcloud.com/v2/saas/anti_fraud/text";  
22 - private static final String REQUEST_URL_ARTICLE = "http://img-api.fengkongcloud.com/v1/saas/anti_fraud/article";  
23 - private static final String REQUEST_URL_IMG = "http://img-api-bj.fengkongcloud.com/v2/saas/anti_fraud/imgs";  
24 - private static final String REQUEST_URL_VIDEO = "http://video-api-bj.fengkongcloud.com/v2/saas/anti_fraud/video";  
25 - private static final String RESPONSE_URL_VIDEO = "http://video-api-bj.fengkongcloud.com/v2/saas/anti_fraud/query_video";  
26 - private static final String REQUEST_URL_VIDEOSTREAM = "http://video-api.fengkongcloud.com/v2/saas/anti_fraud/videostream";  
27 - private static final String RESPONSE_URL_VIDEOSTREAM = "http://video-api.fengkongcloud.com/v2/saas/anti_fraud/query_videostream";  
28 - private static final String FINISH_URL_VIDEOSTREAM = "http://video-api.fengkongcloud.com/v2/saas/anti_fraud/finish_videostream";  
29 -  
30 -  
31 - private static final String Contents_list = "https://www.fengkongcloud.com/ApiV2/ListService/lists";  
32 -  
33 - /**  
34 - * 智能文本过滤  
35 - *  
36 - * @param text 需要过滤的文本  
37 - * @param tokenId 建议传UID  
38 - * @param channel COMMENT,DYNAMIC_BUSINESS,DYNAMIC_USER,不传为COMMENT  
39 - * @return 通过:PASS 拒绝:REJECT 可疑:REVIEW 数美异常:null  
40 - */  
41 - public static JSONObject filterText(String tokenId, String text, String channel) {  
42 - try {  
43 - JSONObject result = reqTextFilter(tokenId, text, channel);  
44 -  
45 - /**  
46 - * 接口会返回code, code=1100 时说明请求成功,根据不同的 riskLevel 风险级别进行业务处理  
47 - * 当 code!=1100 时,如果是 1902 错误,需要检查参数配置  
48 - * 其余情况需要根据错误码进行重试或者其它异常处理  
49 - */  
50 - if (result != null) {  
51 - Integer code = result.getInteger("code");  
52 -  
53 - if (code != null && code == 1100) { //请求成功  
54 - String riskLevel = result.getString("riskLevel");  
55 -  
56 - if ("PASS".equals(riskLevel)) {  
57 - return result;  
58 - }  
59 -  
60 - if ("REJECT".equals(riskLevel)) {  
61 - JSONObject detail = result.getJSONObject("detail");  
62 -  
63 - result.put("desc",  
64 - String.format("(%s)", detail.getString("riskTypeDesc")));  
65 - return result;  
66 - }  
67 -  
68 - if ("REVIEW".equals(riskLevel)) {  
69 - return result;  
70 - }  
71 - }  
72 - }  
73 - return null;  
74 - } catch (Exception e) {  
75 - return null;  
76 - }  
77 - }  
78 -  
79 -  
80 - /**  
81 - * 智能图文过滤  
82 - *  
83 - * @param channel COMMENT,NEWS(新闻),CULTURE_SPORTS(娱乐/体育),不传为COMMENT  
84 - * @param contents 要检测的网页内容,url链接或文本内容  
85 - * @param tokenId 建议传UID  
86 - * @return 通过:PASS 拒绝:REJECT 可疑:REVIEW 数美异常:null  
87 - */  
88 - public static JSONObject filterArticle(String tokenId, String contents, String channel) {  
89 - try {  
90 - JSONObject result = reqArticleFilter(tokenId, contents, channel);  
91 - /**  
92 - * 接口会返回code, code=1100 时说明请求成功,根据不同的 riskLevel 风险级别进行业务处理  
93 - * 当 code!=1100 时,如果是 1902 错误,需要检查参数配置  
94 - * 其余情况需要根据错误码进行重试或者其它异常处理  
95 - */  
96 - return getResult(result);  
97 - } catch (Exception e) {  
98 - return null;  
99 - }  
100 - }  
101 -  
102 - /**  
103 - * 智能图片过滤  
104 - *  
105 - * @param picArray 需要过滤的图片的集合  
106 - * @param tokenId 建议传UID  
107 - * @return 通过:PASS 拒绝:REJECT 异常:REVIEW  
108 - */  
109 - public static JSONObject filterImg(String tokenId, String picArray, String channel) {  
110 - try {  
111 - JSONArray imgArray = getJSONArray(picArray);  
112 - JSONObject result = reqImgFilter(tokenId, imgArray, channel);  
113 - /**  
114 - * 接口会返回code, code=1100 时说明请求成功,根据不同的 riskLevel 风险级别进行业务处理  
115 - * 当 code!=1100 时,如果是 1902 错误,需要检查参数配置  
116 - * 其余情况需要根据错误码进行重试或者其它异常处理  
117 - */  
118 - if (result != null) {  
119 - System.out.println("数美图片过滤返回结果" + result);  
120 - JSONObject jsonObj = new JSONObject();  
121 - StringBuffer strBuffer = new StringBuffer();  
122 - int count = 0;  
123 - Integer code = result.getInteger("code");  
124 - if (code != null && code == 1100) { //请求成功  
125 - JSONArray jsonArray = result.getJSONArray("imgs");  
126 - if (jsonArray.size() > 0) {  
127 - for (int i = 0; i < jsonArray.size(); i++) {  
128 - JSONObject json = jsonArray.getJSONObject(i);  
129 - String riskLevel = json.getString("riskLevel");  
130 -  
131 - if ("PASS".equals(riskLevel)) {  
132 - continue;  
133 - }  
134 -  
135 - if ("REJECT".equals(riskLevel) || "REVIEW".equals(riskLevel)) {  
136 - JSONObject detail = json.getJSONObject("detail");  
137 - for (int j = 0; j < imgArray.size(); j++) {  
138 - String btId = json.getString("btId");  
139 - if (imgArray.getJSONObject(j).containsValue(btId)) {  
140 - strBuffer.append("(第" + (j + 1) + "张-" + detail.getString("description") + ")");  
141 - }  
142 - }  
143 - jsonObj.put("desc", strBuffer);  
144 - count++;  
145 - continue;  
146 - }  
147 - }  
148 - }  
149 - if (count > 0) {  
150 - jsonObj.put("type", "REJECT");  
151 - } else {  
152 - jsonObj.put("type", "PASS");  
153 - }  
154 - } else {//数美请求结果code为失败状态  
155 - jsonObj.put("type", "REJECT");  
156 - jsonObj.put("desc", "code:" + code + ",message:" + result.getString("message"));  
157 - }  
158 - return jsonObj;  
159 - }  
160 - } catch (Exception e) {  
161 - e.printStackTrace();  
162 - }  
163 - return null;  
164 - }  
165 -  
166 - /**  
167 - * 智能视频过滤  
168 - *  
169 - * @param url 需要过滤的视频的url  
170 - * @param uuid 需要过滤的视频的唯一标识  
171 - * @return 通过:PASS 拒绝:REJECT 异常:null  
172 - */  
173 - public static JSONObject filterVideo(String url, String uuid, String channel) {  
174 - try {  
175 - JSONObject result = reqVideoFilter(url, uuid, channel);  
176 - /**  
177 - * 接口会返回code, code=1100 时说明请求成功,根据不同的 riskLevel 风险级别进行业务处理  
178 - * 当 code!=1100 时,如果是 1902 错误,需要检查参数配置  
179 - * 其余情况需要根据错误码进行重试或者其它异常处理  
180 - */  
181 - return result;  
182 - } catch (Exception e) {  
183 - return null;  
184 - }  
185 - }  
186 -  
187 - /**  
188 - * 智能视频过滤  
189 - *  
190 - * @param uuid 需要查看的视频的唯一标识  
191 - * @return 通过:PASS 拒绝:REJECT 异常:null  
192 - */  
193 - public static JSONObject queryVideoResult(String uuid) {  
194 - try {  
195 - JSONObject userData = new JSONObject();  
196 - userData.put("accessKey", ACCESSKEY);  
197 - userData.put("btId", uuid);  
198 - JSONObject result = HttpClientUtils.httpPost(RESPONSE_URL_VIDEO, userData, false);  
199 - System.out.println("响应:" + result);  
200 - return result;  
201 - } catch (Exception e) {  
202 - System.out.println("...................接口请求失败:");  
203 - e.printStackTrace();  
204 - return null;  
205 - }  
206 - }  
207 -  
208 - /**  
209 - * 智能视频流过滤(直播)  
210 - *  
211 - * @param url 需要过滤的视频的url  
212 - * @param uuid 需要过滤的视频的唯一标识  
213 - * @return 通过:PASS 拒绝:REJECT 异常:null  
214 - */  
215 - public static JSONObject filterVideoStream(String url, String uuid, String videoName, String channel) {  
216 - try {  
217 - JSONObject result = reqVideoFilterStream(url, uuid, videoName, channel);  
218 - /**  
219 - * 接口会返回code, code=1100 时说明请求成功,根据不同的 riskLevel 风险级别进行业务处理  
220 - * 当 code!=1100 时,如果是 1902 错误,需要检查参数配置  
221 - * 其余情况需要根据错误码进行重试或者其它异常处理  
222 - */  
223 - return result;  
224 - } catch (Exception e) {  
225 - return null;  
226 - }  
227 - }  
228 -  
229 - /**  
230 - * 智能视频流过滤(直播)  
231 - *  
232 - * @param uuid 需要查看的视频的唯一标识  
233 - * @return 通过:PASS 拒绝:REJECT 异常:null  
234 - */  
235 - public static JSONObject queryVideoStreamResult() {  
236 - try {  
237 - JSONObject userData = new JSONObject();  
238 - userData.put("accessKey", ACCESSKEY);  
239 - JSONObject result = HttpClientUtils.httpPost(RESPONSE_URL_VIDEOSTREAM, userData, false);  
240 - System.out.println("响应:" + result);  
241 - return result;  
242 - } catch (Exception e) {  
243 - System.out.println("...................接口请求失败:");  
244 - e.printStackTrace();  
245 - return null;  
246 - }  
247 - }  
248 -  
249 - /**  
250 - * 视频流关闭(直播--关闭)  
251 - *  
252 - * @param url 关闭的视频流的地址  
253 - * @param requestId 关闭的视频流的requestId  
254 - * @return 通过:PASS 拒绝:REJECT 异常:null  
255 - */  
256 - public static JSONObject finishVideoStream(String url, String requestId) {  
257 - try {  
258 - JSONObject result = reqFinishVideoStream(url, requestId);  
259 - /**  
260 - * 接口会返回code, code=1100 时说明请求成功,根据不同的 riskLevel 风险级别进行业务处理  
261 - * 当 code!=1100 时,如果是 1902 错误,需要检查参数配置  
262 - * 其余情况需要根据错误码进行重试或者其它异常处理  
263 - */  
264 - return result;  
265 - } catch (Exception e) {  
266 - return null;  
267 - }  
268 - }  
269 -  
270 -  
271 - private static JSONObject reqTextFilter(String tokenId, String text, String channel) throws Exception {  
272 - JSONObject userData = new JSONObject();  
273 -  
274 - userData.put("accessKey", ACCESSKEY);  
275 - userData.put("type", "SOCIAL");  
276 -  
277 - JSONObject data = new JSONObject();  
278 - data.put("tokenId", tokenId);  
279 - data.put("text", text);  
280 - data.put("channel", StringUtils.isNotEmpty(channel) ? channel : "COMMENT");  
281 - userData.put("data", data);  
282 -  
283 - return HttpClientUtils.httpPost(REQUEST_URL_TEXT, userData, false);  
284 - }  
285 -  
286 - private static JSONObject reqImgFilter(String tokenId, JSONArray imgs, String channel) throws Exception {  
287 - JSONObject userData = new JSONObject();  
288 - userData.put("accessKey", ACCESSKEY);  
289 - userData.put("type", "AD_PORN_PERSON");  
290 -  
291 - JSONObject data = new JSONObject();  
292 - data.put("tokenId", tokenId);  
293 -  
294 - data.put("imgs", imgs);  
295 - data.put("channel", StringUtils.isNotEmpty(channel) ? channel : "COMMENT");  
296 - userData.put("data", data);  
297 -  
298 - return HttpClientUtils.httpPost(REQUEST_URL_IMG, userData, false);  
299 - }  
300 -  
301 - private static JSONObject reqVideoFilter(String url, String uuid, String channel) throws Exception {  
302 - JSONObject userData = new JSONObject();  
303 - userData.put("accessKey", ACCESSKEY);  
304 - userData.put("btId", uuid);  
305 - userData.put("callback", "http://apiwjjtest.cnlive.com/Daren/filterVideoResult/callbackVideoResult.action");  
306 - userData.put("type", "AD_PORN_PERSON_VIOLENCE");  
307 -  
308 -  
309 - JSONObject data = new JSONObject();  
310 - data.put("url", url);  
311 - data.put("addition", "AUDIO");  
312 - data.put("channel", StringUtils.isNotEmpty(channel) ? channel : "COMMENT");  
313 - userData.put("data", data);  
314 -  
315 - return HttpClientUtils.httpPost(REQUEST_URL_VIDEO, userData, false);  
316 - }  
317 -  
318 - private static JSONObject reqVideoFilterStream(String url, String uuid, String videoName, String channel) throws Exception {  
319 - JSONObject userData = new JSONObject();  
320 - userData.put("accessKey", ACCESSKEY);  
321 -// userData.put("btId", uuid);  
322 - userData.put("callback", "http://test.shen.cnlive.com/api/videoStream/callbackVideoStreamResult");  
323 - userData.put("type", "DEFAULT");  
324 -  
325 -  
326 - JSONObject data = new JSONObject();  
327 - data.put("url", url);  
328 - data.put("VideoName", videoName);  
329 - data.put("callbackLevel", true);//true表示返回所有图片的审核结果,false表示只返回非pass的审核结果  
330 - data.put("detectFrequency", 10);//视频流截帧频率范围:0.5-60(0.5秒一帧-60秒一帧),默认为5  
331 - data.put("tokenId", uuid);//客户端用户账号唯一标识,用于用户行为分析,建议传入用户UID;  
332 -// data.put("channel", StringUtils.isNotEmpty(channel) ? channel : "COMMENT");  
333 - data.put("channel", "VIDEO_LIVE");  
334 - userData.put("data", data);  
335 -  
336 - return HttpClientUtils.httpPost(REQUEST_URL_VIDEOSTREAM, userData, false);  
337 - }  
338 -  
339 - private static JSONObject reqFinishVideoStream(String url, String requestId) throws Exception {  
340 - JSONObject userData = new JSONObject();  
341 - userData.put("accessKey", ACCESSKEY);  
342 - userData.put("requestId", requestId);  
343 - userData.put("url", url);  
344 -  
345 - return HttpClientUtils.httpPost(FINISH_URL_VIDEOSTREAM, userData, false);  
346 - }  
347 -  
348 - private static JSONObject reqArticleFilter(String tokenId, String contents, String channel) throws Exception {  
349 - JSONObject userData = new JSONObject();  
350 - userData.put("accessKey", ACCESSKEY);  
351 -  
352 - JSONObject data = new JSONObject();  
353 - data.put("contents", contents);  
354 - data.put("tokenId", tokenId);  
355 - data.put("channel", StringUtils.isNotEmpty(channel) ? channel : "DEFAULT_LOGO");  
356 - userData.put("data", data);  
357 -  
358 - return HttpClientUtils.httpPost(REQUEST_URL_ARTICLE, userData, false);  
359 - }  
360 -  
361 - private static JSONObject getResult(JSONObject result) {  
362 -  
363 - if (result != null) {  
364 - System.out.println("数美过滤返回结果" + result);  
365 - JSONObject jsonObj = new JSONObject();  
366 - Integer code = result.getInteger("code");  
367 -  
368 - if (code != null && code == 1100) { //请求成功  
369 - String riskLevel = result.getString("riskLevel");  
370 -  
371 - if ("PASS".equals(riskLevel)) {  
372 - jsonObj.put("type", "REJECT");  
373 - return result;  
374 - }  
375 -  
376 - if ("REJECT".equals(riskLevel)) {  
377 - JSONObject detail = result.getJSONObject("detail");  
378 -  
379 - result.put("desc", String.format("(%s)", detail.getString("description")));  
380 - return result;  
381 - }  
382 -  
383 - if ("REVIEW".equals(riskLevel)) {  
384 - return result;  
385 - }  
386 - }  
387 - }  
388 - return null;  
389 - }  
390 -  
391 - private static JSONArray getJSONArray(String json) {  
392 - JSONArray picJson = JSON.parseArray(json);  
393 - JSONArray imgs = new JSONArray();  
394 - for (int i = 0; i < picJson.size(); i++) {  
395 - UUID uuid = UUID.randomUUID();  
396 - String btId = uuid.toString();  
397 - JSONObject jsonObject = new JSONObject();  
398 - JSONObject jsonObj = picJson.getJSONObject(i);  
399 - String img = jsonObj.getString("imageUrl");  
400 - jsonObject.put("img", img);  
401 - jsonObject.put("btId", btId);  
402 - imgs.add(jsonObject);  
403 - }  
404 - return imgs;  
405 - }  
406 -  
407 - /**  
408 - * 名单列表查询  
409 - *  
410 - * @return  
411 - */  
412 - private static String contentsList() {  
413 -  
414 - String url = Contents_list + "?accessKey=" + ACCESSKEY + "&type=1&serviceId=POST_TEXT";  
415 - return HttpClientUtils.get(url);  
416 - }  
417 -  
418 - /**  
419 - * 名单内容列表查询(敏感词黑名单)  
420 - *  
421 - * @return  
422 - */  
423 - private static String blackContentsList() {  
424 -  
425 - String url = "https://www.fengkongcloud.com/ApiV2/ListService/lists/0f85d5aab7f59a6070c403c57aefcc0a/contents?accessKey=" + ACCESSKEY;  
426 - return HttpClientUtils.get(url);  
427 - }  
428 -  
429 - /**  
430 - * 新增名单内容(敏感词黑名单)  
431 - *  
432 - * @param contents  
433 - * @return  
434 - * @throws Exception  
435 - */  
436 - private static JSONObject addBlackContents(String contents) throws Exception {  
437 -  
438 - JSONObject data = new JSONObject();  
439 - String[] contents1 = new String[]{contents};  
440 - data.put("contents", contents1);  
441 -  
442 - return HttpClientUtils.httpPost("https://www.fengkongcloud.com/ApiV2/ListService/lists/0f85d5aab7f59a6070c403c57aefcc0a/contents?accessKey=" + ACCESSKEY, data, false);  
443 - }  
444 -}  
src/main/java/com/cnlive/shenhe/utils/BusinessEnum.java deleted 100644 → 0
1 -package com.cnlive.shenhe.utils;  
2 -  
3 -/**  
4 - * @Auther: 周伟鹏  
5 - * @Date: 2018/11/30 14:32  
6 - * @Description:审核业务  
7 - */  
8 -public enum BusinessEnum {  
9 - VIDEO(1, "点播审核"),  
10 - COMMENT(2, "评论审核");  
11 -  
12 - private Integer businessCode;  
13 - private String businessMessage;  
14 -  
15 - BusinessEnum(Integer businessCode, String businessMessage) {  
16 - this.businessCode = businessCode;  
17 - this.businessMessage = businessMessage;  
18 - }  
19 -  
20 - public Integer getBusinessCode() {  
21 - return businessCode;  
22 - }  
23 -  
24 - public String getBusinessMessage() {  
25 - return businessMessage;  
26 - }  
27 -}  
src/main/java/com/cnlive/shenhe/utils/TextDetectionUtil.java
@@ -22,31 +22,11 @@ public class TextDetectionUtil { @@ -22,31 +22,11 @@ public class TextDetectionUtil {
22 // 输出文件地址 22 // 输出文件地址
23 String fileWriterUrl = "C:\\Users\\Administrator\\Desktop\\通过数据.txt"; 23 String fileWriterUrl = "C:\\Users\\Administrator\\Desktop\\通过数据.txt";
24 // 调用输入流方法 24 // 调用输入流方法
25 - BufferedReader bufferedReader = FileReaderUrl(fileReaderUrl); 25 + BufferedReader bufferedReader = fileReaderUrl(fileReaderUrl);
26 // 调用输出流方法 26 // 调用输出流方法
27 - BufferedWriter bufferedWriter = FileWriterUrl(fileWriterUrl); 27 + BufferedWriter bufferedWriter = fileWriterUrl(fileWriterUrl);
28 try { 28 try {
29 - boolean flag = true;  
30 - while (flag) {  
31 - String textContent = bufferedReader.readLine();  
32 - if (flag = textContent != null ? true : false) {  
33 - // 文本内容送审  
34 - JSONObject textFilter = YiDunAntiFraudUtil.getTextFilter(textContent);  
35 - // 送审返回结果类型  
36 - String type = textFilter.getString("type");  
37 - // 送审返回结果内容  
38 - String desc = textFilter.getString("desc");  
39 - // 如果是通过的内容 输出到文件中  
40 - if (type.equals("PASS")) {  
41 - // 输出(写)的操作  
42 - bufferedWriter.write(textContent);  
43 - // 换行操作  
44 - bufferedWriter.newLine();  
45 - }  
46 - log.info("type:{}" + type);  
47 - log.info("desc:{}" + desc);  
48 - }  
49 - } 29 + fileReaderWriter(bufferedReader, bufferedWriter);
50 } catch (IOException e) { 30 } catch (IOException e) {
51 e.printStackTrace(); 31 e.printStackTrace();
52 } finally { 32 } finally {
@@ -77,7 +57,7 @@ public class TextDetectionUtil { @@ -77,7 +57,7 @@ public class TextDetectionUtil {
77 * @param fileReaderUrl 57 * @param fileReaderUrl
78 * @return 58 * @return
79 */ 59 */
80 - public static BufferedReader FileReaderUrl(String fileReaderUrl) { 60 + public static BufferedReader fileReaderUrl(String fileReaderUrl) {
81 BufferedReader bufferedReader = null; 61 BufferedReader bufferedReader = null;
82 try { 62 try {
83 bufferedReader = new BufferedReader(new FileReader(new File(fileReaderUrl))); 63 bufferedReader = new BufferedReader(new FileReader(new File(fileReaderUrl)));
@@ -93,7 +73,7 @@ public class TextDetectionUtil { @@ -93,7 +73,7 @@ public class TextDetectionUtil {
93 * @param fileWriterUrl 73 * @param fileWriterUrl
94 * @return 74 * @return
95 */ 75 */
96 - public static BufferedWriter FileWriterUrl(String fileWriterUrl) { 76 + public static BufferedWriter fileWriterUrl(String fileWriterUrl) {
97 BufferedWriter bufferedWriter = null; 77 BufferedWriter bufferedWriter = null;
98 try { 78 try {
99 bufferedWriter = new BufferedWriter(new FileWriter(new File(fileWriterUrl))); 79 bufferedWriter = new BufferedWriter(new FileWriter(new File(fileWriterUrl)));
@@ -102,4 +82,35 @@ public class TextDetectionUtil { @@ -102,4 +82,35 @@ public class TextDetectionUtil {
102 } 82 }
103 return bufferedWriter; 83 return bufferedWriter;
104 } 84 }
  85 +
  86 + /**
  87 + * 内容读取执行过程
  88 + *
  89 + * @param bufferedReader
  90 + * @param bufferedWriter
  91 + * @throws IOException
  92 + */
  93 + public static void fileReaderWriter(BufferedReader bufferedReader, BufferedWriter bufferedWriter) throws IOException {
  94 + boolean flag = true;
  95 + while (flag) {
  96 + String textContent = bufferedReader.readLine();
  97 + if (flag = textContent != null) {
  98 + // 文本内容送审
  99 + JSONObject textFilter = YiDunAntiFraudUtil.getTextFilter(textContent);
  100 + // 送审返回结果类型
  101 + String type = textFilter.getString("type");
  102 + // 送审返回结果内容
  103 + String desc = textFilter.getString("desc");
  104 + // 如果是通过的内容 输出到文件中
  105 + if ("PASS".equals(type)) {
  106 + // 输出(写)的操作
  107 + bufferedWriter.write(textContent);
  108 + // 换行操作
  109 + bufferedWriter.newLine();
  110 + }
  111 + log.info("type:{}" + type);
  112 + log.info("desc:{}" + desc);
  113 + }
  114 + }
  115 + }
105 } 116 }
src/main/java/com/cnlive/shenhe/utils/TransitServiceUtils.java
@@ -50,14 +50,4 @@ public class TransitServiceUtils { @@ -50,14 +50,4 @@ public class TransitServiceUtils {
50 } 50 }
51 return result; 51 return result;
52 } 52 }
53 -  
54 - public static void main(String[] args) {  
55 - JSONObject params = new JSONObject();  
56 - params.put("video_id", "11111");  
57 - params.put("state", "22222");  
58 - params.put("attr_tags", "33333");  
59 - params.put("msg", "4444");  
60 -// send("cms","/api/callback",true,params);  
61 - System.exit(0);  
62 - }  
63 } 53 }
src/main/resources/mapper/ShyVideofilterMapper.xml deleted 100644 → 0
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">  
3 -<mapper namespace="com.cnlive.shenhe.mapper.ShyVideofilterMapper">  
4 - <resultMap id="BaseResultMap" type="com.cnlive.shenhe.entity.ShyVideofilter">  
5 - <!--  
6 - WARNING - @mbg.generated  
7 - -->  
8 - <id column="id" jdbcType="INTEGER" property="id" />  
9 - <result column="videos_id" jdbcType="INTEGER" property="videos_id" />  
10 - <result column="token_id" jdbcType="VARCHAR" property="token_id" />  
11 - <result column="channel" jdbcType="VARCHAR" property="channel" />  
12 - <result column="result_type" jdbcType="VARCHAR" property="result_type" />  
13 - <result column="desc_msg" jdbcType="VARCHAR" property="desc_msg" />  
14 - <result column="duration" jdbcType="INTEGER" property="duration" />  
15 - <result column="created_at" jdbcType="TIMESTAMP" property="created_at" />  
16 - </resultMap>  
17 -</mapper>  
18 \ No newline at end of file 0 \ No newline at end of file