/** * 添加新评论 * * @param docId 文档ID * @param commentUser 评论用户名 * @param isGuest 是否是匿名用户 * @param docComment 评论内容 * @param status 评论状态 * @param request HttpServletRequest * @return String * @throws Exception */ public @ResponseBody(datatype = "jsonp") CommentResult addNewComment( long channelId, int docId, String commentUser, String isGuest, String docComment, HttpServletRequest request) throws Exception { DocComment docCommentBean = new DocComment(); if (StringUtil.isEmpty(commentUser)) { if (Boolean.parseBoolean(isGuest)) docCommentBean.setUserName("__quest"); } else { docCommentBean.setUserName(URLDecoder.decode(commentUser, "UTF-8")); } docCommentBean.setDocId(docId); if (!StringUtil.isEmpty(docComment)) { docCommentBean.setDocComment(URLDecoder.decode(docComment, "UTF-8")); } docCommentBean.setUserIP(com.frameworkset.util.StringUtil.getClientIP(request)); // 默认即可发布 int status = 1; // 获取频道的评论审核开关 Integer aduitSwitchFlag = docCommentManager.getChannelCommentAduitSwitch((int) channelId); if (aduitSwitchFlag != null) { // 如果评论为开通状态,则评论的状态为待审核,否则为即可发布状态 status = aduitSwitchFlag == 0 ? 2 : 1; } docCommentBean.setStatus(status); CommentResult result = new CommentResult(); result.setAduitSwitchFlag(aduitSwitchFlag + ""); try { docCommentManager.addOneComment(docCommentBean); result.setMsg("success"); } catch (DocCommentManagerException e) { result.setMsg("failed"); result.setError(StringUtil.exceptionToString(e)); } return result; }