Commit be78d0728972b79145f4c7ace4ddad0eabd5cb9b

Authored by 刘基城
1 parent 07792922

添加关键词过滤

.settings/org.eclipse.wst.common.component
@@ -8,6 +8,15 @@ @@ -8,6 +8,15 @@
8 <dependent-module archiveName="cnlive_live_model-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/cnlive_live_model/cnlive_live_model"> 8 <dependent-module archiveName="cnlive_live_model-0.0.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/cnlive_live_model/cnlive_live_model">
9 <dependency-type>uses</dependency-type> 9 <dependency-type>uses</dependency-type>
10 </dependent-module> 10 </dependent-module>
  11 + <dependent-module archiveName="cnlive_ks3-1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/cnlive_ks3/cnlive_ks3">
  12 + <dependency-type>uses</dependency-type>
  13 + </dependent-module>
  14 + <dependent-module archiveName="smart-framework-4.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-framework/smart-framework">
  15 + <dependency-type>uses</dependency-type>
  16 + </dependent-module>
  17 + <dependent-module archiveName="smart-plugin-job-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-job/smart-plugin-job">
  18 + <dependency-type>uses</dependency-type>
  19 + </dependent-module>
11 <dependent-module archiveName="smart-plugin-dbcp-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-dbcp/smart-plugin-dbcp"> 20 <dependent-module archiveName="smart-plugin-dbcp-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/smart-plugin-dbcp/smart-plugin-dbcp">
12 <dependency-type>uses</dependency-type> 21 <dependency-type>uses</dependency-type>
13 </dependent-module> 22 </dependent-module>
src/main/java/com/cnlive/mz/live/action/VideoAction.java
@@ -18,6 +18,8 @@ import org.smart4j.framework.mvc.bean.View; @@ -18,6 +18,8 @@ import org.smart4j.framework.mvc.bean.View;
18 import org.smart4j.framework.util.CastUtil; 18 import org.smart4j.framework.util.CastUtil;
19 19
20 import com.cnlive.mz.commons.CnliveUtil; 20 import com.cnlive.mz.commons.CnliveUtil;
  21 +import com.cnlive.mz.commons.sensitive.FilteredResult;
  22 +import com.cnlive.mz.commons.sensitive.WordFilterUtil;
