Commit 80c53134bf659f24f136b17bc34a52966d17d39e

Authored by 王言钊
1 parent 366586e6

优化代码中的数字替换成常量

src/main/java/com/cnlive/shenhe/job/AudioJob.java
1 package com.cnlive.shenhe.job; 1 package com.cnlive.shenhe.job;
2 2
3 import com.cnlive.shenhe.entity.ShyAudio; 3 import com.cnlive.shenhe.entity.ShyAudio;
4 -import com.cnlive.shenhe.entity.ShyYidun;  
5 import com.cnlive.shenhe.serviceImpl.AudioServiceImpl; 4 import com.cnlive.shenhe.serviceImpl.AudioServiceImpl;
6 import com.cnlive.shenhe.serviceImpl.YiDunServiceImpl; 5 import com.cnlive.shenhe.serviceImpl.YiDunServiceImpl;
7 import com.cnlive.shenhe.utils.CommonConst; 6 import com.cnlive.shenhe.utils.CommonConst;
@@ -43,7 +42,7 @@ public class AudioJob { @@ -43,7 +42,7 @@ public class AudioJob {
43 logger.info("当前白名单通过的AudioId:" + audio.getAudioId()); 42 logger.info("当前白名单通过的AudioId:" + audio.getAudioId());
44 shyAudio.setUploader("白名单"); 43 shyAudio.setUploader("白名单");
45 // 更新点播音频和审核的音频状态 44 // 更新点播音频和审核的音频状态
46 - audioService.updateAudioAndShenhe(audio, 3); 45 + audioService.updateAudioAndShenhe(audio, CommonConst.AUDIT_SUCCESS);
47 } 46 }
48 } 47 }
49 } 48 }
@@ -63,15 +62,8 @@ public class AudioJob { @@ -63,15 +62,8 @@ public class AudioJob {
63 List<ShyAudio> shyAudioList = audioService.findshyAudio(shyAudio); 62 List<ShyAudio> shyAudioList = audioService.findshyAudio(shyAudio);
64 if (shyAudioList != null && shyAudioList.size() > 0) { 63 if (shyAudioList != null && shyAudioList.size() > 0) {
65 for (ShyAudio audio : shyAudioList) { 64 for (ShyAudio audio : shyAudioList) {
66 -// ShyYidun shyYidun = new ShyYidun();  
67 -// shyYidun.setContent_id(audio.getId().toString());  
68 -// //点播视频  
69 -// shyYidun.setCheck_type(4);  
70 -// ShyYidun shyYidun1 = yiDunServiceImpl.getidunMsgByContentId(shyYidun);  
71 -// if (shyYidun1 == null) {  
72 logger.info("定时向易盾发送点播音频检测视频的audioId:" + audio.getAudioId()); 65 logger.info("定时向易盾发送点播音频检测视频的audioId:" + audio.getAudioId());
73 audioService.audioFilter(audio); 66 audioService.audioFilter(audio);
74 -// }  
75 } 67 }
76 } 68 }
77 } 69 }
src/main/java/com/cnlive/shenhe/job/ContentJob.java
@@ -40,7 +40,7 @@ public class ContentJob { @@ -40,7 +40,7 @@ public class ContentJob {
40 logger.info("当前白名单通过的content_id:" + content.getId()); 40 logger.info("当前白名单通过的content_id:" + content.getId());
41 content.setUpdater("白名单"); 41 content.setUpdater("白名单");
42 // 更新点播和审核的视频状态 42 // 更新点播和审核的视频状态
43 - contentService.callback(content.getId() + "", "白名单审核通过", 1, "", "白名单"); 43 + contentService.callback(content.getId() + "", "白名单审核通过", CommonConst.AUDIT_SUCCESS, "", "白名单");
44 } 44 }
45 } 45 }
46 } 46 }
@@ -56,16 +56,7 @@ public class ContentJob { @@ -56,16 +56,7 @@ public class ContentJob {
56 if (shyContentList != null && shyContentList.size() > 0) { 56 if (shyContentList != null && shyContentList.size() > 0) {
57 logger.info("审核云提交网页审核到易盾数据个数:{}", shyContentList.size()); 57 logger.info("审核云提交网页审核到易盾数据个数:{}", shyContentList.size());
58 for (ShyContent content : shyContentList) { 58 for (ShyContent content : shyContentList) {
59 - //易盾网站过滤  
60 -// ShyYidun shyYidun = new ShyYidun();  
61 -// shyYidun.setContent_id(content.getId().toString());  
62 -// //网页类型  
63 -// shyYidun.setCheck_type(3);  
64 -// ShyYidun shyYidun1 = yiDunServiceImpl.getidunMsgByContentId(shyYidun);  
65 -// logger.info("审核云ShyYidun表里不为空提交网页审核到易盾单条数据:{}", JSON.toJSONString(content));  
66 -// if (shyYidun1 == null) {  
67 contentService.contentFilter(content); 59 contentService.contentFilter(content);
68 -// }  
69 } 60 }
70 } 61 }
71 } 62 }
src/main/java/com/cnlive/shenhe/job/VideosJob.java
@@ -28,6 +28,7 @@ public class VideosJob { @@ -28,6 +28,7 @@ public class VideosJob {
28 28
29 /** 29 /**
30 * 白名单sp视频通过 30 * 白名单sp视频通过
  31 + * 免审、未审核
31 */ 32 */
32 @Scheduled(fixedRate = 60 * 1000) 33 @Scheduled(fixedRate = 60 * 1000)
33 public void updateVideos() { 34 public void updateVideos() {
@@ -42,13 +43,14 @@ public class VideosJob { @@ -42,13 +43,14 @@ public class VideosJob {
42 logger.info("当前白名单通过的videos_id:" + video.getId()); 43 logger.info("当前白名单通过的videos_id:" + video.getId());
43 video.setUpdater("白名单"); 44 video.setUpdater("白名单");
44 // 更新点播和审核的视频状态 45 // 更新点播和审核的视频状态
45 - videosService.updateDianboAndShenhe(video, 3); 46 + videosService.updateDianboAndShenhe(video, CommonConst.AUDIT_SUCCESS);
46 } 47 }
47 } 48 }
48 } 49 }
49 50
50 /** 51 /**
51 * 定时向易盾发送视频抽帧图片进行检测 52 * 定时向易盾发送视频抽帧图片进行检测
  53 + * 机审 、未审核 、抽帧完成 进行送审
52 * 每天10点到23点执行,每分钟一次 54 * 每天10点到23点执行,每分钟一次
53 */ 55 */
54 @Scheduled(cron = "0 0/1 10-23 * * ? ") 56 @Scheduled(cron = "0 0/1 10-23 * * ? ")
@@ -65,16 +67,8 @@ public class VideosJob { @@ -65,16 +67,8 @@ public class VideosJob {
65 for (ShyVideos video : shyVideosList) { 67 for (ShyVideos video : shyVideosList) {
66 logger.info("定时向易盾发送检测视频的videos_id:{}", video.getId()); 68 logger.info("定时向易盾发送检测视频的videos_id:{}", video.getId());
67 //易盾图片过滤 69 //易盾图片过滤
68 -// ShyYidun shyYidun = new ShyYidun();  
69 -// //点播视频  
70 -// shyYidun.setContent_id(video.getId().toString());  
71 -// //图片类型  
72 -// shyYidun.setCheck_type(2);  
73 -// ShyYidun shyYidun1 = yiDunServiceImpl.getidunMsgByContentId(shyYidun);  
74 -// if (shyYidun1 == null) {  
75 logger.info("审核云定时向易盾发送视频抽帧图片检测:{}", video.getVideo_id()); 70 logger.info("审核云定时向易盾发送视频抽帧图片检测:{}", video.getVideo_id());
76 videosService.videoFilter(video.getId()); 71 videosService.videoFilter(video.getId());
77 -// }  
78 } 72 }
79 } 73 }
80 } 74 }
src/main/java/com/cnlive/shenhe/serviceImpl/AudioServiceImpl.java
@@ -7,10 +7,7 @@ import com.cnlive.shenhe.dto.AudioDTO; @@ -7,10 +7,7 @@ import com.cnlive.shenhe.dto.AudioDTO;
7 import com.cnlive.shenhe.entity.*; 7 import com.cnlive.shenhe.entity.*;
8 import com.cnlive.shenhe.mapper.ShyAudioMapper; 8 import com.cnlive.shenhe.mapper.ShyAudioMapper;
9 import com.cnlive.shenhe.mapper.ShyUsersMapper; 9 import com.cnlive.shenhe.mapper.ShyUsersMapper;
10 -import com.cnlive.shenhe.utils.AuditPass;  
11 -import com.cnlive.shenhe.utils.CommonConst;  
12 -import com.cnlive.shenhe.utils.CommonUtils;  
13 -import com.cnlive.shenhe.utils.YiDunAntiFraudUtil; 10 +import com.cnlive.shenhe.utils.*;
14 import com.github.pagehelper.PageHelper; 11 import com.github.pagehelper.PageHelper;
15 import com.github.pagehelper.PageInfo; 12 import com.github.pagehelper.PageInfo;
16 import org.apache.ibatis.session.RowBounds; 13 import org.apache.ibatis.session.RowBounds;
@@ -74,13 +71,19 @@ public class AudioServiceImpl { @@ -74,13 +71,19 @@ public class AudioServiceImpl {
74 return shyAudiolist; 71 return shyAudiolist;
75 } 72 }
76 73
  74 + /**
  75 + * 更新音频和审核状态
  76 + * @param shyAudio
  77 + * @param audioState 视频状态,1通过,2不通过
  78 + * @return
  79 + */
