Commit 4fc1c133cca38264c6da73610e83aabbddfead42

Authored by 徐近程
2 parents a8c3897d e3688572

Merge branch 'dev'

# Conflicts:
#	src/main/java/com/cnlive/shenhe/serviceImpl/ContentServiceImpl.java
src/main/java/com/cnlive/shenhe/serviceImpl/ContentServiceImpl.java
... ... @@ -2,21 +2,12 @@ package com.cnlive.shenhe.serviceImpl;
2 2  
3 3 import com.alibaba.fastjson.JSONArray;
4 4 import com.alibaba.fastjson.JSONObject;
5   -import com.cnlive.shenhe.entity.ShyComments;
6   -import com.cnlive.shenhe.entity.ShyContent;
7   -import com.cnlive.shenhe.entity.ShyLive;
8   -import com.cnlive.shenhe.entity.ShySites;
9   -import com.cnlive.shenhe.entity.ShyUsers;
10   -import com.cnlive.shenhe.entity.ShyVideofilter;
11   -import com.cnlive.shenhe.entity.ShyVideos;
  5 +import com.cnlive.shenhe.entity.*;
12 6 import com.cnlive.shenhe.mapper.ShyCommentsMapper;
13 7 import com.cnlive.shenhe.mapper.ShyContentMapper;
14 8 import com.cnlive.shenhe.mapper.ShySitesMapper;
15 9 import com.cnlive.shenhe.mapper.ShyUsersMapper;
16   -import com.cnlive.shenhe.utils.AntiFraudUtil;
17   -import com.cnlive.shenhe.utils.AuditPass;
18   -import com.cnlive.shenhe.utils.CommonConst;
19   -import com.cnlive.shenhe.utils.CommonUtils;
  10 +import com.cnlive.shenhe.utils.*;
