Commit f2bb9199586fc9f6e7265f125f15fbc272fca7fb
update
Showing
4 changed files
with
65 additions
and
42 deletions
src/main/java/com/cnlive/shenhe/controller/CommentsController.java
| ... | ... | @@ -74,15 +74,17 @@ public class CommentsController { |
| 74 | 74 | List<ShyComments> list = commentPage.getList(); |
| 75 | 75 | if (!list.isEmpty()) { |
| 76 | 76 | for (ShyComments comment : list) { |
| 77 | - String auditor = "白名单"; | |
| 78 | - String auditor_id = comment.getAuditor_id(); | |
| 79 | - if (CommonUtils.isNotEmpty(auditor_id)) { | |
| 80 | - ShyUsers user = new ShyUsers(); | |
| 81 | - user.setUser_id(auditor_id); | |
| 82 | - user = usersService.select(user); | |
| 83 | - if (CommonUtils.isNotNull(user)) auditor = user.getUsername() + user.getEmail(); | |
| 77 | + if(comment.getState()!=CommonConst.AUDIT_INTT){ | |
| 78 | + String auditor = "白名单"; | |
| 79 | + String auditor_id = comment.getAuditor_id(); | |
| 80 | + if (CommonUtils.isNotEmpty(auditor_id)) { | |
| 81 | + ShyUsers user = new ShyUsers(); | |
| 82 | + user.setUser_id(auditor_id); | |
| 83 | + user = usersService.select(user); | |
| 84 | + if (CommonUtils.isNotNull(user)) auditor = user.getUsername() + user.getEmail(); | |
| 85 | + } | |
| 86 | + comment.setAuditor(auditor); | |
| 84 | 87 | } |
| 85 | - comment.setAuditor(auditor); | |
| 86 | 88 | } |
| 87 | 89 | } |
| 88 | 90 | model.addAttribute("commentPage", commentPage); | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/CommentsServiceImpl.java
| ... | ... | @@ -8,6 +8,7 @@ import com.cnlive.shenhe.mapper.ShyCommentsMapper; |
| 8 | 8 | import com.cnlive.shenhe.mapper.ShySitesMapper; |
| 9 | 9 | import com.cnlive.shenhe.mapper.ShyUsersMapper; |
| 10 | 10 | import com.cnlive.shenhe.utils.AuditPass; |
| 11 | +import com.cnlive.shenhe.utils.CommonConst; | |
| 11 | 12 | import com.cnlive.shenhe.utils.CommonUtils; |
| 12 | 13 | import com.github.pagehelper.PageHelper; |
| 13 | 14 | import com.github.pagehelper.PageInfo; |
| ... | ... | @@ -99,15 +100,17 @@ public class CommentsServiceImpl { |
| 99 | 100 | |
| 100 | 101 | public ShyComments getDetailsComment(Integer id) { |
| 101 | 102 | ShyComments comment = shyCommentsMapper.selectByPrimaryKey(id); |
| 102 | - String auditorName = "白名单"; | |
| 103 | - String auditor_id = comment.getAuditor_id(); | |
| 104 | - if (CommonUtils.isNotEmpty(auditor_id)) { | |
| 105 | - ShyUsers user = new ShyUsers(); | |
| 106 | - user.setUser_id(auditor_id); | |
| 107 | - user = shyUsersMapper.selectOne(user); | |
| 108 | - auditorName = user.getUsername() + user.getEmail(); | |
| 103 | + if (comment.getState() != CommonConst.AUDIT_INTT) { | |
| 104 | + String auditorName = "白名单"; | |
| 105 | + String auditor_id = comment.getAuditor_id(); | |
| 106 | + if (CommonUtils.isNotEmpty(auditor_id)) { | |
| 107 | + ShyUsers user = new ShyUsers(); | |
| 108 | + user.setUser_id(auditor_id); | |
| 109 | + user = shyUsersMapper.selectOne(user); | |
| 110 | + auditorName = user.getUsername() + user.getEmail(); | |
| 111 | + } | |
| 112 | + comment.setAuditor(auditorName); | |
| 109 | 113 | } |
| 110 | - comment.setAuditor(auditorName); | |
| 111 | 114 | return comment; |
| 112 | 115 | } |
| 113 | 116 | |
| ... | ... | @@ -123,24 +126,31 @@ public class CommentsServiceImpl { |
| 123 | 126 | json.put("msg", ""); |
| 124 | 127 | JSONObject result = new JSONObject(); |
| 125 | 128 | try { |
| 126 | - result = Pass.commentPass(json,comment.getCallback()); | |
| 129 | + result = Pass.commentPass(json, comment.getCallback()); | |
| 127 | 130 | } catch (Exception e) { |
| 128 | 131 | logger.error("评论回调失败,activity_id:{}", comment.getActivity_id()); |
| 129 | 132 | success = false; |
| 130 | 133 | break; |
| 131 | 134 | } |
| 132 | - Integer code = result.getInteger("errorCode"); | |
| 133 | - if (code != 0) { | |
| 134 | - logger.error("评论回调错误,activity_id:{},errorCode:{},errorMessage:{}", comment.getActivity_id(), code, result.getString("errorMessage")); | |
| 135 | + if (result == null) { | |
| 136 | + logger.error("评论回调错误,且无返回信息。activity_id:{}", comment.getActivity_id()); | |
| 135 | 137 | success = false; |
| 136 | 138 | break; |
| 139 | + } else { | |
| 140 | + Integer code = result.getInteger("errorCode"); | |
| 141 | + if (code != 0) { | |
| 142 | + logger.error("评论回调错误,activity_id:{},errorCode:{},errorMessage:{}", comment.getActivity_id(), code, result.getString("errorMessage")); | |
| 143 | + success = false; | |
| 144 | + break; | |
| 145 | + } | |
| 146 | + comment.setState(state); | |
| 147 | + comment.setAuditor_id(userId); | |
| 148 | + int i = shyCommentsMapper.updateByPrimaryKeySelective(comment); | |
| 149 | + if (i != 1) { | |
| 150 | + success = false; | |
| 151 | + } | |
| 137 | 152 | } |
| 138 | - comment.setState(state); | |
| 139 | - comment.setAuditor_id(userId); | |
| 140 | - int i = shyCommentsMapper.updateByPrimaryKeySelective(comment); | |
| 141 | - if (i != 1) { | |
| 142 | - success = false; | |
| 143 | - } | |
| 153 | + | |
| 144 | 154 | } |
| 145 | 155 | return success; |
| 146 | 156 | } | ... | ... |
src/main/java/com/cnlive/shenhe/utils/AuditPass.java
| ... | ... | @@ -6,6 +6,8 @@ import org.slf4j.LoggerFactory; |
| 6 | 6 | import org.springframework.beans.factory.annotation.Value; |
| 7 | 7 | import org.springframework.stereotype.Component; |
| 8 | 8 | |
| 9 | +import java.io.UnsupportedEncodingException; | |
| 10 | +import java.security.NoSuchAlgorithmException; | |
| 9 | 11 | import java.util.HashMap; |
| 10 | 12 | import java.util.Map; |
| 11 | 13 | |
| ... | ... | @@ -18,36 +20,46 @@ import java.util.Map; |
| 18 | 20 | public class AuditPass { |
| 19 | 21 | private static Logger logger = LoggerFactory.getLogger(AuditPass.class); |
| 20 | 22 | @Value("${platformKey}") |
| 21 | - private String platformKey;//点播platformKey | |
| 23 | + private String platformKey;//点播platformKey | |
| 22 | 24 | @Value("${platformValue}") |
| 23 | - private String platformValue;//点播platformValue | |
| 24 | - @Value("${token}") | |
| 25 | - private String token; | |
| 25 | + private String platformValue;//点播platformValue | |
| 26 | + | |
| 26 | 27 | /** |
| 27 | 28 | * 点播视频回调 |
| 29 | + * | |
| 28 | 30 | * @param video_id |
| 29 | 31 | * @param state |
| 30 | 32 | * @param attr_tags |
| 31 | 33 | * @param msg |
| 32 | 34 | * @return |
| 33 | 35 | */ |
| 34 | - public JSONObject auditPass(String video_id,int state,String attr_tags,String msg,String callBack){ | |
| 35 | - logger.info("点播回调:video_id:{},state:{},attr_tags:{},msg:{}",video_id,state,attr_tags,msg); | |
| 36 | + public JSONObject auditPass(String video_id, int state, String attr_tags, String msg, String callBack) { | |
| 37 | + logger.info("点播回调:video_id:{},state:{},attr_tags:{},msg:{}", video_id, state, attr_tags, msg); | |
| 36 | 38 | JSONObject params = new JSONObject(); |
| 37 | - params.put("video_id",video_id); | |
| 38 | - params.put("state",state+""); | |
| 39 | - params.put("attr_tags",attr_tags); | |
| 40 | - params.put("msg",msg); | |
| 39 | + params.put("video_id", video_id); | |
| 40 | + params.put("state", state + ""); | |
| 41 | + params.put("attr_tags", attr_tags); | |
| 42 | + params.put("msg", msg); | |
| 41 | 43 | HttpUtil httpUtil = HttpUtil.init(); |
| 42 | - httpUtil.setParam("param",params.toJSONString()); | |
| 43 | - String URL =callBack+"?platform="+platformKey+"&token="+token; | |
| 44 | + httpUtil.setParam("param", params.toJSONString()); | |
| 45 | + String token = ""; | |
| 46 | + try { | |
| 47 | + String cb = callBack.replace("//", ""); | |
| 48 | + cb = cb.substring(cb.indexOf("/")); | |
| 49 | + token = CommonUtils.md5(cb + platformKey + platformValue); | |
| 50 | + } catch (NoSuchAlgorithmException e) { | |
| 51 | + e.printStackTrace(); | |
| 52 | + } catch (UnsupportedEncodingException e) { | |
| 53 | + e.printStackTrace(); | |
| 54 | + } | |
| 55 | + String URL = callBack + "?platform=" + platformKey + "&token=" + token; | |
| 44 | 56 | Map<String, String> post = httpUtil.post(URL); |
| 45 | - return JSONObject.parseObject(post.get("result")); | |
| 57 | + return JSONObject.parseObject(post.get("result")); | |
| 46 | 58 | } |
| 47 | 59 | |
| 48 | - public JSONObject commentPass(JSONObject json,String callBack){ | |
| 60 | + public JSONObject commentPass(JSONObject json, String callBack) { | |
| 49 | 61 | Map<String, String> map = new HashMap<>(); |
| 50 | - map.put("param",json.toJSONString()); | |
| 62 | + map.put("param", json.toJSONString()); | |
| 51 | 63 | String result = HttpUtil.form(callBack, map); |
| 52 | 64 | return JSONObject.parseObject(result); |
| 53 | 65 | } | ... | ... |
src/main/resources/application.properties
| ... | ... | @@ -27,7 +27,6 @@ sync_users_app_key=314a9dd4-a9b7-4c12-bbbe-1150a36491ae |
| 27 | 27 | url=http://mam.innerapi.cnlive.com/v1/inner/ShenHeInfo/shenheNotify |
| 28 | 28 | platformKey =AUDIT |
| 29 | 29 | platformValue=10011438 |
| 30 | -token=2718c88930175686e40398994cead75c | |
| 31 | 30 | |
| 32 | 31 | #ÆÀÂۻص÷µØÖ· |
| 33 | 32 | commenturl=http://comment.cnlive.com/services/commentForHd/auditCallBack |
| 34 | 33 | \ No newline at end of file | ... | ... |