77 public int updateAudioAndShenhe(ShyAudio shyAudio, int audioState) { 80 public int updateAudioAndShenhe(ShyAudio shyAudio, int audioState) {
78 //修改点播云音频状态 81 //修改点播云音频状态
79 JSONObject result = Pass.audioPass(shyAudio.getAudioId(), audioState, shyAudio.getAttr_tags(), shyAudio.getMsg(), shyAudio.getCallback()); 82 JSONObject result = Pass.audioPass(shyAudio.getAudioId(), audioState, shyAudio.getAttr_tags(), shyAudio.getMsg(), shyAudio.getCallback());
80 Integer code = result.getInteger("code"); 83 Integer code = result.getInteger("code");
81 Integer shenheState = CommonConst.AUDIT_REFUSE; 84 Integer shenheState = CommonConst.AUDIT_REFUSE;
82 if (0 == code) { 85 if (0 == code) {
83 - if (audioState == 3) { 86 + if (audioState == CommonConst.AUDIT_SUCCESS) {
84 shenheState = CommonConst.AUDIT_SUCCESS; 87 shenheState = CommonConst.AUDIT_SUCCESS;
85 } 88 }
86 //修改审核云的音频状态 89 //修改审核云的音频状态
@@ -350,9 +353,10 @@ public class AudioServiceImpl { @@ -350,9 +353,10 @@ public class AudioServiceImpl {
350 353
351 /** 354 /**
352 * 易盾点播音频过滤 355 * 易盾点播音频过滤
353 - * 356 + * 音频送审时 给了回调地址
  357 + * 送审类型:1:文本 2:图片 3.网页 4:点播音频
354 * @param shyAudio 358 * @param shyAudio
355 - * @return 1:文本 2:图片 3.网页 4:点播音频 359 + * @return
356 */ 360 */
357 public void audioFilter(ShyAudio shyAudio) { 361 public void audioFilter(ShyAudio shyAudio) {
358 //调用易盾点播音频检测接口 362 //调用易盾点播音频检测接口
@@ -368,7 +372,7 @@ public class AudioServiceImpl { @@ -368,7 +372,7 @@ public class AudioServiceImpl {
368 shyYidun.setCreate_time(new Date()); 372 shyYidun.setCreate_time(new Date());
369 shyYidun.setTask_id(taskId); 373 shyYidun.setTask_id(taskId);
370 shyYidun.setData_id(dataId); 374 shyYidun.setData_id(dataId);
371 - shyYidun.setCheck_type(4); 375 + shyYidun.setCheck_type(CommonConstStates.DIANBOYINPIN);
372 yiDunServiceImpl.addYiDunMsg(shyYidun); 376 yiDunServiceImpl.addYiDunMsg(shyYidun);
373 } 377 }
374 } 378 }
src/main/java/com/cnlive/shenhe/serviceImpl/ContentServiceImpl.java
@@ -7,10 +7,7 @@ import com.cnlive.shenhe.entity.*; @@ -7,10 +7,7 @@ import com.cnlive.shenhe.entity.*;
7 import com.cnlive.shenhe.mapper.ShyCommentsMapper; 7 import com.cnlive.shenhe.mapper.ShyCommentsMapper;
8 import com.cnlive.shenhe.mapper.ShyContentMapper; 8 import com.cnlive.shenhe.mapper.ShyContentMapper;
9 import com.cnlive.shenhe.mapper.ShyUsersMapper; 9 import com.cnlive.shenhe.mapper.ShyUsersMapper;
10 -import com.cnlive.shenhe.utils.AuditPass;  
11 -import com.cnlive.shenhe.utils.CommonConst;  
12 -import com.cnlive.shenhe.utils.CommonUtils;  
13 -import com.cnlive.shenhe.utils.YiDunAntiFraudUtil; 10 +import com.cnlive.shenhe.utils.*;
14 import com.github.pagehelper.PageHelper; 11 import com.github.pagehelper.PageHelper;
15 import com.github.pagehelper.PageInfo; 12 import com.github.pagehelper.PageInfo;
16 import org.apache.ibatis.session.RowBounds; 13 import org.apache.ibatis.session.RowBounds;
@@ -384,9 +381,9 @@ public class ContentServiceImpl { @@ -384,9 +381,9 @@ public class ContentServiceImpl {
384 381
385 /** 382 /**
386 * 易盾网站过滤 383 * 易盾网站过滤
387 - * 384 + * 送审类型:1:文本 2:图片 3.网页 4:点播音频
388 * @param shyContent 385 * @param shyContent
389 - * @return 1:文本 2:图片 3.网页 4:点播音频 386 + * @return
390 */ 387 */
391 public void contentFilter(ShyContent shyContent) { 388 public void contentFilter(ShyContent shyContent) {
392 try { 389 try {
@@ -403,7 +400,7 @@ public class ContentServiceImpl { @@ -403,7 +400,7 @@ public class ContentServiceImpl {
403 shyYidun.setUrl(contentUrl); 400 shyYidun.setUrl(contentUrl);
404 shyYidun.setTask_id(taskId); 401 shyYidun.setTask_id(taskId);
405 shyYidun.setData_id(dataId); 402 shyYidun.setData_id(dataId);
406 - shyYidun.setCheck_type(3); 403 + shyYidun.setCheck_type(CommonConstStates.WANGYE);
407 shyYidun.setContent_id(shyContent.getId().toString()); 404 shyYidun.setContent_id(shyContent.getId().toString());
408 shyYidun.setCreate_time(new Date()); 405 shyYidun.setCreate_time(new Date());
409 logger.info("审核云保存到ShyYidun表里数据:{}", JSON.toJSONString(shyYidun)); 406 logger.info("审核云保存到ShyYidun表里数据:{}", JSON.toJSONString(shyYidun));
src/main/java/com/cnlive/shenhe/serviceImpl/VideosServiceImpl.java
@@ -12,10 +12,7 @@ import com.cnlive.shenhe.entity.ShyVideos; @@ -12,10 +12,7 @@ import com.cnlive.shenhe.entity.ShyVideos;
12 import com.cnlive.shenhe.entity.ShyYidun; 12 import com.cnlive.shenhe.entity.ShyYidun;
13 import com.cnlive.shenhe.mapper.ShyUsersMapper; 13 import com.cnlive.shenhe.mapper.ShyUsersMapper;
14 import com.cnlive.shenhe.mapper.ShyVideosMapper; 14 import com.cnlive.shenhe.mapper.ShyVideosMapper;
15 -import com.cnlive.shenhe.utils.AuditPass;  
16 -import com.cnlive.shenhe.utils.CommonConst;  
17 -import com.cnlive.shenhe.utils.CommonUtils;  
18 -import com.cnlive.shenhe.utils.YiDunAntiFraudUtil; 15 +import com.cnlive.shenhe.utils.*;
19 import com.github.pagehelper.PageHelper; 16 import com.github.pagehelper.PageHelper;
20 import com.github.pagehelper.PageInfo; 17 import com.github.pagehelper.PageInfo;
21 import org.apache.ibatis.session.RowBounds; 18 import org.apache.ibatis.session.RowBounds;
@@ -28,7 +25,10 @@ import org.springframework.util.StringUtils; @@ -28,7 +25,10 @@ import org.springframework.util.StringUtils;
28 import tk.mybatis.mapper.entity.Example; 25 import tk.mybatis.mapper.entity.Example;
29 26
30 import java.text.ParseException; 27 import java.text.ParseException;
31 -import java.util.*; 28 +import java.util.Arrays;
  29 +import java.util.Date;
  30 +import java.util.List;
  31 +import java.util.UUID;
32 32
33 /** 33 /**
34 * @Auther: chenhao 34 * @Auther: chenhao
@@ -332,9 +332,9 @@ public class VideosServiceImpl { @@ -332,9 +332,9 @@ public class VideosServiceImpl {
332 332
333 /** 333 /**
334 * 易盾视频(图片)过滤 334 * 易盾视频(图片)过滤
335 - * 335 + * type:1:文本 2:图片 3.网页 4:点播音频
336 * @param cid 审核云中视频的id 336 * @param cid 审核云中视频的id
337 - * @return 1:文本 2:图片 3.网页 4:点播音频 337 + * @return
338 */ 338 */
339 public int videoFilter(Integer cid) { 339 public int videoFilter(Integer cid) {
340 ShyVideos shyVideos = shyVideosMapper.selectByPrimaryKey(cid); 340 ShyVideos shyVideos = shyVideosMapper.selectByPrimaryKey(cid);
@@ -384,7 +384,7 @@ public class VideosServiceImpl { @@ -384,7 +384,7 @@ public class VideosServiceImpl {
384 shyYidun.setUrl(url); 384 shyYidun.setUrl(url);
385 shyYidun.setDesc_msg(desc); 385 shyYidun.setDesc_msg(desc);
386 //校验图片类型 386 //校验图片类型
387 - shyYidun.setCheck_type(2); 387 + shyYidun.setCheck_type(CommonConstStates.TUPIAN);
388 shyYidun.setDuration(shyVideos.getDuration()); 388 shyYidun.setDuration(shyVideos.getDuration());
389 shyYidun.setCreate_time(new Date()); 389 shyYidun.setCreate_time(new Date());
390 390
@@ -400,7 +400,7 @@ public class VideosServiceImpl { @@ -400,7 +400,7 @@ public class VideosServiceImpl {
400 * 更新点播和审核的视频状态 400 * 更新点播和审核的视频状态
401 * 401 *
402 * @param video 402 * @param video
403 - * @param dianboState 视频状态,3通过,4不通过 403 + * @param dianboState 视频状态,1通过,2不通过
404 * @return 404 * @return
405 */ 405 */
406 public int updateDianboAndShenhe(ShyVideos video, int dianboState) { 406 public int updateDianboAndShenhe(ShyVideos video, int dianboState) {
@@ -413,7 +413,7 @@ public class VideosServiceImpl { @@ -413,7 +413,7 @@ public class VideosServiceImpl {
413 String callback = video.getCallback(); 413 String callback = video.getCallback();
414 if (callback.contains("bc.cnlive.com")) { 414 if (callback.contains("bc.cnlive.com")) {
415 if ("0".equals(errorCode)) { 415 if ("0".equals(errorCode)) {
416 - if (dianboState == 3) { 416 + if (dianboState == CommonConst.AUDIT_SUCCESS) {
417 shenheState = CommonConst.AUDIT_SUCCESS; 417 shenheState = CommonConst.AUDIT_SUCCESS;
418 } 418 }
419 //修改审核云的视频状态 419 //修改审核云的视频状态
@@ -429,7 +429,7 @@ public class VideosServiceImpl { @@ -429,7 +429,7 @@ public class VideosServiceImpl {
429 } 429 }
430 } else { 430 } else {
431 if (0 == code) { 431 if (0 == code) {
432 - if (dianboState == 3) { 432 + if (dianboState == CommonConst.AUDIT_SUCCESS) {
433 shenheState = CommonConst.AUDIT_SUCCESS; 433 shenheState = CommonConst.AUDIT_SUCCESS;
434 } 434 }
435 //修改审核云的视频状态 435 //修改审核云的视频状态
src/main/java/com/cnlive/shenhe/utils/CommonConstStates.java
@@ -46,8 +46,6 @@ public class CommonConstStates { @@ -46,8 +46,6 @@ public class CommonConstStates {
46 */ 46 */
47 public static Integer QUANBU = 0; 47 public static Integer QUANBU = 0;
48 48
49 -  
50 - //是否显示 0:不显示 1:显示  
51 /** 49 /**
52 * 是否显示 0:不显示 1:显示 50 * 是否显示 0:不显示 1:显示
53 */ 51 */
@@ -57,8 +55,6 @@ public class CommonConstStates { @@ -57,8 +55,6 @@ public class CommonConstStates {
57 */ 55 */
58 public static Integer SHIFOU_XIANSHIYES = 1; 56 public static Integer SHIFOU_XIANSHIYES = 1;
59 57
60 -  
61 - //商务模式:0免费 1收费  
62 /** 58 /**
63 * 商务模式:0免费 1收费 59 * 商务模式:0免费 1收费
64 */ 60 */
@@ -68,8 +64,6 @@ public class CommonConstStates { @@ -68,8 +64,6 @@ public class CommonConstStates {
68 */ 64 */
69 public static Integer SHOUFEI = 1; 65 public static Integer SHOUFEI = 1;
70 66
71 - //0表示正常 1表示下线  
72 -  
73 /** 67 /**
74 * 0表示正常 1表示下线 68 * 0表示正常 1表示下线
75 */ 69 */
@@ -78,4 +72,24 @@ public class CommonConstStates { @@ -78,4 +72,24 @@ public class CommonConstStates {
78 * 0表示正常 1表示下线 72 * 0表示正常 1表示下线
79 */ 73 */
80 public static Integer XIAXIAN = 1; 74 public static Integer XIAXIAN = 1;
  75 +
  76 +
  77 + /**
  78 + * 1:文本 2:图片 3.网页 4:点播音频
  79 + */
  80 + public static Integer DIANBOYINPIN = 4;
  81 + /**
  82 + * 1:文本 2:图片 3.网页 4:点播音频
  83 + */
  84 + public static Integer WANGYE = 3;
  85 + /**
  86 + * 1:文本 2:图片 3.网页 4:点播音频
  87 + */
  88 + public static Integer TUPIAN = 2;
  89 + /**
  90 + * 1:文本 2:图片 3.网页 4:点播音频
  91 + */
  92 + public static Integer WENBEN = 1;
  93 +
  94 +
81 } 95 }