Commit 5968d32ae18ab5cb92a546d6a1d997d29190d10b

Authored by liwei2917
1 parent 559d1004

话题接口

... ... @@ -56,6 +56,12 @@
56 56 <groupId>org.springframework.boot</groupId>
57 57 <artifactId>spring-boot-starter-websocket</artifactId>
58 58 </dependency>
  59 +
  60 + <!-- mq队列 -->
  61 + <dependency>
  62 + <groupId>org.springframework.boot</groupId>
  63 + <artifactId>spring-boot-starter-amqp</artifactId>
  64 + </dependency>
59 65  
60 66 <!-- 自动更新 -->
61 67 <dependency>
... ...
src/main/java/com/cnlive/shenhe/api/TopicControllerApi.java
... ... @@ -9,10 +9,13 @@ import com.cnlive.shenhe.serviceImpl.TopicServiceImpl;
9 9 import com.cnlive.shenhe.utils.AuditPass;
10 10 import com.cnlive.shenhe.utils.CommonConst;
11 11 import com.cnlive.shenhe.utils.CommonUtils;
  12 +import com.cnlive.shenhe.utils.TransitServiceUtils;
  13 +
12 14 import org.slf4j.Logger;
13 15 import org.slf4j.LoggerFactory;
14 16 import org.springframework.beans.factory.annotation.Autowired;
15 17 import org.springframework.stereotype.Controller;
  18 +import org.springframework.web.bind.annotation.GetMapping;