20 11 import com.github.pagehelper.PageHelper;
21 12 import com.github.pagehelper.PageInfo;
22 13 import org.apache.ibatis.session.RowBounds;
... ... @@ -61,27 +52,29 @@ public class ContentServiceImpl {
61 52 VideosServiceImpl videosService;
62 53 @Autowired
63 54 VideofilterServiceImpl videofilterServiceImpl;
64   -
  55 + @Autowired
  56 + YiDunServiceImpl yiDunServiceImpl;
  57 +
65 58 @Value("${spring.localhost.url}")
66 59 String localhost_url;
67 60  
68 61 public ShyContent getShyContent(ShyContent shyContent) {
69 62 List<ShyContent> shyContentList = shyContentMapper.select(shyContent);
70 63 if(CommonUtils.isNotNull(shyContentList)&&shyContentList.size()>0){
71   - return shyContentList.get(0);
  64 + return shyContentList.get(0);
72 65 }
73 66 return new ShyContent();
74 67 }
75 68  
76 69 //**************************************
77 70 public List<ShyContent> findshyContent(ShyContent shyContent) {
78   -
  71 +
79 72 return shyContentMapper.selectByRowBounds(shyContent, new RowBounds(0, 100));
80 73 }
81 74  
82 75 //***************************
83 76 public boolean updateshyContent(ShyContent shyContent) {
84   - int result = shyContentMapper.updateByPrimaryKey(shyContent);
  77 + int result = shyContentMapper.updateByPrimaryKeySelective(shyContent);
85 78 if (result == 0) {
86 79 return false;
87 80 }
... ... @@ -116,7 +109,7 @@ public class ContentServiceImpl {
116 109 criteria.andGreaterThanOrEqualTo("create_date", start_date);
117 110 }
118 111 if ( CommonUtils.isNotNull(end_date)) {
119   - criteria.andLessThanOrEqualTo("create_date", end_date);
  112 + criteria.andLessThanOrEqualTo("create_date", end_date);
120 113 }
121 114 if (CommonUtils.isNotEmpty(title)) {
122 115 criteria.andLike("title", "%" + title + "%");
... ... @@ -131,13 +124,13 @@ public class ContentServiceImpl {
131 124 criteria.andEqualTo("updater", updater);
132 125 }
133 126 if (CommonUtils.isNotEmpty(content_tag)) {
134   - criteria.andEqualTo("content_tag", content_tag);
  127 + criteria.andEqualTo("content_tag", content_tag);
135 128 }
136 129 if (CommonUtils.isNotNull(spid)) {
137 130 criteria.andEqualTo("sp_id", spid);
138 131 }
139 132 if (CommonUtils.isNotEmpty(contentId)) {
140   - criteria.andEqualTo("content_id", contentId);
  133 + criteria.andEqualTo("content_id", contentId);
141 134 }
142 135 if (CommonUtils.isNotNull(receive_status)) {
143 136 criteria.andEqualTo("receive_status", receive_status);
... ... @@ -151,53 +144,53 @@ public class ContentServiceImpl {
151 144 PageInfo<ShyContent> pageInfo = new PageInfo<>(contentList);
152 145 return pageInfo;
153 146 }
154   -
  147 +
155 148 /**
156 149 * 根据条件导出数据excel
157 150 * @return
158 151 */
159   - public List<ShyContent> findByCondition(String title,String content_tag,String contentId, Date start_date,
160   - Date end_date,Integer receive_status, Integer page,
161   - Integer pageSize, String orderByClause, Integer spid) {
162   -
163   - Example example = new Example(ShyContent.class);
164   - Example.Criteria criteria = example.createCriteria();
165   - if (CommonUtils.isNotEmpty(orderByClause)) {
166   - example.setOrderByClause(orderByClause);
167   - } else {
168   - example.setOrderByClause("create_date desc");
169   - }
170   - if (CommonUtils.isNotNull(start_date) ) {
171   - criteria.andGreaterThanOrEqualTo("create_date", start_date);
172   - }
173   - if ( CommonUtils.isNotNull(end_date)) {
174   - criteria.andLessThanOrEqualTo("create_date", end_date);
175   - }
176   - if (CommonUtils.isNotEmpty(title)) {
177   - criteria.andLike("title", "%" + title + "%");
178   - }
179   - if (CommonUtils.isNotNull(spid)) {
180   - criteria.andEqualTo("sp_id", spid);
181   - }
182   - if (CommonUtils.isNotEmpty(contentId)) {
183   - criteria.andEqualTo("content_id", contentId);
184   - }
185   - if (CommonUtils.isNotEmpty(content_tag)) {
186   - criteria.andEqualTo("content_tag", content_tag);
187   - }
188   - if (CommonUtils.isNotNull(receive_status)) {
189   - criteria.andEqualTo("receive_status", receive_status);
190   - }
  152 + public List<ShyContent> findByCondition(String title,String content_tag,String contentId, Date start_date,
  153 + Date end_date,Integer receive_status, Integer page,
  154 + Integer pageSize, String orderByClause, Integer spid) {
  155 +
  156 + Example example = new Example(ShyContent.class);
  157 + Example.Criteria criteria = example.createCriteria();
  158 + if (CommonUtils.isNotEmpty(orderByClause)) {
  159 + example.setOrderByClause(orderByClause);
  160 + } else {
  161 + example.setOrderByClause("create_date desc");
  162 + }
  163 + if (CommonUtils.isNotNull(start_date) ) {
  164 + criteria.andGreaterThanOrEqualTo("create_date", start_date);
  165 + }
  166 + if ( CommonUtils.isNotNull(end_date)) {
  167 + criteria.andLessThanOrEqualTo("create_date", end_date);
  168 + }
  169 + if (CommonUtils.isNotEmpty(title)) {
  170 + criteria.andLike("title", "%" + title + "%");
  171 + }
  172 + if (CommonUtils.isNotNull(spid)) {
  173 + criteria.andEqualTo("sp_id", spid);
  174 + }
  175 + if (CommonUtils.isNotEmpty(contentId)) {
  176 + criteria.andEqualTo("content_id", contentId);
  177 + }
  178 + if (CommonUtils.isNotEmpty(content_tag)) {
  179 + criteria.andEqualTo("content_tag", content_tag);
  180 + }
  181 + if (CommonUtils.isNotNull(receive_status)) {
  182 + criteria.andEqualTo("receive_status", receive_status);
  183 + }
191 184 List<ShyContent> shyContentList = shyContentMapper.selectByExample(example);
192 185 return shyContentList;
193 186 }
194   -
  187 +
195 188  
196 189 //******************************
197 190 public ShyContent getDetailsContent(Integer id) {
198   - ShyContent content = shyContentMapper.selectByPrimaryKey(id);
  191 + ShyContent content = shyContentMapper.selectByPrimaryKey(id);
199 192 if (content.getReceive_status() == CommonConst.RECEIVE_AUDIT) {
200   - String updater = CommonUtils.isEmpty(content.getUpdater()) || "null".equals(content.getUpdater())? "白名单":content.getUpdater();
  193 + String updater = CommonUtils.isEmpty(content.getUpdater()) || "null".equals(content.getUpdater())? "白名单":content.getUpdater();
201 194 String auditor_id = content.getAuditor_id();
202 195 if (CommonUtils.isNotEmpty(auditor_id)) {
203 196 ShyUsers user = new ShyUsers();
... ... @@ -210,77 +203,77 @@ public class ContentServiceImpl {
210 203 content.setUpdater(updater);
211 204 }
212 205 ShySites shySite=sitesService.findspidDescByspid(content.getSp_id());
213   - if(CommonUtils.isNotNull(shySite)){
214   - content.setSp_desc(shySite.getName());
215   - }
  206 + if(CommonUtils.isNotNull(shySite)){
  207 + content.setSp_desc(shySite.getName());
  208 + }
216 209 return content;
217 210 }
218 211  
219 212 //**********************
220   - public boolean callback(String contentId, String msg, Integer state, String userId,String updater) {
221   - boolean success = true;
222   - ShyContent content = shyContentMapper.selectByPrimaryKey(Integer.parseInt(contentId));
223   - JSONObject result = new JSONObject();
224   - try {
225   - if(CommonUtils.isNotEmpty(content.getContent_tag())&&content.getContent_tag().equals("content")){
226   - result = Pass.contentPass(content.getContent_id(), state+"", msg, content.getCallback());
227   - }else if(CommonUtils.isNotEmpty(content.getContent_tag())&&content.getContent_tag().equals("moment")){
228   - result = Pass.momentPass(content.getContent_id(), state, msg, content.getCallback(),content.getAuthor());
229   - }
230   - } catch (Exception e) {
231   - logger.error("图文审核回调失败,图文id:{}", content.getId());
232   - success = false;
233   - return success;
234   - }
235   - if (result == null) {
236   - logger.error("图文回调错误,且无返回信息。图文id:{}", content.getId());
237   - success = false;
238   - return success;
239   - } else {
240   - Integer code = result.getInteger("errorCode");
241   - if (code != 0) {
242   - logger.error("图文回调错误,图文id:{},errorCode:{},errorMessage:{}", content.getId(), code,
243   - result.getString("errorMessage"));
244   - success = false;
245   - return success;
246   - }
247   -
248   - //如果当前图文是朋友圈的视频,通知点播云
249   - if(CommonUtils.isNotEmpty(content.getContent_tag())
250   - &&content.getContent_tag().equals("moment")
251   - &&CommonUtils.isNotEmpty(content.getVideo_id())
252   - &&state==CommonConst.AUDIT_REFUSE){
253   - ShyVideos shyVideos1 = new ShyVideos();
254   - shyVideos1.setVideo_id(content.getVideo_id());
255   - List<ShyVideos> listshyVideos = videosService.findshyVideo(shyVideos1);
256   - if (listshyVideos.size() > 0) {
257   - ShyVideos shyVideos = listshyVideos.get(0);
258   - String showMsg = videosService.repulse(shyVideos.getId().toString(), msg, userId);
259   - if (CommonUtils.isNotEmpty(showMsg)) {
260   - success = false;
261   - return success;
262   - }
263   - }
264   - }
265   -
266   - content.setContent_status(state);// 设置图文状态为审核后的状态
267   - content.setReceive_status(CommonConst.RECEIVE_AUDIT);// 领取状态为已审核
268   - content.setShenhe_msg(msg);// 设置审核消息
269   - if (CommonUtils.isNotEmpty(userId)) {
270   - content.setAuditor_id(userId);
271   - content.setShenhe_type(CommonConst.AUDIT_TYPE_USER);// 设置审核类型为人工
272   - }else{
273   - content.setUpdater(updater);//设置更新人
274   - }
275   - content.setLast_update(CommonUtils.getCurrentTime());
276   - int i = shyContentMapper.updateByPrimaryKeySelective(content);
277   - if (i != 1) {
278   - success = false;
279   - }
280   - }
281   -
282   - return success;
283   - }
  213 + public boolean callback(String contentId, String msg, Integer state, String userId,String updater) {
  214 + boolean success = true;
  215 + ShyContent content = shyContentMapper.selectByPrimaryKey(Integer.parseInt(contentId));
  216 + JSONObject result = new JSONObject();
  217 + try {
  218 + if(CommonUtils.isNotEmpty(content.getContent_tag())&&content.getContent_tag().equals("content")){
  219 + result = Pass.contentPass(content.getContent_id(), state+"", msg, content.getCallback());
  220 + }else if(CommonUtils.isNotEmpty(content.getContent_tag())&&content.getContent_tag().equals("moment")){
  221 + result = Pass.momentPass(content.getContent_id(), state, msg, content.getCallback(),content.getAuthor());
  222 + }
  223 + } catch (Exception e) {
  224 + logger.error("图文审核回调失败,图文id:{}", content.getId());
  225 + success = false;
  226 + return success;
  227 + }
  228 + if (result == null) {
  229 + logger.error("图文回调错误,且无返回信息。图文id:{}", content.getId());
  230 + success = false;
  231 + return success;
  232 + } else {
  233 + Integer code = result.getInteger("errorCode");
  234 + if (code != 0) {
  235 + logger.error("图文回调错误,图文id:{},errorCode:{},errorMessage:{}", content.getId(), code,
  236 + result.getString("errorMessage"));
  237 + success = false;
  238 + return success;
  239 + }
  240 +
  241 + //如果当前图文是朋友圈的视频,通知点播云
  242 + if(CommonUtils.isNotEmpty(content.getContent_tag())
  243 + &&content.getContent_tag().equals("moment")
  244 + &&CommonUtils.isNotEmpty(content.getVideo_id())
  245 + &&state==CommonConst.AUDIT_REFUSE){
  246 + ShyVideos shyVideos1 = new ShyVideos();
  247 + shyVideos1.setVideo_id(content.getVideo_id());
  248 + List<ShyVideos> listshyVideos = videosService.findshyVideo(shyVideos1);
  249 + if (listshyVideos.size() > 0) {
  250 + ShyVideos shyVideos = listshyVideos.get(0);
  251 + String showMsg = videosService.repulse(shyVideos.getId().toString(), msg, userId);
  252 + if (CommonUtils.isNotEmpty(showMsg)) {
  253 + success = false;
  254 + return success;
  255 + }
  256 + }
  257 + }
  258 +
  259 + content.setContent_status(state);// 设置图文状态为审核后的状态
  260 + content.setReceive_status(CommonConst.RECEIVE_AUDIT);// 领取状态为已审核
  261 + content.setShenhe_msg(msg);// 设置审核消息
  262 + if (CommonUtils.isNotEmpty(userId)) {
  263 + content.setAuditor_id(userId);
  264 + content.setShenhe_type(CommonConst.AUDIT_TYPE_USER);// 设置审核类型为人工
  265 + }else{
  266 + content.setUpdater(updater);//设置更新人
  267 + }
  268 + content.setLast_update(CommonUtils.getCurrentTime());
  269 + int i = shyContentMapper.updateByPrimaryKeySelective(content);
  270 + if (i != 1) {
  271 + success = false;
  272 + }
  273 + }
  274 +
  275 + return success;
  276 + }
284 277  
285 278 //**********************************
286 279 public Integer receive(String ids, Integer num, String userId, Integer spid) {
... ... @@ -290,9 +283,9 @@ public class ContentServiceImpl {
290 283 for (String cid : cids) {
291 284 ShyContent shyContent = shyContentMapper.selectByPrimaryKey(Integer.parseInt(cid));
292 285 if (CommonUtils.isNotNull(shyContent) && shyContent.getReceive_status() == CommonConst.RECEIVE_BEFORE ) {
293   - shyContent.setAuditor_id(userId);
294   - shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
295   - shyContent.setLast_update(CommonUtils.getCurrentTime());
  286 + shyContent.setAuditor_id(userId);
  287 + shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
  288 + shyContent.setLast_update(CommonUtils.getCurrentTime());
296 289 shyContentMapper.updateByPrimaryKeySelective(shyContent);
297 290 n++;
298 291 }
... ... @@ -306,9 +299,9 @@ public class ContentServiceImpl {
306 299 List<ShyContent> shyContentList = shyContentMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num));
307 300 if (!shyContentList.isEmpty()) {
308 301 for (ShyContent shyContent : shyContentList) {
309   - shyContent.setAuditor_id(userId);
310   - shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
311   - shyContent.setLast_update(CommonUtils.getCurrentTime());
  302 + shyContent.setAuditor_id(userId);
  303 + shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
  304 + shyContent.setLast_update(CommonUtils.getCurrentTime());
312 305 shyContentMapper.updateByPrimaryKeySelective(shyContent);
313 306 n++;
314 307 }
... ... @@ -341,76 +334,53 @@ public class ContentServiceImpl {
341 334 public int updateByPrimaryKeySelective(ShyContent content) {
342 335 return shyContentMapper.updateByPrimaryKeySelective(content);
343 336 }
344   -
  337 +
345 338 /**
346 339 * 获得审核类型
347 340 * @param spId
348 341 */
349 342 public Integer getShenheType(Integer spId,String ContentTag){
350   -
351   - //获取图文免审sp
  343 +
  344 + //获取图文免审sp
352 345 List<Integer> sites = sitesService.getBusinessList(CommonConst.BUSINESS_CONTENT);
353 346 //初始化一个审核状态
354 347 Integer shenheType=3;//审核类型,1:免审,2:机审,3:人工审
355 348 //如果当前sp是免审sp
356 349 if(sites.contains(spId)){
357   - shenheType=1;//免审
  350 + shenheType=1;//免审
358 351 }else{
359   - if("content".equals(ContentTag)){
360   - shenheType=2;//机审
361   - }else{
362   - shenheType=3;//人工审
363   - }
  352 + if("content".equals(ContentTag)){
  353 + shenheType=2;//机审
  354 + }else{
  355 + shenheType=3;//人工审
  356 + }
364 357 }
365 358  
366 359 return shenheType;
367   - }
  360 + }
368 361  
369 362 /**
370   - * 数美视频(图片)过滤
371   - * @param cid 审核云中图文id
372   - * @param channel 尺度
  363 + * 易盾网站过滤
  364 + *
  365 + * @param shyContent
373 366 * @return
374 367 */
375   - public int contentFilter(ShyContent shyContent,String channel){
376   -
377   - JSONObject result = null;//数美返回结果
378   - String type="";//数美返回结果的类型
379   - String desc="";//数美失败结果的详情
380   - String Token_id=UUID.randomUUID().toString();
381   - String contentUrl=localhost_url+"/api/content/detail/"+shyContent.getId()+".html";
382   - logger.info("数美送审图文url:"+contentUrl);
383   - try{
384   - //调用数美接口
385   - result = AntiFraudUtil.filterArticle(Token_id,contentUrl,channel);
386   - type=result.getString("riskLevel");
387   - desc=result.getString("desc");//数美失败结果的详情
388   - }catch(Exception e){
389   - type=CommonConst.REJECT;//报错就给一个拒绝状态
390   - desc="数美审核报错了";
391   - }
392   - if(type.toLowerCase().equals(CommonConst.PASS)){//数美通过
393   - desc="数美审核通过了";
394   - shyContent.setShenhe_msg(desc);
395   - //修改图文状态
396   - callback(shyContent.getId().toString(),desc,CommonConst.AUDIT_SUCCESS,"","机审通过");
397   - }else if(type.toLowerCase().equals(CommonConst.REJECT)||type.toLowerCase().equals(CommonConst.REVIEW)){//数美拒绝
398   - shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_USER);//审核类型改为人工审核
399   - shyContent.setShenhe_msg(desc);//拒绝原因
400   - updateshyContent(shyContent);
401   -// videosService.updateDianboAndShenhe(shyVideos,4);
  368 + public void contentFilter(ShyContent shyContent) {
  369 + String contentUrl = localhost_url + "/api/content/detail/" + shyContent.getId() + ".html";
  370 + logger.info("向易盾网站检测接口提交的url:" + contentUrl);
  371 + //调用易盾网站检测接口
  372 + JSONObject jsonObject = YiDunAntiFraudUtil.submitYiDunUrl(contentUrl);
  373 + if (jsonObject != null) {
  374 + JSONObject result = jsonObject.getJSONObject("result");
  375 + String dataId = result.getString("dataId");
  376 + ShyYidun shyYidun = new ShyYidun();
  377 + shyYidun.setId(dataId);
  378 + shyYidun.setUrl(contentUrl);
  379 +
  380 + shyYidun.setContent_id(shyContent.getId().toString());
  381 + shyYidun.setCreate_time(new Date());
  382 + yiDunServiceImpl.addYiDunMsg(shyYidun);
402 383 }
403   - ShyVideofilter videofilter=new ShyVideofilter();
404   - videofilter.setChannel(channel);
405   - videofilter.setDesc_msg(desc);
406   - videofilter.setResult_type(type);
407   - videofilter.setToken_id(Token_id);
408   - videofilter.setVideos_id(shyContent.getId());
409   - videofilter.setDuration(-1);
410   - videofilter.setCreated_at(CommonUtils.getCurrentTime());
411   - videofilterServiceImpl.impotVideofilter(videofilter);
412   -
413   - return 0;
414 384 }
415 385  
416 386 }
... ...