Commit e0c102fba0d5ff8b3a770e4c42f28bdf571228a0
1 parent
f5af8407
易盾网站审核update
Showing
4 changed files
with
90 additions
and
82 deletions
src/main/java/com/cnlive/shenhe/job/ContentJob.java
| ... | ... | @@ -67,12 +67,12 @@ public class ContentJob { |
| 67 | 67 | List<ShyContent> shyContentList = contentService.findshyContent(shyContent); |
| 68 | 68 | if (shyContentList != null && shyContentList.size() > 0) { |
| 69 | 69 | for (ShyContent content : shyContentList) { |
| 70 | - logger.info("定时发送易盾检测的content_id:" + content.getId()); | |
| 71 | 70 | //易盾网站过滤 |
| 72 | 71 | ShyYidun shyYidun = new ShyYidun(); |
| 73 | 72 | shyYidun.setContent_id(content.getId().toString()); |
| 74 | 73 | ShyYidun shyYidun1 = yiDunServiceImpl.getidunMsgByContentId(shyYidun); |
| 75 | 74 | if (shyYidun1 == null) { |
| 75 | + logger.info("定时发送易盾检测的content_id:" + content.getId()); | |
| 76 | 76 | contentService.contentFilter(content); |
| 77 | 77 | } |
| 78 | 78 | } | ... | ... |
src/main/java/com/cnlive/shenhe/job/YiDunUrlResultJob.java
| ... | ... | @@ -56,93 +56,101 @@ public class YiDunUrlResultJob { |
| 56 | 56 | */ |
| 57 | 57 | @Scheduled(cron = "0 0/1 * * * ? ")//每分钟一次 |
| 58 | 58 | public void YiDunUrl() { |
| 59 | - Map<String, String> params = new HashMap<String, String>(5); | |
| 60 | - // 1.设置公共参数 | |
| 61 | - params.put("secretId", SECRETID); | |
| 62 | - params.put("version", "v1.0"); | |
| 63 | - params.put("timestamp", String.valueOf(System.currentTimeMillis())); | |
| 64 | - params.put("nonce", String.valueOf(new Random().nextInt())); | |
| 59 | + try { | |
| 60 | + Map<String, String> params = new HashMap<String, String>(5); | |
| 61 | + // 1.设置公共参数 | |
| 62 | + params.put("secretId", SECRETID); | |
| 63 | + params.put("version", "v1.0"); | |
| 64 | + params.put("timestamp", String.valueOf(System.currentTimeMillis())); | |
| 65 | + params.put("nonce", String.valueOf(new Random().nextInt())); | |
| 65 | 66 | |
| 66 | - // 2.生成签名信息 | |
| 67 | - String signature1 = YiDunAntiFraudUtil.genSignature(SECRETKEY, params); | |
| 68 | - params.put("signature", signature1); | |
| 67 | + // 2.生成签名信息 | |
| 68 | + String signature1 = YiDunAntiFraudUtil.genSignature(SECRETKEY, params); | |
| 69 | + params.put("signature", signature1); | |
| 69 | 70 | |
| 70 | - // 3.发送HTTP请求 | |
| 71 | - String s1 = HttpClientUtils.post_str(URL_RESULT, params); | |
| 72 | - logger.info("查询易盾网站检测结果:{}", s1); | |
| 71 | + // 3.发送HTTP请求 | |
| 72 | + String s1 = HttpClientUtils.post_str(URL_RESULT, params); | |
| 73 | + logger.info("查询易盾网站检测结果:{}", s1); | |
| 73 | 74 | |
| 74 | - // 4.解析接口返回值 | |
| 75 | - JSONObject resultObject = JSONObject.parseObject(s1); | |
| 76 | - int code = resultObject.getIntValue("code"); | |
| 77 | - String msg = resultObject.getString("msg"); | |
| 78 | - //易盾返回结果的类型 | |
| 79 | - String type; | |
| 80 | - //易盾失败结果的详情 | |
| 81 | - String desc = ""; | |
| 82 | - if (code == 200 && "ok".equals(msg)) { | |
| 83 | - JSONArray resultJSONArray = resultObject.getJSONArray("result"); | |
| 84 | - for (int i = 0; i < resultJSONArray.size(); i++) { | |
| 85 | - ShyContent shyContent = new ShyContent(); | |
| 86 | - JSONObject jsonObject = resultJSONArray.getJSONObject(i); | |
| 87 | - String dataId = jsonObject.getString("dataId"); | |
| 88 | - ShyYidun yiDunMsg = yiDunServiceImpl.getYiDunMsg(dataId); | |
| 89 | - ShyYidun newYiDunMsg = new ShyYidun(); | |
| 90 | - newYiDunMsg.setId(yiDunMsg.getId()); | |
| 91 | - newYiDunMsg.setDuration(-1); | |
| 92 | - newYiDunMsg.setUpdate_time(new Date()); | |
| 93 | - //检测结果, 1:正常(建议通过) 2:异常(建议拦截) 3:疑似(建议人工确认)0:无结果(检测失败) | |
| 94 | - int result = jsonObject.getIntValue("result"); | |
| 95 | - newYiDunMsg.setResult_type(String.valueOf(result)); | |
| 96 | - if (result == 1) { | |
| 97 | - desc = "数美审核通过了"; | |
| 98 | - shyContent.setShenhe_msg(desc); | |
| 99 | - newYiDunMsg.setDesc_msg(desc); | |
| 100 | - //修改图文状态 | |
| 101 | - contentServiceImpl.callback(newYiDunMsg.getContent_id(), desc, CommonConst.AUDIT_SUCCESS, "", "机审通过"); | |
| 102 | - } else { | |
| 103 | - JSONObject evidences = jsonObject.getJSONObject("evidences"); | |
| 104 | - JSONArray texts = evidences.getJSONArray("texts"); | |
| 105 | - if (texts != null && texts.size() > 0) { | |
| 106 | - for (int j = 0; j < texts.size(); j++) { | |
| 107 | - JSONObject jsonObject1 = texts.getJSONObject(j); | |
| 108 | - //检测结果,0:通过,1:嫌疑,2:不通过 | |
| 109 | - int action = jsonObject1.getIntValue("action"); | |
| 110 | - if (action == 1) { | |
| 111 | - desc = desc + "文字嫌疑"; | |
| 112 | - break; | |
| 75 | + // 4.解析接口返回值 | |
| 76 | + JSONObject resultObject = JSONObject.parseObject(s1); | |
| 77 | + int code = resultObject.getIntValue("code"); | |
| 78 | + String msg = resultObject.getString("msg"); | |
| 79 | + //易盾返回结果的类型 | |
| 80 | + String type; | |
| 81 | + //易盾失败结果的详情 | |
| 82 | + String desc = ""; | |
| 83 | + if (code == 200 && "ok".equals(msg)) { | |
| 84 | + JSONArray resultJSONArray = resultObject.getJSONArray("result"); | |
| 85 | + if(resultJSONArray!=null&&resultJSONArray.size()>0){ | |
| 86 | + for (int i = 0; i < resultJSONArray.size(); i++) { | |
| 87 | + ShyContent shyContent = new ShyContent(); | |
| 88 | + JSONObject jsonObject = resultJSONArray.getJSONObject(i); | |
| 89 | + String dataId = jsonObject.getString("dataId"); | |
| 90 | + ShyYidun yiDunMsg = yiDunServiceImpl.getYiDunMsg(dataId); | |
| 91 | + ShyYidun newYiDunMsg = new ShyYidun(); | |
| 92 | + newYiDunMsg.setId(yiDunMsg.getId()); | |
| 93 | + newYiDunMsg.setDuration(-1); | |
| 94 | + newYiDunMsg.setUpdate_time(new Date()); | |
| 95 | + shyContent.setId(Integer.valueOf(yiDunMsg.getContent_id())); | |
| 96 | + //检测结果, 1:正常(建议通过) 2:异常(建议拦截) 3:疑似(建议人工确认)0:无结果(检测失败) | |
| 97 | + int result = jsonObject.getIntValue("result"); | |
| 98 | + newYiDunMsg.setResult_type(String.valueOf(result)); | |
| 99 | + if (result == 1) { | |
| 100 | + desc = "易盾审核通过了"; | |
| 101 | + shyContent.setShenhe_msg(desc); | |
| 102 | + newYiDunMsg.setDesc_msg(desc); | |
| 103 | + //修改图文状态 | |
| 104 | + contentServiceImpl.callback(yiDunMsg.getContent_id(), desc, CommonConst.AUDIT_SUCCESS, "", "机审通过"); | |
| 105 | + } else { | |
| 106 | + JSONObject evidences = jsonObject.getJSONObject("evidences"); | |
| 107 | + JSONArray texts = evidences.getJSONArray("texts"); | |
| 108 | + if (texts != null && texts.size() > 0) { | |
| 109 | + for (int j = 0; j < texts.size(); j++) { | |
| 110 | + JSONObject jsonObject1 = texts.getJSONObject(j); | |
| 111 | + //检测结果,0:通过,1:嫌疑,2:不通过 | |
| 112 | + int action = jsonObject1.getIntValue("action"); | |
| 113 | + if (action == 1) { | |
| 114 | + desc = desc + "文字嫌疑"; | |
| 115 | + break; | |
| 116 | + } | |
| 117 | + if (action == 2) { | |
| 118 | + desc = desc + "文字违规"; | |
| 119 | + break; | |
| 120 | + } | |
| 121 | + } | |
| 113 | 122 | } |
| 114 | - if (action == 2) { | |
| 115 | - desc = desc + "文字不通过"; | |
| 116 | - break; | |
| 117 | - } | |
| 118 | - } | |
| 119 | - } | |
| 120 | - JSONArray images = evidences.getJSONArray("images"); | |
| 121 | - if (images != null && images.size() > 0) { | |
| 122 | - for (int k = 0; k < images.size(); k++){ | |
| 123 | - JSONObject jsonObject1 = images.getJSONObject(k); | |
| 124 | - //0:正常,1:不确定,2:确定 | |
| 125 | - int level = jsonObject1.getIntValue("level"); | |
| 126 | - if (level == 1) { | |
| 127 | - desc = desc + "图片嫌疑"; | |
| 128 | - break; | |
| 129 | - } | |
| 130 | - if (level == 2) { | |
| 131 | - desc = desc + "图片不通过"; | |
| 132 | - break; | |
| 123 | + JSONArray images = evidences.getJSONArray("images"); | |
| 124 | + if (images != null && images.size() > 0) { | |
| 125 | + for (int k = 0; k < images.size(); k++){ | |
| 126 | + JSONObject jsonObject1 = images.getJSONObject(k); | |
| 127 | + //0:正常,1:不确定,2:确定 | |
| 128 | + int level = jsonObject1.getIntValue("level"); | |
| 129 | + if (level == 1) { | |
| 130 | + desc = desc + "图片嫌疑"; | |
| 131 | + break; | |
| 132 | + } | |
| 133 | + if (level == 2) { | |
| 134 | + desc = desc + "图片违规"; | |
| 135 | + break; | |
| 136 | + } | |
| 137 | + } | |
| 133 | 138 | } |
| 139 | + | |
| 140 | + //审核类型改为人工审核 | |
| 141 | + shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_USER); | |
| 142 | + //拒绝原因 | |
| 143 | + shyContent.setShenhe_msg(desc); | |
| 144 | + newYiDunMsg.setDesc_msg(desc); | |
| 145 | + contentServiceImpl.updateshyContent(shyContent); | |
| 146 | + desc=""; | |
| 134 | 147 | } |
| 148 | + yiDunServiceImpl.updateYiDunMsg(newYiDunMsg); | |
| 135 | 149 | } |
| 136 | - | |
| 137 | - //审核类型改为人工审核 | |
| 138 | - shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_USER); | |
| 139 | - //拒绝原因 | |
| 140 | - shyContent.setShenhe_msg(desc); | |
| 141 | - newYiDunMsg.setDesc_msg(desc); | |
| 142 | - contentServiceImpl.updateshyContent(shyContent); | |
| 143 | 150 | } |
| 144 | - yiDunServiceImpl.updateYiDunMsg(newYiDunMsg); | |
| 145 | 151 | } |
| 152 | + } catch (Exception e) { | |
| 153 | + e.printStackTrace(); | |
| 146 | 154 | } |
| 147 | 155 | |
| 148 | 156 | } | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/ContentServiceImpl.java
| ... | ... | @@ -74,7 +74,7 @@ public class ContentServiceImpl { |
| 74 | 74 | |
| 75 | 75 | //*************************** |
| 76 | 76 | public boolean updateshyContent(ShyContent shyContent) { |
| 77 | - int result = shyContentMapper.updateByPrimaryKey(shyContent); | |
| 77 | + int result = shyContentMapper.updateByPrimaryKeySelective(shyContent); | |
| 78 | 78 | if (result == 0) { |
| 79 | 79 | return false; |
| 80 | 80 | } |
| ... | ... | @@ -369,7 +369,7 @@ public class ContentServiceImpl { |
| 369 | 369 | ShyYidun shyYidun = new ShyYidun(); |
| 370 | 370 | shyYidun.setId(dataId); |
| 371 | 371 | shyYidun.setUrl(contentUrl); |
| 372 | - shyYidun.setContent_id(shyContent.getContent_id()); | |
| 372 | + shyYidun.setContent_id(shyContent.getId().toString()); | |
| 373 | 373 | shyYidun.setCreate_time(new Date()); |
| 374 | 374 | yiDunServiceImpl.addYiDunMsg(shyYidun); |
| 375 | 375 | } | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/YiDunServiceImpl.java
| ... | ... | @@ -35,7 +35,7 @@ public class YiDunServiceImpl { |
| 35 | 35 | if (CommonUtils.isNotNull(shyContentList) && shyContentList.size() > 0) { |
| 36 | 36 | return shyContentList.get(0); |
| 37 | 37 | } |
| 38 | - return new ShyYidun(); | |
| 38 | + return null; | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public ShyYidun getYiDunMsg(String dataId) { | ... | ... |