16 19 import org.springframework.web.bind.annotation.PostMapping;
17 20 import org.springframework.web.bind.annotation.RequestBody;
18 21 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -30,6 +33,9 @@ public class TopicControllerApi {
30 33 CommentsServiceImpl commentsService;
31 34 @Autowired
32 35 TopicServiceImpl topicService;
  36 +
  37 + @Autowired
  38 + TransitServiceUtils t;
33 39  
34 40 /**
35 41 * @author liwei
... ... @@ -41,6 +47,7 @@ public class TopicControllerApi {
41 47 public ResponseBean impotTopic(@RequestBody String param) {
42 48 logger.info("话题入库,param=====" + param);
43 49 JSONObject json = JSONObject.parseObject(param);
  50 + JSONObject result = new JSONObject();
44 51  
45 52 //获取所有参数
46 53 String topic_id = json.getString("topic_id");//话题id
... ... @@ -77,9 +84,9 @@ public class TopicControllerApi {
77 84  
78 85 boolean YorN = topicService.updateshyTopic(shyTopic1);
79 86 if (YorN == true) {
80   - return new ResponseBean(ErrorEnum.ERROR);
  87 + return new ResponseBean(ErrorEnum.SUCCESS,new JSONObject().put("topic_id", topic_id));
81 88 } else {
82   - return new ResponseBean(ErrorEnum.SUCCESS);
  89 + return new ResponseBean(ErrorEnum.ERROR,new JSONObject().put("topic_id", topic_id));
83 90 }
84 91 }
85 92 //如果不存在直接插入
... ... @@ -96,11 +103,56 @@ public class TopicControllerApi {
96 103 shyTopic.setCreate_date(CommonUtils.getCurrentTime());//送审时间
97 104 boolean YorN = topicService.impotshyTopic(shyTopic);
98 105 if (YorN == true) {
99   - return new ResponseBean(ErrorEnum.ERROR);
  106 + return new ResponseBean(ErrorEnum.SUCCESS,new JSONObject().put("topic_id", topic_id));
100 107 } else {
101   - return new ResponseBean(ErrorEnum.SUCCESS);
  108 + return new ResponseBean(ErrorEnum.ERROR,new JSONObject().put("topic_id", topic_id));
102 109 }
103 110 }
104 111  
105   -
  112 + @GetMapping("/send")
  113 + @ResponseBody
  114 + public String send() {
  115 + System.out.println("1111");
  116 + JSONObject params = new JSONObject();
  117 + params.put("video_id", "11111");
  118 + params.put("state", "22222");
  119 + params.put("attr_tags", "33333");
  120 + params.put("msg", "4444");
  121 + t.send("cms","/api/callback", false, params);
  122 + return "1111";
  123 + }
  124 +
  125 + @PostMapping("/callback")
  126 + @ResponseBody
  127 + public void callback(@RequestBody String param) {
  128 + logger.info("话题回调通知,param=====" + param);
  129 + JSONObject json = JSONObject.parseObject(param);
  130 + //获取中转服务器消息
  131 + String errorCode = json.getString("errorCode");
  132 + String errorMessage=json.getString("errorMessage");
  133 + String date=json.getString("date");
  134 + //获取接收方消息
  135 + JSONObject dateObject = JSONObject.parseObject(date);
  136 + String topic_id=dateObject.getString("topic_id");
  137 + //获取当前话题实体
  138 + ShyTopic shyTopic=new ShyTopic();
  139 + shyTopic.setTopic_id(topic_id);
  140 + ShyTopic topic = topicService.getShyTopic(shyTopic);
  141 +
  142 + if(errorCode.equals("0")){
  143 + logger.info("cms系统已通知");
  144 + if(topic!=null){
  145 + topic.setShenhe_msg(topic.getShenhe_msg()+",cms系统已通知");
  146 + }
  147 + }else{//中转服务器失败
  148 + logger.info("中转服务器调用cms失败,失败消息:"+errorMessage);
  149 + topic.setShenhe_msg(topic.getShenhe_msg()+",中转服务器调用cms失败,失败消息:"+errorMessage);
  150 + topic.setShenhe_status(CommonConst.AUDIT_INTT);
  151 + topic.setShenhe_type(CommonConst.AUDIT_TYPE_USER);
  152 + }
  153 + topicService.updateshyTopic(shyTopic);
  154 + }
  155 +
  156 +
106 157 }
  158 +
... ...
src/main/java/com/cnlive/shenhe/bean/ResponseBean.java
... ... @@ -39,6 +39,10 @@ public class ResponseBean implements Serializable {
39 39 public ResponseBean(ErrorEnum errorEnum) {
40 40 this.errorEnum = errorEnum;
41 41 }
  42 + public ResponseBean(ErrorEnum errorEnum, Object data) {
  43 + this.errorEnum = errorEnum;
  44 + this.data = data;
  45 + }
42 46  
43 47 public Integer getErrorCode() {
44 48 if (CommonUtils.isNotNull(this.errorEnum)) {
... ...
src/main/java/com/cnlive/shenhe/controller/TopicController.java
... ... @@ -142,22 +142,21 @@ public class TopicController {
142 142 * @param ids
143 143 * @return
144 144 */
145   -// @PostMapping("/pass")
146   -// @ResponseBody
147   -// public ResponseBean pass(String ids, HttpSession session) {
148   -// SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
149   -// String userId = sessionUser.getUserId();
150   -// boolean success =false;
151   -// String[] contentIds = ids.split(",");
152   -// for (String contentId : contentIds) {
153   -// success = contentService.callback(contentId,"审核通过", CommonConst.AUDIT_SUCCESS, userId,"");
154   -// }
155   -// if (success) {
156   -// return new ResponseBean();
157   -// } else {
158   -// return new ResponseBean(ErrorEnum.ERROR);
159   -// }
160   -// }
  145 + @PostMapping("/pass")
  146 + @ResponseBody
  147 + public ResponseBean pass(String ids, HttpSession session) {
  148 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  149 + String userId = sessionUser.getUserId();
  150 + boolean success =false;
  151 + String[] topicIds = ids.split(",");
  152 + for (String id : topicIds) {
  153 + success = topicService.callback(id,"审核通过", CommonConst.AUDIT_SUCCESS, userId,"");
  154 + if(!success){
  155 + return new ResponseBean(ErrorEnum.ERROR);
  156 + }
  157 + }
  158 + return new ResponseBean(ErrorEnum.SUCCESS);
  159 + }
161 160  
162 161 /**
163 162 * 审核拒绝
... ... @@ -165,23 +164,22 @@ public class TopicController {
165 164 * @param ids
166 165 * @return
167 166 */
168   -// @PostMapping("/refuse")
169   -// @ResponseBody
170   -// public ResponseBean refuse(String ids,String msg, HttpSession session) {
171   -// SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
172   -// String userId = sessionUser.getUserId();
173   -// boolean success =false;
174   -// String[] contentIds = ids.split(",");
175   -// for (String contentId : contentIds) {
176   -// success = contentService.callback(contentId,msg, CommonConst.AUDIT_REFUSE, userId,"");
177   -// }
178   -// if (success) {
179   -// return new ResponseBean();
180   -// } else {
181   -// return new ResponseBean(ErrorEnum.ERROR);
182   -// }
183   -//
184   -// }
  167 + @PostMapping("/refuse")
  168 + @ResponseBody
  169 + public ResponseBean refuse(String ids,String msg, HttpSession session) {
  170 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  171 + String userId = sessionUser.getUserId();
  172 + boolean success =false;
  173 + String[] contentIds = ids.split(",");
  174 + for (String id : contentIds) {
  175 + success = topicService.callback(id,msg, CommonConst.AUDIT_REFUSE, userId,"");
  176 + if(!success){
  177 + return new ResponseBean(ErrorEnum.ERROR);
  178 + }
  179 + }
  180 + return new ResponseBean(ErrorEnum.SUCCESS);
  181 +
  182 + }
185 183  
186 184  
187 185 /**
... ...
src/main/java/com/cnlive/shenhe/serviceImpl/TopicServiceImpl.java
... ... @@ -19,6 +19,7 @@ import com.cnlive.shenhe.utils.AntiFraudUtil;
19 19 import com.cnlive.shenhe.utils.AuditPass;
20 20 import com.cnlive.shenhe.utils.CommonConst;
21 21 import com.cnlive.shenhe.utils.CommonUtils;
  22 +import com.cnlive.shenhe.utils.TransitServiceUtils;
22 23 import com.github.pagehelper.PageHelper;
23 24 import com.github.pagehelper.PageInfo;
24 25 import org.apache.ibatis.session.RowBounds;
... ... @@ -56,7 +57,7 @@ public class TopicServiceImpl {
56 57 @Autowired
57 58 ShyUsersMapper shyUsersMapper;
58 59 @Autowired
59   - AuditPass Pass;
  60 + TransitServiceUtils transitServiceUtils;
60 61 @Autowired
61 62 SitesServiceImpl sitesService;
62 63 @Autowired
... ... @@ -67,7 +68,7 @@ public class TopicServiceImpl {
67 68 @Value("${spring.localhost.url}")
68 69 String localhost_url;
69 70  
70   - public ShyTopic getShyContent(ShyTopic shyTopic) {
  71 + public ShyTopic getShyTopic(ShyTopic shyTopic) {
71 72 List<ShyTopic> shyTopicList = shyTopicMapper.select(shyTopic);
72 73 if(CommonUtils.isNotNull(shyTopicList)&&shyTopicList.size()>0){
73 74 return shyTopicList.get(0);
... ... @@ -189,154 +190,49 @@ public class TopicServiceImpl {
189 190 }
190 191  
191 192  
192   - //******************************
193   - public ShyTopic getDetailsContent(Integer id) {
194   - ShyTopic content = shyTopicMapper.selectByPrimaryKey(id);
195   - if (content.getShenhe_status() != CommonConst.RECEIVE_AUDIT) {
196   - String updater = CommonUtils.isEmpty(content.getUpdater()) || "null".equals(content.getUpdater())? "白名单":content.getUpdater();
197   - String auditor_id = content.getAuditor_id();
198   - if (CommonUtils.isNotEmpty(auditor_id)) {
199   - ShyUsers user = new ShyUsers();
200   - user.setUser_id(auditor_id);
201   - user = shyUsersMapper.selectOne(user);
202   - String email = CommonUtils.isEmpty(user.getEmail())|| "null".equals(user.getEmail()) ? "" : user.getEmail();
203   - String userName = CommonUtils.isEmpty(user.getUsername()) ? email : user.getUsername();
204   - updater = userName ;
205   - }
206   - content.setUpdater(updater);
207   - }
208   - ShySites shySite=sitesService.findspidDescByspid(content.getSp_id());
209   - if(CommonUtils.isNotNull(shySite)){
210   - content.setSp_desc(shySite.getName());
211   - }
212   - return content;
213   - }
  193 +
214 194  
215 195 //**********************
216   -// public boolean callback(String contentId, String msg, Integer state, String userId,String updater) {
217   -// boolean success = true;
218   -// ShyTopic content = shyTopicMapper.selectByPrimaryKey(Integer.parseInt(contentId));
219   -// JSONObject result = new JSONObject();
220   -// try {
221   -// if(CommonUtils.isNotEmpty(content.getContent_tag())&&content.getContent_tag().equals("content")){
222   -// result = Pass.contentPass(content.getContent_id(), state+"", msg, content.getCallback());
223   -// }else if(CommonUtils.isNotEmpty(content.getContent_tag())&&content.getContent_tag().equals("moment")){
224   -// result = Pass.momentPass(content.getContent_id(), state, msg, content.getCallback(),content.getAuthor());
225   -// }
226   -// } catch (Exception e) {
227   -// logger.error("图文审核回调失败,图文id:{}", content.getId());
228   -// success = false;
229   -// return success;
230   -// }
231   -// if (result == null) {
232   -// logger.error("图文回调错误,且无返回信息。图文id:{}", content.getId());
233   -// success = false;
234   -// return success;
235   -// } else {
236   -// Integer code = result.getInteger("errorCode");
237   -// if (code != 0) {
238   -// logger.error("图文回调错误,图文id:{},errorCode:{},errorMessage:{}", content.getId(), code,
239   -// result.getString("errorMessage"));
240   -// success = false;
241   -// return success;
242   -// }
243   -//
244   -// //如果当前图文是朋友圈的视频,通知点播云
245   -// if(CommonUtils.isNotEmpty(content.getContent_tag())
246   -// &&content.getContent_tag().equals("moment")
247   -// &&CommonUtils.isNotEmpty(content.getVideo_id())
248   -// &&state==CommonConst.AUDIT_REFUSE){
249   -// ShyVideos shyVideos1 = new ShyVideos();
250   -// shyVideos1.setVideo_id(content.getVideo_id());
251   -// List<ShyVideos> listshyVideos = videosService.findshyVideo(shyVideos1);
252   -// if (listshyVideos.size() > 0) {
253   -// ShyVideos shyVideos = listshyVideos.get(0);
254   -// String showMsg = videosService.repulse(shyVideos.getId().toString(), msg, userId);
255   -// if (CommonUtils.isNotEmpty(showMsg)) {
256   -// success = false;
257   -// return success;
258   -// }
259   -// }
260   -// }
261   -//
262   -// content.setContent_status(state);// 设置图文状态为审核后的状态
263   -// content.setReceive_status(CommonConst.RECEIVE_AUDIT);// 领取状态为已审核
264   -// content.setShenhe_msg(msg);// 设置审核消息
265   -// if (CommonUtils.isNotEmpty(userId)) {
266   -// content.setAuditor_id(userId);
267   -// content.setShenhe_type(CommonConst.AUDIT_TYPE_USER);// 设置审核类型为人工
268   -// }else{
269   -// content.setUpdater(updater);//设置更新人
270   -// }
271   -// content.setLast_update(CommonUtils.getCurrentTime());
272   -// int i = shyContentMapper.updateByPrimaryKeySelective(content);
273   -// if (i != 1) {
274   -// success = false;
275   -// }
276   -// }
277   -//
278   -// return success;
279   -// }
  196 + public boolean callback(String id, String msg, Integer state, String userId,String updater) {
  197 + boolean success = true;
  198 + ShyTopic topic = shyTopicMapper.selectByPrimaryKey(Integer.parseInt(id));
  199 + JSONObject params = new JSONObject();
  200 + params.put("topic_id", topic.getTopic_id());
  201 + params.put("status", state+1);
  202 + params.put("msg", msg);
  203 + success = transitServiceUtils.send("cms","updateTopicStatus", true, params);
  204 + if(!success){
  205 + logger.error("话题审核回调失败,话题表id:{}", topic.getId());
  206 + return success;
  207 + }
  208 +
  209 + topic.setShenhe_status(state);// 设置话题状态为审核后的状态
  210 + topic.setShenhe_msg(msg);// 设置审核消息
  211 + if (CommonUtils.isNotEmpty(userId)) {
  212 + topic.setAuditor_id(userId);
  213 + topic.setShenhe_type(CommonConst.AUDIT_TYPE_USER);// 设置审核类型为人工
  214 + }else{
  215 + topic.setUpdater(updater);//设置更新人
  216 + }
  217 + topic.setUpdate_date(CommonUtils.getCurrentTime());
  218 + int i = shyTopicMapper.updateByPrimaryKeySelective(topic);
  219 + if (i != 1) {
  220 + success = false;
  221 + }
280 222  
281   - //**********************************
282   -// public Integer receive(String ids, Integer num, String userId, Integer spid) {
283   -// Integer n = 0;
284   -// if (CommonUtils.isNotEmpty(ids)) {
285   -// String[] cids = ids.split(",");
286   -// for (String cid : cids) {
287   -// ShyContent shyContent = shyContentMapper.selectByPrimaryKey(Integer.parseInt(cid));
288   -// if (CommonUtils.isNotNull(shyContent) && shyContent.getReceive_status() == CommonConst.RECEIVE_BEFORE ) {
289   -// shyContent.setAuditor_id(userId);
290   -// shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
291   -// shyContent.setLast_update(CommonUtils.getCurrentTime());
292   -// shyContentMapper.updateByPrimaryKeySelective(shyContent);
293   -// n++;
294   -// }
295   -// }
296   -// } else if (CommonUtils.isNotNull(num) && num > 0) {
297   -// Example example = new Example(ShyContent.class);
298   -// example.setOrderByClause("create_date desc");
299   -// example.and().andEqualTo("receive_status", CommonConst.RECEIVE_BEFORE);
300   -//// example.and().andEqualTo("receive", CommonConst.RECEIVE_AFTER);
301   -// if (CommonUtils.isNotNull(spid) && spid != 0) example.and().andEqualTo("spid", spid);
302   -// List<ShyContent> shyContentList = shyContentMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num));
303   -// if (!shyContentList.isEmpty()) {
304   -// for (ShyContent shyContent : shyContentList) {
305   -// shyContent.setAuditor_id(userId);
306   -// shyContent.setReceive_status(CommonConst.RECEIVE_AFTER);
307   -// shyContent.setLast_update(CommonUtils.getCurrentTime());
308   -// shyContentMapper.updateByPrimaryKeySelective(shyContent);
309   -// n++;
310   -// }
311   -// }
312   -// }
313   -// return n;
314   -// }
  223 + return success;
  224 + }
315 225  
316   - //***************************************
317   -// public Integer retReceive(String ids, String userId) {
318   -// Integer n = 0;
319   -// String[] cids = ids.split(",");
320   -// for (String cid : cids) {
321   -// ShyContent shyContent = shyContentMapper.selectByPrimaryKey(Integer.parseInt(cid));
322   -// if (shyContent.getReceive_status() == CommonConst.RECEIVE_AFTER && userId.equals(shyContent.getAuditor_id())) {
323   -// shyContent.setReceive_status(CommonConst.RECEIVE_BEFORE);
324   -// shyContent.setAuditor_id(null);
325   -// shyContent.setLast_update(CommonUtils.getCurrentTime());
326   -// int i = shyContentMapper.updateByPrimaryKeySelective(shyContent);
327   -// if (i == 1) n++;
328   -// }
329   -// }
330   -// return n;
331   -// }
  226 +
332 227 //**************************************
333   -// public ShyContent selectByPrimaryKey(Integer id) {
334   -// ShyContent shyContent = shyContentMapper.selectByPrimaryKey(id);
335   -// return shyContent;
336   -// }
337   -// public int updateByPrimaryKeySelective(ShyContent content) {
338   -// return shyContentMapper.updateByPrimaryKeySelective(content);
339   -// }
  228 + public ShyTopic selectByPrimaryKey(Integer id) {
  229 + ShyTopic shyTopic = shyTopicMapper.selectByPrimaryKey(id);
  230 + return shyTopic;
  231 + }
  232 +
  233 + public int updateByPrimaryKeySelective(ShyTopic topic) {
  234 + return shyTopicMapper.updateByPrimaryKeySelective(topic);
  235 + }
340 236  
341 237 /**
342 238 * 获得审核类型
... ... @@ -357,52 +253,7 @@ public class TopicServiceImpl {
357 253 return shenheType;
358 254 }
359 255  
360   - /**
361   - * 数美视频(图片)过滤
362   - * @param cid 审核云中图文id
363   - * @param channel 尺度
364   - * @return
365   - */
366   -// public int contentFilter(ShyContent shyContent,String channel){
367   -//
368   -// JSONObject result = null;//数美返回结果
369   -// String type="";//数美返回结果的类型
370   -// String desc="";//数美失败结果的详情
371   -// String Token_id=UUID.randomUUID().toString();
372   -// String contentUrl=localhost_url+"/api/content/detail/"+shyContent.getId()+".html";
373   -// logger.info("数美送审图文url:"+contentUrl);
374   -// try{
375   -// //调用数美接口
376   -// result = AntiFraudUtil.filterArticle(Token_id,contentUrl,channel);
377   -// type=result.getString("riskLevel");
378   -// desc=result.getString("desc");//数美失败结果的详情
379   -// }catch(Exception e){
380   -// type=CommonConst.REJECT;//报错就给一个拒绝状态
381   -// desc="数美审核报错了";
382   -// }
383   -// if(type.toLowerCase().equals(CommonConst.PASS)){//数美通过
384   -// desc="数美审核通过了";
385   -// shyContent.setShenhe_msg(desc);
386   -// //修改图文状态
387   -// callback(shyContent.getId().toString(),desc,CommonConst.AUDIT_SUCCESS,"","机审通过");
388   -// }else if(type.toLowerCase().equals(CommonConst.REJECT)||type.toLowerCase().equals(CommonConst.REVIEW)){//数美拒绝
389   -// shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_USER);//审核类型改为人工审核
390   -// shyContent.setShenhe_msg(desc);//拒绝原因
391   -// updateshyContent(shyContent);
392   -//// videosService.updateDianboAndShenhe(shyVideos,4);
393   -// }
394   -// ShyVideofilter videofilter=new ShyVideofilter();
395   -// videofilter.setChannel(channel);
396   -// videofilter.setDesc_msg(desc);
397   -// videofilter.setResult_type(type);
398   -// videofilter.setToken_id(Token_id);
399   -// videofilter.setVideos_id(shyContent.getId());
400   -// videofilter.setDuration(-1);
401   -// videofilter.setCreated_at(CommonUtils.getCurrentTime());
402   -// videofilterServiceImpl.impotVideofilter(videofilter);
403   -//
404   -// return 0;
405   -// }
  256 +
406 257  
407 258 }
408 259  
... ...
src/main/java/com/cnlive/shenhe/utils/TransitServiceUtils.java 0 → 100644
  1 +package com.cnlive.shenhe.utils;
  2 +
  3 +import com.alibaba.fastjson.JSONObject;
  4 +
  5 +import org.springframework.amqp.core.AmqpTemplate;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +@Component
  10 +public class TransitServiceUtils {
  11 +
  12 + @Autowired
  13 + private AmqpTemplate rabbitTemplate;
  14 + private String exchange = "transitService";//交换机
  15 + private String routingKey = "audit";//路由
  16 +
  17 + /**
  18 + * MQ 生产者工具类
  19 + *
  20 + * @param calleeId 接收方 mall 电商 user 用户 daren 达人 cms cms 审核 audit
  21 + * @param cmdId 调用URL_ID
  22 + * @param isCallback 0需要回调 1不需要回调
  23 + * @param data 接口参数
  24 + */
  25 + public boolean send(String calleeId, String cmdId, Boolean isCallback, JSONObject data) {
  26 + boolean result=true;
  27 + try{
  28 + JSONObject json = new JSONObject();
  29 + json.put("callerId", "audit");
  30 + json.put("calleeId", calleeId);//
  31 + json.put("cmdId", cmdId);
  32 + if (isCallback) {
  33 + json.put("isCallback", "0");
  34 + } else {
  35 + json.put("isCallback", "1");
  36 + }
  37 + json.put("data", data);
  38 + this.rabbitTemplate.convertAndSend(exchange, routingKey, json.toString());
  39 + }
  40 + catch(Exception e){
  41 + result=false;
  42 + }
  43 + return result;
  44 + }
  45 +
  46 + public static void main(String[] args) {
  47 + JSONObject params = new JSONObject();
  48 + params.put("video_id", "11111");
  49 + params.put("state", "22222");
  50 + params.put("attr_tags", "33333");
  51 + params.put("msg", "4444");
  52 +// send("cms","/api/callback",true,params);
  53 + System.exit(0);
  54 + }
  55 +}