21 import com.cnlive.mz.live.common.Constants; 23 import com.cnlive.mz.live.common.Constants;
22 import com.cnlive.mz.live.common.LiveUtils; 24 import com.cnlive.mz.live.common.LiveUtils;
23 import com.cnlive.mz.live.entity.TLive; 25 import com.cnlive.mz.live.entity.TLive;
@@ -70,13 +72,18 @@ public class VideoAction { @@ -70,13 +72,18 @@ public class VideoAction {
70 if (title.length() > 50) { 72 if (title.length() > 50) {
71 title = title.substring(0, 50); 73 title = title.substring(0, 50);
72 } 74 }
73 - String direct = params.getString("direct");  
74 String description = params.getString("description"); 75 String description = params.getString("description");
  76 + FilteredResult resTitle = WordFilterUtil.filterHtml(title, '*');
  77 + title=resTitle.getFilteredContent().toString();
  78 + FilteredResult resDescr= WordFilterUtil.filterHtml(description, '*');
  79 + description=resDescr.getFilteredContent().toString();
  80 +
  81 + String direct = params.getString("direct");
75 String custom_args = params.getString("custom_args"); 82 String custom_args = params.getString("custom_args");
76 String md5 = params.getString("md5"); 83 String md5 = params.getString("md5");
77 String relation_id = params.getString("relation_id"); 84 String relation_id = params.getString("relation_id");
78 String uuid = ""; 85 String uuid = "";
79 - boolean success=true; 86 + boolean success = true;
80 if (video_type.equals("2")) { 87 if (video_type.equals("2")) {
81 // 2:sdk上传录播文件 88 // 2:sdk上传录播文件
82 TVideo tVideo = new TVideo(); 89 TVideo tVideo = new TVideo();
@@ -108,14 +115,14 @@ public class VideoAction { @@ -108,14 +115,14 @@ public class VideoAction {
108 tLive.setDirect(Integer.parseInt(direct)); 115 tLive.setDirect(Integer.parseInt(direct));
109 } 116 }
110 tLive.setLive_url(Constants.KS_HOST_RTMP + tLive.getT_user_id() + "_" + uuid); 117 tLive.setLive_url(Constants.KS_HOST_RTMP + tLive.getT_user_id() + "_" + uuid);
111 - success=tLiveService.startLive(tLive); 118 + success = tLiveService.startLive(tLive);
112 } 119 }
113 data.put("video_uuid", uuid); 120 data.put("video_uuid", uuid);
114 ApiBean apiBean = new ApiBean(); 121 ApiBean apiBean = new ApiBean();
115 if (success) { 122 if (success) {
116 apiBean.setCode(100); 123 apiBean.setCode(100);
117 apiBean.setMessage("请求成功"); 124 apiBean.setMessage("请求成功");
118 - }else{ 125 + } else {
119 apiBean.setCode(201); 126 apiBean.setCode(201);
120 apiBean.setMessage("发起直播失败"); 127 apiBean.setMessage("发起直播失败");
121 } 128 }
@@ -161,10 +168,10 @@ public class VideoAction { @@ -161,10 +168,10 @@ public class VideoAction {
161 @Request.Get("/video/view/{id}") 168 @Request.Get("/video/view/{id}")
162 public View view(int id) { 169 public View view(int id) {
163 TVideo tVideo = tVideoService.getVideoById(id); 170 TVideo tVideo = tVideoService.getVideoById(id);
164 - System.out.println("------"+tVideo); 171 + System.out.println("------" + tVideo);
165 return new View("live/video_view.jsp").data("tVideo", tVideo); 172 return new View("live/video_view.jsp").data("tVideo", tVideo);
166 } 173 }
167 - 174 +
168 @Request.Post("/api/video/one") 175 @Request.Post("/api/video/one")
169 public ApiBean one(Params params) { 176 public ApiBean one(Params params) {
170 String app_access_key = params.getString("app_access_key"); 177 String app_access_key = params.getString("app_access_key");
@@ -190,7 +197,7 @@ public class VideoAction { @@ -190,7 +197,7 @@ public class VideoAction {
190 tVideoService.notify(video_uuid); 197 tVideoService.notify(video_uuid);
191 } else if (video_type.equals("3")) { 198 } else if (video_type.equals("3")) {
192 // 直播通知 199 // 直播通知
193 - //tLiveService.notify(video_uuid); 200 + // tLiveService.notify(video_uuid);
194 // 直播正常结束 201 // 直播正常结束
195 tLiveService.notify(video_uuid, 2); 202 tLiveService.notify(video_uuid, 2);
196 } 203 }
@@ -231,8 +238,9 @@ public class VideoAction { @@ -231,8 +238,9 @@ public class VideoAction {
231 } 238 }
232 log.info(sb.toString()); 239 log.info(sb.toString());
233 } 240 }
  241 +
234 @Request.Post("/video/unline") 242 @Request.Post("/video/unline")
235 - public Result underLine(Params params){ 243 + public Result underLine(Params params) {
236 int id = params.getInt("id"); 244 int id = params.getInt("id");
237 tVideoService.underLine(id); 245 tVideoService.underLine(id);
238 return null; 246 return null;
src/main/java/com/cnlive/mz/live/action/WordAction.java 0 → 100644
  1 +package com.cnlive.mz.live.action;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +import java.util.Map.Entry;
  6 +
  7 +import org.smart4j.framework.ioc.annotation.Inject;
  8 +import org.smart4j.framework.mvc.annotation.Action;
  9 +import org.smart4j.framework.mvc.annotation.Request;
  10 +import org.smart4j.framework.mvc.bean.Params;
  11 +import org.smart4j.framework.mvc.bean.Result;
  12 +import org.smart4j.framework.mvc.bean.View;
  13 +
  14 +import com.cnlive.mz.live.entity.TRoom;
  15 +import com.cnlive.mz.live.service.SensitiveWordService;
  16 +
  17 +@Action
  18 +public class WordAction {
  19 +
  20 + @Inject
  21 + private SensitiveWordService sensitiveWord;
  22 +
  23 + @Request.Post("/word/add")
  24 + public Result add(Params params){
  25 + Map map = params.getFieldMap();
  26 + String str = (String) map.get("words");
  27 + str=str.replace(",", ",3.");
  28 + str=str+",3.";
  29 + return new Result(sensitiveWord.add(str));
  30 + }
  31 +
  32 + @Request.Get("/word/list")
  33 + public View list(){
  34 + View view = new View("word/word_management.jsp");
  35 + List<String> str = sensitiveWord.list();
  36 + view.data("str", str);
  37 + return view;
  38 + }
  39 +}
src/main/webapp/pages/common/left.jsp
@@ -71,6 +71,9 @@ @@ -71,6 +71,9 @@
71 <li> 71 <li>
72 <a href="${BASE}/live/alllive/1"><i class="fa fa-circle-o text-yellow"></i>直播管理</a> 72 <a href="${BASE}/live/alllive/1"><i class="fa fa-circle-o text-yellow"></i>直播管理</a>
73 </li> 73 </li>
  74 + <li>
  75 + <a href="${BASE}/word/list"><i class="fa fa-circle-o text-yellow"></i>敏感词管理</a>
  76 + </li>
74 </c:if> 77 </c:if>
75 </ul> 78 </ul>
76 </section> 79 </section>
src/main/webapp/pages/word/word_add.jsp 0 → 100644
  1 +<%@ page language="java" pageEncoding="UTF-8"%>
  2 +<%@ include file="/pages/common/taglib.jsp"%>
  3 +<!DOCTYPE html>
  4 +<html>
  5 +<head>
  6 +<meta charset="UTF-8">
  7 +<title>添加敏感词 | <f:message key="common.title" /></title>
  8 +<meta
  9 + content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
  10 + name='viewport'>
  11 +<%@ include file="/pages/common/css.jsp"%>
  12 +<link href="${BASE}/static/assets/plugins/uploadfile/css/fileinput.css"
  13 + media="all" rel="stylesheet" type="text/css" />
  14 +<!--[if IE]>
  15 + <script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
  16 + <![endif]-->
  17 +</head>
  18 +<body class="skin-blue sidebar-mini">
  19 + <div class="wrapper">
  20 + <%@ include file="/pages/common/top.jsp"%>
  21 + <%@ include file="/pages/common/left.jsp"%>
  22 + <div class="content-wrapper">
  23 + <!-- Content Header (Page header) -->
  24 + <section class="content-header">
  25 + <h1>
  26 + <small>添加敏感词</small> <small
  27 + class="label label-warning" style="display: none"
  28 + id="info_tab_span"><i class="fa fa-bell-o"></i>保存成功</small>
  29 + </h1>
  30 + <ol class="breadcrumb">
  31 + <li><a><i class="fa fa-dashboard"></i> 首页</a></li>
  32 + <li class="active">添加敏感词</li>
  33 + </ol>
  34 + </section>
  35 + <!-- Main content -->
  36 + <section class="content">
  37 + <div class="row">
  38 + <div class="col-md-12">
  39 + <form id="create_form" method="post">
  40 + <div class="box box-success">
  41 + <div class="box-body">
  42 + <div class="form-group">
  43 + <label>请输入关键词 </label>
  44 + <div class="input-group">
  45 + <span class="input-group-addon"><i class="fa fa-font"></i>
  46 + </span> <textarea id="words" name="words" class="form-control" rows="3" placeholder="北京,上海,天津"></textarea>
  47 + </div>
  48 + </div>
  49 + </div>
  50 + <button type="submit" id="t_channel_save_btn"
  51 + class="btn btn-primary">
  52 + <i class="fa fa-save "></i> 保存
  53 + </button>
  54 + </form>
  55 + </div>
  56 + </div>
  57 + </section>
  58 + </div>
  59 + <%@ include file="/pages/common/bottom.jsp"%>
  60 + </div>
  61 + <%@ include file="/pages/common/js.jsp"%>
  62 + <script type="text/javascript">
  63 + $(function() {
  64 + $('#create_form').ajaxForm({
  65 + type : 'post',
  66 + url : '../../word/add',
  67 + beforeSubmit : function() {
  68 + return true;
  69 + },
  70 + error : function(XMLHttpRequest, textStatus, errorThrown) {
  71 + alert("错误");
  72 + },
  73 + success : function(result) {
  74 + alert("添加成功");
  75 + location.href = '../../word/list';
  76 + }
  77 + });
  78 + });
  79 +
  80 + </script>
  81 +</body>
  82 +</html>
src/main/webapp/pages/word/word_management.jsp 0 → 100644
  1 +<%@ page language="java" pageEncoding="UTF-8"%>
  2 +<%@ include file="/pages/common/taglib.jsp"%>
  3 +<!DOCTYPE html>
  4 +<html>
  5 +<head>
  6 +<meta charset="UTF-8">
  7 +<title>所有关键词 | <f:message key="common.title" /></title>
  8 +<meta
  9 + content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
  10 + name='viewport'>
  11 +<%@ include file="/pages/common/css.jsp"%>
  12 +<link href="${BASE}/static/assets/plugins/uploadfile/css/fileinput.css"
  13 + media="all" rel="stylesheet" type="text/css" />
  14 +<!--[if IE]>
  15 + <script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
  16 + <![endif]-->
  17 +</head>
  18 +<body class="skin-blue sidebar-mini">
  19 + <div class="wrapper">
  20 + <%@ include file="/pages/common/top.jsp"%>
  21 + <%@ include file="/pages/common/left.jsp"%>
  22 + <div class="content-wrapper">
  23 + <!-- Content Header (Page header) -->
  24 + <section class="content-header">
  25 + <h1>
  26 + 所有关键词 <small><a href="../pages/word/word_add.jsp"><i
  27 + class="fa fa-plus"></i>新增</a> </small><small class="label label-warning" style="display: none"
  28 + id="info_tab_span"><i class="fa fa-bell-o"></i>保存成功</small>
  29 + </h1>
  30 + <ol class="breadcrumb">
  31 + <li><a><i class="fa fa-dashboard"></i> 首页</a></li>
  32 + <li class="active">所有关键词</li>
  33 + </ol>
  34 + </section>
  35 + <!-- Main content -->
  36 + <section class="content">
  37 + <div class="row">
  38 + <div class="col-md-12">
  39 + <div class="box box-success">
  40 + <div class="box-body">
  41 + <div class="form-group">
  42 + <table class="table table-bordered">
  43 + <tr>
  44 + <!-- <th>过滤</th>-->
  45 + </tr>
  46 + <c:forEach var="str" items="${str}"
  47 + varStatus="stat">
  48 + <tr>
  49 + <td>${str}</td>
  50 + </tr>
  51 + </c:forEach>
  52 + </table>
  53 + </div>
  54 + </div>
  55 + </div>
  56 + </div>
  57 + </section>
  58 + </div>
  59 + <%@ include file="/pages/common/bottom.jsp"%>
  60 + </div>
  61 +</body>
  62 +</html>
target/m2e-wtp/web-resources/META-INF/maven/com.cnlive.mz.live.web/cnlive_live_web/pom.properties
1 #Generated by Maven Integration for Eclipse 1 #Generated by Maven Integration for Eclipse
2 -#Thu Jun 23 09:20:00 CST 2016 2 +#Mon Jun 27 14:02:38 CST 2016
3 version=0.0.1-SNAPSHOT 3 version=0.0.1-SNAPSHOT
4 groupId=com.cnlive.mz.live.web 4 groupId=com.cnlive.mz.live.web
5 m2e.projectName=cnlive_live_web 5 m2e.projectName=cnlive_live_web
6 m2e.projectLocation=D\:\\1_CNLIVE_JAVA_CODE\\cnlive_live_web 6 m2e.projectLocation=D\:\\1_CNLIVE_JAVA_CODE\\cnlive_live_web
7 artifactId=cnlive_live_web 7 artifactId=cnlive_live_web
8 -#Generated by Maven Integration for Eclipse  
9 -#Tue Jun 21 13:17:57 CST 2016  
10 -version=0.0.1-SNAPSHOT  
11 -groupId=com.cnlive.mz.live.web  
12 -m2e.projectName=cnlive_live_web  
13 -m2e.projectLocation=D\:\\1_CNLIVE_JAVA_CODE\\cnlive_live_web  
14 -artifactId=cnlive_live_web  
15 -#Generated by Maven Integration for Eclipse  
16 -#Mon Jun 20 09:31:18 CST 2016  
17 -#Mon Jun 20 10:10:00 CST 2016  
18 -#Fri Jun 17 09:20:43 CST 2016  
19 -version=0.0.1-SNAPSHOT  
20 -groupId=com.cnlive.mz.live.web  
21 -m2e.projectName=cnlive_live_web  
22 -m2e.projectLocation=C\:\\Users\\Administrator\\git\\cnlive_live_web  
23 -artifactId=cnlive_live_web  
24 \ No newline at end of file 8 \ No newline at end of file