Commit 4e201c1f1d6caaf0a7d6823832341a34acc835ee
1 parent
5c8453b0
图文免审和机审
Showing
8 changed files
with
103 additions
and
11 deletions
src/main/java/com/cnlive/shenhe/api/ContentControllerApi.java
| ... | ... | @@ -48,12 +48,15 @@ public class ContentControllerApi { |
| 48 | 48 | shyContent.setContent_id(json.getString("contentId")); |
| 49 | 49 | shyContent.setContent_tag("content");//图文标签 |
| 50 | 50 | List<ShyContent> contentList = contentService.findshyContent(shyContent); |
| 51 | + | |
| 52 | + //获取审核类型 | |
| 53 | + Integer shenheType = contentService.getShenheType(json.getInteger("spId")); | |
| 51 | 54 | //存在则更新 |
| 52 | 55 | if (contentList.size() > 0) { |
| 53 | 56 | ShyContent shyContent1 = contentList.get(0); |
| 54 | 57 | shyContent1.setTitle(json.getString("title"));//标题 |
| 55 | 58 | shyContent1.setTitle_image(json.getString("titleImage"));//标题图片 |
| 56 | - shyContent1.setShenhe_type(CommonConst.AUDIT_TYPE_USER);//审核类型是人工 | |
| 59 | + shyContent1.setShenhe_type(shenheType);//审核类型 | |
| 57 | 60 | shyContent1.setContent_status(json.getInteger("contentStatus"));//当前图文的审核状态 |
| 58 | 61 | shyContent1.setSource(json.getString("source"));//来源 |
| 59 | 62 | shyContent1.setAuthor(json.getString("author"));//作者 |
| ... | ... | @@ -83,7 +86,7 @@ public class ContentControllerApi { |
| 83 | 86 | //如果不存在直接插入 |
| 84 | 87 | shyContent.setTitle(json.getString("title"));//标题 |
| 85 | 88 | shyContent.setTitle_image(json.getString("titleImage"));//标题图片 |
| 86 | - shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_USER);//审核类型是人工 | |
| 89 | + shyContent.setShenhe_type(shenheType);//审核类型 | |
| 87 | 90 | shyContent.setContent_status(json.getInteger("contentStatus"));//当前图文的审核状态 |
| 88 | 91 | shyContent.setSource(json.getString("source"));//来源 |
| 89 | 92 | shyContent.setAuthor(json.getString("author"));//作者 |
| ... | ... | @@ -123,12 +126,14 @@ public class ContentControllerApi { |
| 123 | 126 | shyContent.setContent_id(json.getString("momentId"));//朋友圈id |
| 124 | 127 | shyContent.setContent_tag("moment");//朋友圈标签 |
| 125 | 128 | List<ShyContent> contentList = contentService.findshyContent(shyContent); |
| 129 | + //获取审核类型 | |
| 130 | + Integer shenheType = contentService.getShenheType(json.getInteger("spId")); | |
| 126 | 131 | //存在则更新 |
| 127 | 132 | if (contentList.size() > 0) { |
| 128 | 133 | ShyContent shyContent1 = contentList.get(0); |
| 129 | 134 | shyContent1.setTitle(json.getString("title"));//标题 |
| 130 | 135 | shyContent1.setTitle_image(json.getString("image"));//用户头像 |
| 131 | - shyContent1.setShenhe_type(CommonConst.AUDIT_TYPE_USER);//审核类型是人工 | |
| 136 | + shyContent1.setShenhe_type(shenheType);//审核类型 | |
| 132 | 137 | String contentTime = json.getString("createTime");//朋友圈内容创建时间 |
| 133 | 138 | if (CommonUtils.isNotEmpty(contentTime)) { |
| 134 | 139 | // Date timestamp = CommonUtils.getTimestamp(contentTime, "yyyy-MM-dd HH:mm:ss"); |
| ... | ... | @@ -158,7 +163,7 @@ public class ContentControllerApi { |
| 158 | 163 | //如果不存在直接插入 |
| 159 | 164 | shyContent.setTitle(json.getString("title"));//标题 |
| 160 | 165 | shyContent.setTitle_image(json.getString("image"));//用户头像 |
| 161 | - shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_USER);//审核类型是人工 | |
| 166 | + shyContent.setShenhe_type(shenheType);//审核类型 | |
| 162 | 167 | shyContent.setContent_status(1);//当前朋友圈内容的审核状态,先发后审 |
| 163 | 168 | String contentTime = json.getString("createTime");//创建时间 |
| 164 | 169 | if (CommonUtils.isNotEmpty(contentTime)) { | ... | ... |
src/main/java/com/cnlive/shenhe/controller/SitesController.java
| ... | ... | @@ -79,7 +79,7 @@ public class SitesController { |
| 79 | 79 | ShySites site = sitesService.get(siteId); |
| 80 | 80 | SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey()); |
| 81 | 81 | Integer spid = sessionUser.getSpid(); |
| 82 | - if ((!sessionUser.isMaster() && spid != 0) || (sessionUser.isMaster() && site.getSpid() != spid)) { | |
| 82 | + if ((!sessionUser.isMaster() && spid != 0) ) { | |
| 83 | 83 | return "page/error.html"; |
| 84 | 84 | } |
| 85 | 85 | String write = ""; | ... | ... |
src/main/java/com/cnlive/shenhe/job/ContentJob.java
| ... | ... | @@ -39,7 +39,7 @@ public class ContentJob { |
| 39 | 39 | /** |
| 40 | 40 | * 白名单sp图文通过 |
| 41 | 41 | */ |
| 42 | -// @Scheduled(fixedRate = 60 * 1000) | |
| 42 | + @Scheduled(fixedRate = 60 * 1000) | |
| 43 | 43 | public void updateVideos() { |
| 44 | 44 | ShyContent shyContent = new ShyContent(); |
| 45 | 45 | shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_FREE);// 审核类型为免审 |
| ... | ... | @@ -58,7 +58,7 @@ public class ContentJob { |
| 58 | 58 | /** |
| 59 | 59 | * 定时发送数美检测视频 |
| 60 | 60 | */ |
| 61 | -// @Scheduled(cron="0 0/1 10-23 * * ? ")//每天10点到23点执行,每分钟一次 | |
| 61 | + @Scheduled(cron="0 0/1 10-23 * * ? ")//每天10点到23点执行,每分钟一次 | |
| 62 | 62 | public void videofilter() { |
| 63 | 63 | ShyContent shyContent = new ShyContent(); |
| 64 | 64 | shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_MACHANE);//审核类型为机审 |
| ... | ... | @@ -68,7 +68,7 @@ public class ContentJob { |
| 68 | 68 | for (ShyContent content : shyContentList) { |
| 69 | 69 | logger.info("定时发送数美检测的content_id:"+content.getId()); |
| 70 | 70 | //数美图片过滤 |
| 71 | -// videosService.videoFilter(video.getId(),CommonConst.DYNAMIC_USER); | |
| 71 | + contentService.contentFilter(content,""); | |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | } | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
| ... | ... | @@ -255,7 +255,7 @@ public class CommentsServiceImpl { |
| 255 | 255 | */ |
| 256 | 256 | public void getShenheType(ShyComments shyComments){ |
| 257 | 257 | |
| 258 | - //获取点播免审sp | |
| 258 | + //获取评论免审sp | |
| 259 | 259 | List<Integer> sites = sitesService.getBusinessList(CommonConst.BUSINESS_COMMENT); |
| 260 | 260 | //初始化一个审核状态 |
| 261 | 261 | Integer shenheType=3;//审核类型,1:免审,2:机审,3:人工审 | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/ContentServiceImpl.java
| 1 | 1 | package com.cnlive.shenhe.serviceImpl; |
| 2 | 2 | |
| 3 | +import com.alibaba.fastjson.JSONArray; | |
| 3 | 4 | import com.alibaba.fastjson.JSONObject; |
| 4 | 5 | import com.cnlive.shenhe.entity.ShyComments; |
| 5 | 6 | import com.cnlive.shenhe.entity.ShyContent; |
| 6 | 7 | import com.cnlive.shenhe.entity.ShyLive; |
| 7 | 8 | import com.cnlive.shenhe.entity.ShySites; |
| 8 | 9 | import com.cnlive.shenhe.entity.ShyUsers; |
| 10 | +import com.cnlive.shenhe.entity.ShyVideofilter; | |
| 9 | 11 | import com.cnlive.shenhe.entity.ShyVideos; |
| 10 | 12 | import com.cnlive.shenhe.mapper.ShyCommentsMapper; |
| 11 | 13 | import com.cnlive.shenhe.mapper.ShyContentMapper; |
| 12 | 14 | import com.cnlive.shenhe.mapper.ShySitesMapper; |
| 13 | 15 | import com.cnlive.shenhe.mapper.ShyUsersMapper; |
| 16 | +import com.cnlive.shenhe.utils.AntiFraudUtil; | |
| 14 | 17 | import com.cnlive.shenhe.utils.AuditPass; |
| 15 | 18 | import com.cnlive.shenhe.utils.CommonConst; |
| 16 | 19 | import com.cnlive.shenhe.utils.CommonUtils; |
| ... | ... | @@ -25,8 +28,12 @@ import tk.mybatis.mapper.entity.Example; |
| 25 | 28 | |
| 26 | 29 | import java.sql.Timestamp; |
| 27 | 30 | import java.text.ParseException; |
| 31 | +import java.util.ArrayList; | |
| 28 | 32 | import java.util.Date; |
| 33 | +import java.util.HashMap; | |
| 29 | 34 | import java.util.List; |
| 35 | +import java.util.Map; | |
| 36 | +import java.util.UUID; | |
| 30 | 37 | |
| 31 | 38 | /** |
| 32 | 39 | * @Auther: liwei |
| ... | ... | @@ -51,6 +58,8 @@ public class ContentServiceImpl { |
| 51 | 58 | SitesServiceImpl sitesService; |
| 52 | 59 | @Autowired |
| 53 | 60 | VideosServiceImpl videosService; |
| 61 | + @Autowired | |
| 62 | + VideofilterServiceImpl videofilterServiceImpl; | |
| 54 | 63 | |
| 55 | 64 | public ShyContent getShyContent(ShyContent shyContent) { |
| 56 | 65 | List<ShyContent> shyContentList = shyContentMapper.select(shyContent); |
| ... | ... | @@ -320,6 +329,70 @@ public class ContentServiceImpl { |
| 320 | 329 | public int updateByPrimaryKeySelective(ShyContent content) { |
| 321 | 330 | return shyContentMapper.updateByPrimaryKeySelective(content); |
| 322 | 331 | } |
| 332 | + | |
| 333 | + /** | |
| 334 | + * 获得审核类型 | |
| 335 | + * @param spId | |
| 336 | + */ | |
| 337 | + public Integer getShenheType(Integer spId){ | |
| 338 | + | |
| 339 | + //获取图文免审sp | |
| 340 | + List<Integer> sites = sitesService.getBusinessList(CommonConst.BUSINESS_CONTENT); | |
| 341 | + //初始化一个审核状态 | |
| 342 | + Integer shenheType=3;//审核类型,1:免审,2:机审,3:人工审 | |
| 343 | + //如果当前sp是免审sp | |
| 344 | + if(sites.contains(spId)){ | |
| 345 | + shenheType=1;//免审 | |
| 346 | + }else{ | |
| 347 | + shenheType=2;//机审 | |
| 348 | + } | |
| 349 | + return shenheType; | |
| 350 | + } | |
| 351 | + | |
| 352 | + /** | |
| 353 | + * 数美视频(图片)过滤 | |
| 354 | + * @param cid 审核云中图文id | |
| 355 | + * @param channel 尺度 | |
| 356 | + * @return | |
| 357 | + */ | |
| 358 | + public int contentFilter(ShyContent shyContent,String channel){ | |
| 359 | + | |
| 360 | + JSONObject result = null;//数美返回结果 | |
| 361 | + String type="";//数美返回结果的类型 | |
| 362 | + String desc="";//数美失败结果的详情 | |
| 363 | + String Token_id=UUID.randomUUID().toString(); | |
| 364 | + try{ | |
| 365 | + //调用数美接口 | |
| 366 | + result = AntiFraudUtil.filterArticle(Token_id,shyContent.getContent_url(),channel); | |
| 367 | + type=result.getString("type"); | |
| 368 | + desc=result.getString("desc");//数美失败结果的详情 | |
| 369 | + }catch(Exception e){ | |
| 370 | + type=CommonConst.REJECT;//报错就给一个拒绝状态 | |
| 371 | + desc="数美审核报错了"; | |
| 372 | + } | |
| 373 | + if(type.toLowerCase().equals(CommonConst.PASS)){//数美通过 | |
| 374 | + desc="数美审核通过了"; | |
| 375 | + shyContent.setShenhe_msg(desc); | |
| 376 | + //修改图文状态 | |
| 377 | + callback(shyContent.getId().toString(),desc,CommonConst.AUDIT_SUCCESS,""); | |
| 378 | + }else if(type.toLowerCase().equals(CommonConst.REJECT)){//数美拒绝 | |
| 379 | + shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_USER);//审核类型改为人工审核 | |
| 380 | + shyContent.setShenhe_msg(desc);//拒绝原因 | |
| 381 | + updateshyContent(shyContent); | |
| 382 | +// videosService.updateDianboAndShenhe(shyVideos,4); | |
| 383 | + } | |
| 384 | + ShyVideofilter videofilter=new ShyVideofilter(); | |
| 385 | + videofilter.setChannel(channel); | |
| 386 | + videofilter.setDesc_msg(desc); | |
| 387 | + videofilter.setResult_type(type); | |
| 388 | + videofilter.setToken_id(Token_id); | |
| 389 | + videofilter.setVideos_id(shyContent.getId()); | |
| 390 | + videofilter.setDuration(-1); | |
| 391 | + videofilter.setCreated_at(CommonUtils.getCurrentTime()); | |
| 392 | + videofilterServiceImpl.impotVideofilter(videofilter); | |
| 393 | + | |
| 394 | + return 0; | |
| 395 | + } | |
| 323 | 396 | |
| 324 | 397 | } |
| 325 | 398 | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/SitesServiceImpl.java
| ... | ... | @@ -30,15 +30,18 @@ public class SitesServiceImpl { |
| 30 | 30 | public PageInfo<ShySites> getPage(Integer page, Integer pageSize, String orderByClause, String key, Integer spId) { |
| 31 | 31 | Example example = new Example(ShySites.class); |
| 32 | 32 | Example.Criteria criteria = example.createCriteria(); |
| 33 | + Example.Criteria criteria2 = example.createCriteria(); | |
| 33 | 34 | if (CommonUtils.isNotEmpty(orderByClause)) { |
| 34 | 35 | example.setOrderByClause(orderByClause); |
| 35 | 36 | } |
| 36 | 37 | if (CommonUtils.isNotEmpty(key)) { |
| 37 | 38 | criteria.andLike("name", "%" + key + "%"); |
| 38 | - criteria.andLike("company", "%" + key + "%"); | |
| 39 | + criteria2.andLike("spid", "%" + key + "%"); | |
| 40 | + example.or(criteria2); | |
| 39 | 41 | } |
| 40 | 42 | if (CommonUtils.isNotNull(spId)) |
| 41 | 43 | criteria.andEqualTo("spid", spId); |
| 44 | + criteria2.andEqualTo("spid", spId); | |
| 42 | 45 | PageHelper.startPage(page, pageSize, true); |
| 43 | 46 | List<ShySites> shySitesList = shySitesMapper.selectByExample(example); |
| 44 | 47 | PageInfo<ShySites> pageInfo = new PageInfo<ShySites>(shySitesList); | ... | ... |
src/main/java/com/cnlive/shenhe/utils/AntiFraudUtil.java
| ... | ... | @@ -5,8 +5,12 @@ import com.alibaba.fastjson.JSONArray; |
| 5 | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | 6 | import org.apache.commons.lang3.StringUtils; |
| 7 | 7 | |
| 8 | +import java.util.HashMap; | |
| 9 | +import java.util.Map; | |
| 8 | 10 | import java.util.UUID; |
| 9 | 11 | |
| 12 | +import javax.swing.plaf.basic.BasicScrollPaneUI.HSBChangeListener; | |
| 13 | + | |
| 10 | 14 | |
| 11 | 15 | /** |
| 12 | 16 | * 数美 反欺诈工具类 |
| ... | ... | @@ -44,6 +48,13 @@ public class AntiFraudUtil { |
| 44 | 48 | //queryVideoResult("02b649b7-3451-403e-abd0-592302cec2a0"); |
| 45 | 49 | |
| 46 | 50 | try { |
| 51 | + Map<Object, Object> hashMap = new HashMap<Object, Object>(); | |
| 52 | + hashMap.put("11", "1111"); | |
| 53 | + String object = (String) hashMap.get("11"); | |
| 54 | + String object2 = (String) hashMap.get("22"); | |
| 55 | + System.out.println(object); | |
| 56 | + System.out.println(object2); | |
| 57 | + | |
| 47 | 58 | // System.out.println(addBlackContents("2222")); |
| 48 | 59 | } catch (Exception e) { |
| 49 | 60 | e.printStackTrace(); | ... | ... |
src/main/java/com/cnlive/shenhe/utils/CommonConst.java
| ... | ... | @@ -78,7 +78,7 @@ public class CommonConst { |
| 78 | 78 | */ |
| 79 | 79 | public static Integer BUSINESS_CONTENT = 3; |
| 80 | 80 | |
| 81 | - public static JSONObject BUSINESS = JSONObject.parseObject("{\"1\":\"点播业务\",\"2\":\"评论业务\"}"); | |
| 81 | + public static JSONObject BUSINESS = JSONObject.parseObject("{\"1\":\"点播业务\",\"2\":\"评论业务\",\"3\":\"图文业务\"}"); | |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * 抽帧状态:未抽帧 | ... | ... |