... ...
src/main/resources/application.properties
... ... @@ -36,6 +36,19 @@ mybatis.mapper-locations=classpath:mapping/*.xml
36 36 mybatis.type-aliases-package=com.cnlive.shenhe.entity
37 37 server.port=82
38 38  
  39 +#rabbitmq\u76f8\u5173\u914d\u7f6e
  40 +spring.rabbitmq.host=120.92.4.80
  41 +spring.rabbitmq.port=5672
  42 +spring.rabbitmq.username=test
  43 +spring.rabbitmq.password=password
  44 +# \u5f00\u542f\u53d1\u9001\u786e\u8ba4
  45 +spring.rabbitmq.publisher-confirms=true
  46 +# \u5f00\u542f\u53d1\u9001\u5931\u8d25\u9000\u56de
  47 +spring.rabbitmq.publisher-returns=true
  48 +# \u5f00\u542fACK
  49 +spring.rabbitmq.listener.direct.acknowledge-mode=manual
  50 +spring.rabbitmq.listener.simple.acknowledge-mode=manual
  51 +
39 52 #logback\u65e5\u5fd7\u4e2d\u4f7f\u7528
40 53 spring.application.name=cnlive_shenhe_test
41 54 spring.application.home=/usr/local/test_cnlive_shenhe/cnlive_shenhe/log
... ...