Commit c26e561723fe73fda9b3cf14c76c530b5c670163

Authored by 郑超
1 parent f519f545

cms同步图文内容到审核云

src/main/java/com/cnlive/shenhe/api/ContentControllerApi.java
... ... @@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
13 13 import org.springframework.beans.factory.annotation.Autowired;
14 14 import org.springframework.stereotype.Controller;
15 15 import org.springframework.ui.Model;
  16 +import org.springframework.util.StringUtils;
16 17 import org.springframework.web.bind.annotation.*;
17 18  
18 19 import java.util.Date;
... ... @@ -43,7 +44,8 @@ public class ContentControllerApi {
43 44 JSONObject json = JSONObject.parseObject(param);
44 45 //判断是否存在
45 46 ShyContent shyContent = new ShyContent();
46   - shyContent.setContent_id(json.getString("contentId"));
  47 + String contentId = json.getString("contentId");
  48 + shyContent.setContent_id(contentId);
47 49 //图文标签
48 50 shyContent.setContent_tag("content");
49 51  
... ... @@ -84,13 +86,15 @@ public class ContentControllerApi {
84 86 //spid
85 87 shyContent1.setSp_id(json.getInteger("spId"));
86 88 //图文标签
87   - shyContent1.setContent_tag("content");
  89 + String contentTag = json.getString("content_tag");
  90 + shyContent1.setContent_tag(StringUtils.isEmpty(contentTag) ? "content" : contentTag);
88 91 //领取状态
89 92 shyContent1.setReceive_status(CommonConst.RECEIVE_BEFORE);
90 93 //最后一次更新时间
91 94 shyContent1.setLast_update(CommonUtils.getCurrentTime());
92 95 boolean YorN = contentService.updateshyContent(shyContent1);
93 96 if (YorN == true) {
  97 + logger.info("图文同步接口更新成功:{}", contentId);
94 98 return new ResponseBean(ErrorEnum.SUCCESS);
95 99 } else {
96 100 return new ResponseBean(ErrorEnum.ERROR);
... ... @@ -130,6 +134,9 @@ public class ContentControllerApi {
130 134 shyContent.setContent_time(timestamp);
131 135  
132 136 }
  137 + String contentTag = json.getString("content_tag");
  138 + shyContent.setContent_tag(StringUtils.isEmpty(contentTag) ? "content" : contentTag);
  139 +
133 140 shyContent.setCreate_date(CommonUtils.getCurrentTime());
134 141 //回调地址
135 142 shyContent.setCallback(json.getString("callback"));
... ... @@ -145,6 +152,7 @@ public class ContentControllerApi {
145 152 shyContent.setLast_update(CommonUtils.getCurrentTime());
146 153 boolean YorN = contentService.impotContent(shyContent);
147 154 if (YorN == true) {
  155 + logger.info("图文同步接口保存操作成功:{}", json.getString("contentId"));
148 156 return new ResponseBean(ErrorEnum.SUCCESS);
149 157 } else {
150 158 return new ResponseBean(ErrorEnum.ERROR);
... ...
src/main/java/com/cnlive/shenhe/job/ContentJob.java
... ... @@ -13,6 +13,11 @@ import org.springframework.stereotype.Component;
13 13  
14 14 import java.util.List;
15 15  
  16 +/**
  17 + * 图文发布审核
  18 + *
  19 + * @author
  20 + */
16 21 @Component
17 22 public class ContentJob {
18 23 private static Logger logger = LoggerFactory.getLogger(ContentJob.class);
... ... @@ -61,7 +66,6 @@ public class ContentJob {
61 66 if (shyYidun1 == null) {
62 67 logger.info("定时发送易盾检测的content_id:" + content.getId());
63 68 contentService.contentFilter(content);
64   -
65 69 }
66 70 }
67 71 }
... ...
src/main/java/com/cnlive/shenhe/serviceImpl/ContentServiceImpl.java
1 1 package com.cnlive.shenhe.serviceImpl;
2 2  
3   -import com.alibaba.fastjson.JSONArray;
4 3 import com.alibaba.fastjson.JSONObject;
5 4 import com.cnlive.shenhe.entity.*;
6 5 import com.cnlive.shenhe.mapper.ShyCommentsMapper;
7 6 import com.cnlive.shenhe.mapper.ShyContentMapper;
8 7 import com.cnlive.shenhe.mapper.ShySitesMapper;
9 8 import com.cnlive.shenhe.mapper.ShyUsersMapper;
10   -import com.cnlive.shenhe.utils.*;
  9 +import com.cnlive.shenhe.utils.AuditPass;
  10 +import com.cnlive.shenhe.utils.CommonConst;
  11 +import com.cnlive.shenhe.utils.CommonUtils;
  12 +import com.cnlive.shenhe.utils.YiDunAntiFraudUtil;
11 13 import com.github.pagehelper.PageHelper;
12 14 import com.github.pagehelper.PageInfo;
13 15 import org.apache.ibatis.session.RowBounds;
... ... @@ -18,14 +20,8 @@ import org.springframework.beans.factory.annotation.Value;
18 20 import org.springframework.stereotype.Service;
19 21 import tk.mybatis.mapper.entity.Example;
20 22  
21   -import java.sql.Timestamp;
22   -import java.text.ParseException;
23   -import java.util.ArrayList;
24 23 import java.util.Date;
25   -import java.util.HashMap;
26 24 import java.util.List;
27   -import java.util.Map;
28   -import java.util.UUID;
29 25  
30 26 /**
31 27 * @Auther: liwei
... ... @@ -54,21 +50,21 @@ public class ContentServiceImpl {
54 50 VideofilterServiceImpl videofilterServiceImpl;
55 51 @Autowired
56 52 YiDunServiceImpl yiDunServiceImpl;
57   -
  53 +
58 54 @Value("${spring.localhost.url}")
59 55 String localhost_url;
60 56  
61 57 public ShyContent getShyContent(ShyContent shyContent) {
62 58 List<ShyContent> shyContentList = shyContentMapper.select(shyContent);
63   - if(CommonUtils.isNotNull(shyContentList)&&shyContentList.size()>0){
64   - return shyContentList.get(0);
  59 + if (CommonUtils.isNotNull(shyContentList) && shyContentList.size() > 0) {
  60 + return shyContentList.get(0);
65 61 }
66 62 return new ShyContent();
67 63 }
68 64  
69 65 //**************************************
70 66 public List<ShyContent> findshyContent(ShyContent shyContent) {
71   -
  67 +
72 68 return shyContentMapper.selectByRowBounds(shyContent, new RowBounds(0, 100));
73 69 }
74 70  
... ... @@ -97,7 +93,7 @@ public class ContentServiceImpl {
97 93 return shyCommentsMapper.updateByPrimaryKeySelective(shyComments);
98 94 }
99 95  
100   - public PageInfo<ShyContent> getPage( String title,String source,String author,String content_tag,String contentId, Date start_date, Date end_date, Integer receive_status, String updater, Integer page, Integer pageSize, String orderByClause, Integer spid, String userId) {
  96 + public PageInfo<ShyContent> getPage(String title, String source, String author, String content_tag, String contentId, Date start_date, Date end_date, Integer receive_status, String updater, Integer page, Integer pageSize, String orderByClause, Integer spid, String userId) {
101 97 Example example = new Example(ShyContent.class);
102 98 Example.Criteria criteria = example.createCriteria();
103 99 if (CommonUtils.isNotEmpty(orderByClause)) {
... ... @@ -105,36 +101,36 @@ public class ContentServiceImpl {
105 101 } else {
106 102 example.setOrderByClause("create_date desc");
107 103 }
108   - if (CommonUtils.isNotNull(start_date) ) {
  104 + if (CommonUtils.isNotNull(start_date)) {
109 105 criteria.andGreaterThanOrEqualTo("create_date", start_date);
110 106 }
111   - if ( CommonUtils.isNotNull(end_date)) {
112   - criteria.andLessThanOrEqualTo("create_date", end_date);
  107 + if (CommonUtils.isNotNull(end_date)) {
  108 + criteria.andLessThanOrEqualTo("create_date", end_date);
113 109 }
114 110 if (CommonUtils.isNotEmpty(title)) {
115 111 criteria.andLike("title", "%" + title + "%");
116 112 }
117 113 if (CommonUtils.isNotEmpty(source)) {
118   - criteria.andLike("source","%" + source + "%");
  114 + criteria.andLike("source", "%" + source + "%");
119 115 }
120 116 if (CommonUtils.isNotEmpty(author)) {
121   - criteria.andEqualTo("author",author);
  117 + criteria.andEqualTo("author", author);
122 118 }
123 119 if (CommonUtils.isNotEmpty(updater)) {
124 120 criteria.andEqualTo("updater", updater);
125 121 }
126 122 if (CommonUtils.isNotEmpty(content_tag)) {
127   - criteria.andEqualTo("content_tag", content_tag);
  123 + criteria.andEqualTo("content_tag", content_tag);
128 124 }
129 125 if (CommonUtils.isNotNull(spid)) {
130 126 criteria.andEqualTo("sp_id", spid);
131 127 }
132 128 if (CommonUtils.isNotEmpty(contentId)) {
133   - criteria.andEqualTo("content_id", contentId);
  129 + criteria.andEqualTo("content_id", contentId);
134 130 }
135 131 if (CommonUtils.isNotNull(receive_status)) {
136 132 criteria.andEqualTo("receive_status", receive_status);
137   - if (receive_status!=CommonConst.RECEIVE_BEFORE) {
  133 + if (receive_status != CommonConst.RECEIVE_BEFORE) {
138 134 criteria.andEqualTo("auditor_id", userId);
139 135 }
140 136 }
... ... @@ -144,136 +140,141 @@ public class ContentServiceImpl {
144 140 PageInfo<ShyContent> pageInfo = new PageInfo<>(contentList);
145 141 return pageInfo;
146 142 }
147   -
  143 +
148 144 /**
149 145 * 根据条件导出数据excel
  146 + *
150 147 * @return
151 148 */
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   - }
  149 + public List<ShyContent> findByCondition(String title, String content_tag, String contentId, Date start_date,
  150 + Date end_date, Integer receive_status, Integer page,
  151 + Integer pageSize, String orderByClause, Integer spid) {
  152 +
  153 + Example example = new Example(ShyContent.class);
  154 + Example.Criteria criteria = example.createCriteria();
  155 + if (CommonUtils.isNotEmpty(orderByClause)) {
  156 + example.setOrderByClause(orderByClause);
  157 + } else {
  158 + example.setOrderByClause("create_date desc");
  159 + }
  160 + if (CommonUtils.isNotNull(start_date)) {
  161 + criteria.andGreaterThanOrEqualTo("create_date", start_date);
  162 + }
  163 + if (CommonUtils.isNotNull(end_date)) {
  164 + criteria.andLessThanOrEqualTo("create_date", end_date);
  165 + }
  166 + if (CommonUtils.isNotEmpty(title)) {
  167 + criteria.andLike("title", "%" + title + "%");
  168 + }
  169 + if (CommonUtils.isNotNull(spid)) {
  170 + criteria.andEqualTo("sp_id", spid);
  171 + }
  172 + if (CommonUtils.isNotEmpty(contentId)) {
  173 + criteria.andEqualTo("content_id", contentId);
  174 + }
  175 + if (CommonUtils.isNotEmpty(content_tag)) {
  176 + criteria.andEqualTo("content_tag", content_tag);
  177 + }
  178 + if (CommonUtils.isNotNull(receive_status)) {
  179 + criteria.andEqualTo("receive_status", receive_status);
  180 + }
184 181 List<ShyContent> shyContentList = shyContentMapper.selectByExample(example);
185 182 return shyContentList;
186 183 }
187   -
  184 +
188 185  
189 186 //******************************
190 187 public ShyContent getDetailsContent(Integer id) {
191   - ShyContent content = shyContentMapper.selectByPrimaryKey(id);
  188 + ShyContent content = shyContentMapper.selectByPrimaryKey(id);
192 189 if (content.getReceive_status() == CommonConst.RECEIVE_AUDIT) {
193   - String updater = CommonUtils.isEmpty(content.getUpdater()) || "null".equals(content.getUpdater())? "白名单":content.getUpdater();
  190 + String updater = CommonUtils.isEmpty(content.getUpdater()) || "null".equals(content.getUpdater()) ? "白名单" : content.getUpdater();
194 191 String auditor_id = content.getAuditor_id();
195 192 if (CommonUtils.isNotEmpty(auditor_id)) {
196 193 ShyUsers user = new ShyUsers();
197 194 user.setUser_id(auditor_id);
198 195 user = shyUsersMapper.selectOne(user);
199   - String email = CommonUtils.isEmpty(user.getEmail())|| "null".equals(user.getEmail()) ? "" : user.getEmail();
  196 + String email = CommonUtils.isEmpty(user.getEmail()) || "null".equals(user.getEmail()) ? "" : user.getEmail();
200 197 String userName = CommonUtils.isEmpty(user.getUsername()) ? email : user.getUsername();
201   - updater = userName ;
  198 + updater = userName;
202 199 }
203 200 content.setUpdater(updater);
204 201 }
205   - ShySites shySite=sitesService.findspidDescByspid(content.getSp_id());
206   - if(CommonUtils.isNotNull(shySite)){
207   - content.setSp_desc(shySite.getName());
208   - }
  202 + ShySites shySite = sitesService.findspidDescByspid(content.getSp_id());
  203 + if (CommonUtils.isNotNull(shySite)) {
  204 + content.setSp_desc(shySite.getName());
  205 + }
209 206 return content;
210 207 }
211 208  
212 209 //**********************
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   - }
  210 + public boolean callback(String contentId, String msg, Integer state, String userId, String updater) {
  211 + boolean success = true;
  212 + ShyContent content = shyContentMapper.selectByPrimaryKey(Integer.parseInt(contentId));
  213 + JSONObject result = new JSONObject();
  214 + try {
  215 + if (CommonUtils.isNotEmpty(content.getContent_tag()) && content.getContent_tag().equals("content")) {
  216 + result = Pass.contentPass(content.getContent_id(), state + "", msg, content.getCallback());
  217 + } else if (CommonUtils.isNotEmpty(content.getContent_tag()) && content.getContent_tag().equals("moment")) {
  218 + result = Pass.momentPass(content.getContent_id(), state, msg, content.getCallback(), content.getAuthor());
  219 + } else if (CommonUtils.isNotEmpty(content.getContent_tag()) && content.getContent_tag().equals("cms_photoalbum")) {
  220 + result = Pass.cmsCommonContentPass(content.getContent_id(), state, msg, content.getCallback(), content.getAuthor());
  221 + } else if (CommonUtils.isNotEmpty(content.getContent_tag()) && content.getContent_tag().equals("edu_works")) {
  222 + result = Pass.cmsCommonContentPass(content.getContent_id(), state, msg, content.getCallback(), content.getAuthor());
  223 + }
  224 + } catch (Exception e) {
  225 + logger.error("图文审核回调失败,图文id:{}", content.getId());
  226 + success = false;
  227 + return success;
  228 + }
  229 + if (result == null) {
  230 + logger.error("图文回调错误,且无返回信息。图文id:{}", content.getId());
  231 + success = false;
  232 + return success;
  233 + } else {
  234 + Integer code = result.getInteger("errorCode");
  235 + if (code != 0) {
  236 + logger.error("图文回调错误,图文id:{},errorCode:{},errorMessage:{}", content.getId(), code,
  237 + result.getString("errorMessage"));
  238 + success = false;
  239 + return success;
  240 + }
  241 +
  242 + //如果当前图文是朋友圈的视频,通知点播云
  243 + if (CommonUtils.isNotEmpty(content.getContent_tag())
  244 + && content.getContent_tag().equals("moment")
  245 + && CommonUtils.isNotEmpty(content.getVideo_id())
  246 + && state == CommonConst.AUDIT_REFUSE) {
  247 + ShyVideos shyVideos1 = new ShyVideos();
  248 + shyVideos1.setVideo_id(content.getVideo_id());
  249 + List<ShyVideos> listshyVideos = videosService.findshyVideo(shyVideos1);
  250 + if (listshyVideos.size() > 0) {
  251 + ShyVideos shyVideos = listshyVideos.get(0);
  252 + String showMsg = videosService.repulse(shyVideos.getId().toString(), msg, userId);
  253 + if (CommonUtils.isNotEmpty(showMsg)) {
  254 + success = false;
  255 + return success;
  256 + }
  257 + }
  258 + }
  259 +
  260 + content.setContent_status(state);// 设置图文状态为审核后的状态
  261 + content.setReceive_status(CommonConst.RECEIVE_AUDIT);// 领取状态为已审核
  262 + content.setShenhe_msg(msg);// 设置审核消息
  263 + if (CommonUtils.isNotEmpty(userId)) {
  264 + content.setAuditor_id(userId);
  265 + content.setShenhe_type(CommonConst.AUDIT_TYPE_USER);// 设置审核类型为人工
  266 + } else {
  267 + content.setUpdater(updater);//设置更新人
  268 + }
  269 + content.setLast_update(CommonUtils.getCurrentTime());
  270 + int i = shyContentMapper.updateByPrimaryKeySelective(content);
  271 + if (i != 1) {
  272 + success = false;
  273 + }
  274 + }
  275 +
  276 + return success;
  277 + }
277 278  
278 279 //**********************************
279 280 public Integer receive(String ids, Integer num, String userId, Integer spid) {
... ... @@ -282,10 +283,10 @@ public class ContentServiceImpl {
282 283 String[] cids = ids.split(",");
283 284 for (String cid : cids) {
284 285 ShyContent shyContent = shyContentMapper.selectByPrimaryKey(Integer.parseInt(cid));
285   - if (CommonUtils.isNotNull(shyContent) && shyContent.getReceive_status() == CommonConst.RECEIVE_BEFORE ) {
286   - shyContent.setAuditor_id(userId);
287   - shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
288   - shyContent.setLast_update(CommonUtils.getCurrentTime());
  286 + if (CommonUtils.isNotNull(shyContent) && shyContent.getReceive_status() == CommonConst.RECEIVE_BEFORE) {
  287 + shyContent.setAuditor_id(userId);
  288 + shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
  289 + shyContent.setLast_update(CommonUtils.getCurrentTime());
289 290 shyContentMapper.updateByPrimaryKeySelective(shyContent);
290 291 n++;
291 292 }
... ... @@ -299,9 +300,9 @@ public class ContentServiceImpl {
299 300 List<ShyContent> shyContentList = shyContentMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num));
300 301 if (!shyContentList.isEmpty()) {
301 302 for (ShyContent shyContent : shyContentList) {
302   - shyContent.setAuditor_id(userId);
303   - shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
304   - shyContent.setLast_update(CommonUtils.getCurrentTime());
  303 + shyContent.setAuditor_id(userId);
  304 + shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
  305 + shyContent.setLast_update(CommonUtils.getCurrentTime());
305 306 shyContentMapper.updateByPrimaryKeySelective(shyContent);
306 307 n++;
307 308 }
... ... @@ -326,38 +327,41 @@ public class ContentServiceImpl {
326 327 }
327 328 return n;
328 329 }
  330 +
329 331 //**************************************
330 332 public ShyContent selectByPrimaryKey(Integer id) {
331 333 ShyContent shyContent = shyContentMapper.selectByPrimaryKey(id);
332 334 return shyContent;
333 335 }
  336 +
334 337 public int updateByPrimaryKeySelective(ShyContent content) {
335 338 return shyContentMapper.updateByPrimaryKeySelective(content);
336 339 }
337   -
  340 +
338 341 /**
339 342 * 获得审核类型
  343 + *
340 344 * @param spId
341 345 */
342   - public Integer getShenheType(Integer spId,String ContentTag){
343   -
344   - //获取图文免审sp
  346 + public Integer getShenheType(Integer spId, String ContentTag) {
  347 +
  348 + //获取图文免审sp
345 349 List<Integer> sites = sitesService.getBusinessList(CommonConst.BUSINESS_CONTENT);
346 350 //初始化一个审核状态
347   - Integer shenheType=3;//审核类型,1:免审,2:机审,3:人工审
  351 + Integer shenheType = 3;//审核类型,1:免审,2:机审,3:人工审
348 352 //如果当前sp是免审sp
349   - if(sites.contains(spId)){
350   - shenheType=1;//免审
351   - }else{
352   - if("content".equals(ContentTag)){
353   - shenheType=2;//机审
354   - }else{
355   - shenheType=3;//人工审
356   - }
  353 + if (sites.contains(spId)) {
  354 + shenheType = 1;//免审
  355 + } else {
  356 + if ("content".equals(ContentTag)) {
  357 + shenheType = 2;//机审
  358 + } else {
  359 + shenheType = 3;//人工审
  360 + }
357 361 }
358 362  
359 363 return shenheType;
360   - }
  364 + }
361 365  
362 366 /**
363 367 * 易盾网站过滤
... ...
src/main/java/com/cnlive/shenhe/utils/AuditPass.java
... ... @@ -25,24 +25,24 @@ public class AuditPass {
25 25 private String platformValue;//点播platformValue
26 26 @Value("${live_url}")
27 27 private String live_url;//直播同步信息
28   -
  28 +
29 29 @Value("${queryUserByMobile}")
30 30 private String queryUserByMobile;//用户云查网家家用户信息(通过手机号)
31   -
  31 +
32 32 @Value("${queryUserByUserId}")
33 33 private String queryUserByUserId;//用户云查网家家用户信息(通过用户id)
34   -
  34 +
35 35 public static void main(String[] args) {
36   - JSONObject map= new JSONObject();
37   - map.put("platform","a" );
38   - map.put("commentUserAvatar","http://yweb0.cnliveimg.com/images/headImg/2019/1129/1575022593286.jpg" );
39   - map.put("appId","60#iqw7flx829" );
40   - map.put("commentUserIP", null);
41   - map.put("type", "topic");
42   - map.put("activityId", "802:video:comets:604_ab79303bd0074a24965a92dd6514681a#20939");
43   - HttpUtil httpUtil = HttpUtil.init();
44   - httpUtil.setParam("param", map.toJSONString());
45   - Map<String, String> post = httpUtil.post("http://test.shen.cnlive.com/api/comments/import");
  36 + JSONObject map = new JSONObject();
  37 + map.put("platform", "a");
  38 + map.put("commentUserAvatar", "http://yweb0.cnliveimg.com/images/headImg/2019/1129/1575022593286.jpg");
  39 + map.put("appId", "60#iqw7flx829");
  40 + map.put("commentUserIP", null);
  41 + map.put("type", "topic");
  42 + map.put("activityId", "802:video:comets:604_ab79303bd0074a24965a92dd6514681a#20939");
  43 + HttpUtil httpUtil = HttpUtil.init();
  44 + httpUtil.setParam("param", map.toJSONString());
  45 + Map<String, String> post = httpUtil.post("http://test.shen.cnlive.com/api/comments/import");
46 46 }
47 47  
48 48 /**
... ... @@ -77,6 +77,7 @@ public class AuditPass {
77 77 Map<String, String> post = httpUtil.post(URL);
78 78 return JSONObject.parseObject(post.get("result"));
79 79 }
  80 +
80 81 /**
81 82 * 直播视频回调
82 83 *
... ... @@ -87,20 +88,20 @@ public class AuditPass {
87 88 * @return
88 89 */
89 90 public JSONObject livePass(String activity_id, int state, String attr_tags, String msg, String callBack) {
90   - logger.info("直播回调:id:{},state:{},attr_tags:{},exceptionMessage:{}", activity_id, state, attr_tags, msg);
91   - JSONObject params = new JSONObject();
92   - params.put("id", activity_id);
93   - params.put("state", state);
94   - params.put("attr_tags", attr_tags);
95   - params.put("exceptionMessage", msg);
96   - HttpUtil httpUtil = HttpUtil.init();
97   - httpUtil.setParam("param", params.toJSONString());
98   - Map<String, String> post = httpUtil.post(callBack);
99   - String result = post.get("result");
100   - logger.info("直播回调result:{}",result);
101   - return JSONObject.parseObject(post.get("result"));
  91 + logger.info("直播回调:id:{},state:{},attr_tags:{},exceptionMessage:{}", activity_id, state, attr_tags, msg);
  92 + JSONObject params = new JSONObject();
  93 + params.put("id", activity_id);
  94 + params.put("state", state);
  95 + params.put("attr_tags", attr_tags);
  96 + params.put("exceptionMessage", msg);
  97 + HttpUtil httpUtil = HttpUtil.init();
  98 + httpUtil.setParam("param", params.toJSONString());
  99 + Map<String, String> post = httpUtil.post(callBack);
  100 + String result = post.get("result");
  101 + logger.info("直播回调result:{}", result);
  102 + return JSONObject.parseObject(post.get("result"));
102 103 }
103   -
  104 +
104 105 /**
105 106 * 直播视频回调
106 107 *
... ... @@ -111,139 +112,166 @@ public class AuditPass {
111 112 * @return
112 113 */
113 114 public JSONObject liveApplyPass(String activity_id, int state, String attr_tags, String msg, String callBack) {
114   - logger.info("直播申请回调:id:{},state:{},attr_tags:{},exceptionMessage:{}", activity_id, state, attr_tags, msg);
115   - JSONObject params = new JSONObject();
116   - params.put("id", activity_id);
117   - params.put("state", state);
118   - params.put("attr_tags", attr_tags);
119   - params.put("exceptionMessage", msg);
120   - HttpUtil httpUtil = HttpUtil.init();
121   - httpUtil.setParam("param", params.toJSONString());
122   - Map<String, String> post = httpUtil.post(callBack);
123   - return JSONObject.parseObject(post.get("result"));
  115 + logger.info("直播申请回调:id:{},state:{},attr_tags:{},exceptionMessage:{}", activity_id, state, attr_tags, msg);
  116 + JSONObject params = new JSONObject();
  117 + params.put("id", activity_id);
  118 + params.put("state", state);
  119 + params.put("attr_tags", attr_tags);
  120 + params.put("exceptionMessage", msg);
  121 + HttpUtil httpUtil = HttpUtil.init();
  122 + httpUtil.setParam("param", params.toJSONString());
  123 + Map<String, String> post = httpUtil.post(callBack);
  124 + return JSONObject.parseObject(post.get("result"));
124 125 }
125   -
  126 +
126 127 /**
127   - * 直播云信息同步
128   - * @param json
129   - * @param callBack
130   - * @return
131   - */
132   - public JSONObject syncLive(String activity_id) {
133   - logger.info("直播云信息同步:activity_id:{}", activity_id);
134   - HttpUtil httpUtil = HttpUtil.init();
135   - httpUtil.setParam("activityId", activity_id);
136   - Map<String, String> post = httpUtil.post(live_url);
137   - return JSONObject.parseObject(post.get("result"));
138   - }
  128 + * 直播云信息同步
  129 + *
  130 + * @param json
  131 + * @param callBack
  132 + * @return
  133 + */
  134 + public JSONObject syncLive(String activity_id) {
  135 + logger.info("直播云信息同步:activity_id:{}", activity_id);
  136 + HttpUtil httpUtil = HttpUtil.init();
  137 + httpUtil.setParam("activityId", activity_id);
  138 + Map<String, String> post = httpUtil.post(live_url);
  139 + return JSONObject.parseObject(post.get("result"));
  140 + }
139 141  
140 142 /**
141 143 * 评论审核回调
  144 + *
142 145 * @param json
143 146 * @param callBack
144 147 * @return
145 148 */
146 149 public JSONObject commentPass(JSONObject json, String callBack) {
147   - logger.info("评论审核回调:param:{}", json);
  150 + logger.info("评论审核回调:param:{}", json);
148 151 Map<String, String> map = new HashMap<>();
149 152 map.put("param", json.toJSONString());
150 153 String result = HttpUtil.form(callBack, map);
151 154 return JSONObject.parseObject(result);
152 155 }
  156 +
153 157 /**
154 158 * 评论禁言
  159 + *
155 160 * @param json
156 161 * @param callBack
157 162 * @return
158 163 */
159 164 public JSONObject commentSpeak(JSONObject json, String callBack) {
160   - logger.info("评论禁言:param:{}", json);
161   - Map<String, String> map = new HashMap<>();
162   - map.put("param", json.toJSONString());
163   - String result = HttpUtil.form(callBack, map);
164   - return JSONObject.parseObject(result);
  165 + logger.info("评论禁言:param:{}", json);
  166 + Map<String, String> map = new HashMap<>();
  167 + map.put("param", json.toJSONString());
  168 + String result = HttpUtil.form(callBack, map);
  169 + return JSONObject.parseObject(result);
165 170 }
166   -
  171 +
167 172 /**
168 173 * 频道审核回调
  174 + *
169 175 * @param json
170 176 * @param callBack
171 177 * @return
172 178 */
173 179 public JSONObject channelPass(JSONObject json, String callBack) {
174   - logger.info("频道审核回调:param:{}", json);
175   - Map<String, String> map = new HashMap<>();
176   - map.put("param", json.toJSONString());
177   - String result = HttpUtil.form(callBack, map);
178   - return JSONObject.parseObject(result);
  180 + logger.info("频道审核回调:param:{}", json);
  181 + Map<String, String> map = new HashMap<>();
  182 + map.put("param", json.toJSONString());
  183 + String result = HttpUtil.form(callBack, map);
  184 + return JSONObject.parseObject(result);
179 185 }
180   -
181   -
  186 +
  187 +
182 188 /**
183 189 * 图文审核回调
184   - * @param ids
185   - * @param type 1(fabu),2(xiaxian),3(shanchu)
186   - * @param shenheStatus 1
  190 + *
187 191 * @param msg
188 192 * @param callBack
189 193 * @return
190 194 */
191   - public JSONObject contentPass(String contentId, String type,String msg, String callBack) {
  195 + public JSONObject contentPass(String contentId, String type, String msg, String callBack) {
192 196 logger.info("图文回调:ids:{},type:{},msg:{}", contentId, type, msg);
193 197 HttpUtil httpUtil = HttpUtil.init();
194   - String URL = callBack + "?contentId=" + contentId + "&type=" + type+ "&shenMsg=" + msg;
  198 + String URL = callBack + "?contentId=" + contentId + "&type=" + type + "&shenMsg=" + msg;
195 199 Map<String, String> post = httpUtil.post(URL);
196 200 return JSONObject.parseObject(post.get("result"));
197 201 }
198   - public JSONObject momentPass(String content_id, Integer state, String msg, String callback, String userId) {
199   - logger.info("朋友圈回调:content_id:{},state:{},msg:{},userId:{}", content_id, state, msg,userId);
200   - JSONObject json=new JSONObject();
201   - json.put("userId",userId );
202   - json.put("momentId",content_id );
203   - json.put("status",state );
204   - json.put("msg", msg);
205   - String httpUtilResult = HttpClientUtils.HttpPostWithJson(callback, json.toString());
206   - logger.info("朋友圈返回数据,httpUtilResult=====" + httpUtilResult);
  202 +
  203 + public JSONObject momentPass(String content_id, Integer state, String msg, String callback, String userId) {
  204 + logger.info("朋友圈回调:content_id:{},state:{},msg:{},userId:{}", content_id, state, msg, userId);
  205 + JSONObject json = new JSONObject();
  206 + json.put("userId", userId);
  207 + json.put("momentId", content_id);
  208 + json.put("status", state);
  209 + json.put("msg", msg);
  210 + String httpUtilResult = HttpClientUtils.HttpPostWithJson(callback, json.toString());
  211 + logger.info("朋友圈返回数据,httpUtilResult=====" + httpUtilResult);
207 212 JSONObject result = JSONObject.parseObject(httpUtilResult);
208   - return result;
209   - }
210   - public JSONObject queryUser(String userId, String userMobile) {
211   - logger.info("用户云查询用户:userId:{},userMobile:{}", userId, userMobile);
212   - HttpUtil httpUtil = HttpUtil.init();
213   - String URL = "";
214   - if(CommonUtils.isNotEmpty(userId)){
215   - URL = queryUserByUserId + userId;
216   - }else{
217   - URL = queryUserByMobile + userMobile;
218   - }
219   - logger.info("用户云查询用户使用url:"+URL);
220   - Map<String, String> post = httpUtil.post(URL);
221   - return JSONObject.parseObject(post.get("result"));
222   - }
223   -
224   - //音频回调
225   - public JSONObject audioPass(String audioId, int state, String attr_tags, String msg, String callBack) {
226   - logger.info("点播音频回调:audioId:{},state:{},attr_tags:{},msg:{}", audioId, state, attr_tags, msg);
227   - JSONObject params = new JSONObject();
228   - params.put("video_id", audioId);
229   - //3-成功 4-失败
230   - params.put("state", state + "");
231   - params.put("attr_tags", attr_tags);
232   - params.put("msg", msg);
233   - HttpUtil httpUtil = HttpUtil.init();
234   - httpUtil.setParam("param", params.toJSONString());
235   - String token = "";
236   - try {
237   - String cb = callBack.replace("//", "");
238   - cb = cb.substring(cb.indexOf("/"));
239   - token = CommonUtils.md5(cb + platformKey + platformValue);
240   - } catch (NoSuchAlgorithmException e) {
241   - e.printStackTrace();
242   - } catch (UnsupportedEncodingException e) {
243   - e.printStackTrace();
244   - }
245   - String URL = callBack + "?platform=" + platformKey + "&token=" + token;
246   - Map<String, String> post = httpUtil.post(URL);
247   - return JSONObject.parseObject(post.get("result"));
248   - }
  213 + return result;
  214 + }
  215 +
  216 + /**
  217 + * cms审核回调
  218 + *
  219 + * @param content_id
  220 + * @param state
  221 + * @param msg
  222 + * @param callback
  223 + * @param userId
  224 + * @return
  225 + */
  226 + public JSONObject cmsCommonContentPass(String content_id, Integer state, String msg, String callback, String userId) {
  227 + logger.info("cms审核回调:content_id:{},state:{},msg:{},userId:{}", content_id, state, msg, userId);
  228 + JSONObject json = new JSONObject();
  229 + json.put("userId", userId);
  230 + json.put("contentId", content_id);
  231 + json.put("status", state);
  232 + json.put("msg", msg);
  233 + String httpUtilResult = HttpClientUtils.HttpPostWithJson(callback, json.toString());
  234 + logger.info("cms审核返回数据,httpUtilResult=====" + httpUtilResult);
  235 + return JSONObject.parseObject(httpUtilResult);
  236 + }
  237 +
  238 + public JSONObject queryUser(String userId, String userMobile) {
  239 + logger.info("用户云查询用户:userId:{},userMobile:{}", userId, userMobile);
  240 + HttpUtil httpUtil = HttpUtil.init();
  241 + String URL = "";
  242 + if (CommonUtils.isNotEmpty(userId)) {
  243 + URL = queryUserByUserId + userId;
  244 + } else {
  245 + URL = queryUserByMobile + userMobile;
  246 + }
  247 + logger.info("用户云查询用户使用url:" + URL);
  248 + Map<String, String> post = httpUtil.post(URL);
  249 + return JSONObject.parseObject(post.get("result"));
  250 + }
  251 +
  252 + //音频回调
  253 + public JSONObject audioPass(String audioId, int state, String attr_tags, String msg, String callBack) {
  254 + logger.info("点播音频回调:audioId:{},state:{},attr_tags:{},msg:{}", audioId, state, attr_tags, msg);
  255 + JSONObject params = new JSONObject();
  256 + params.put("video_id", audioId);
  257 + //3-成功 4-失败
  258 + params.put("state", state + "");
  259 + params.put("attr_tags", attr_tags);
  260 + params.put("msg", msg);
  261 + HttpUtil httpUtil = HttpUtil.init();
  262 + httpUtil.setParam("param", params.toJSONString());
  263 + String token = "";
  264 + try {
  265 + String cb = callBack.replace("//", "");
  266 + cb = cb.substring(cb.indexOf("/"));
  267 + token = CommonUtils.md5(cb + platformKey + platformValue);
  268 + } catch (NoSuchAlgorithmException e) {
  269 + e.printStackTrace();
  270 + } catch (UnsupportedEncodingException e) {
  271 + e.printStackTrace();
  272 + }
  273 + String URL = callBack + "?platform=" + platformKey + "&token=" + token;
  274 + Map<String, String> post = httpUtil.post(URL);
  275 + return JSONObject.parseObject(post.get("result"));
  276 + }
249 277 }
... ...