forum search
This commit is contained in:
parent
c58a20b53c
commit
c02cc0159c
@ -20,21 +20,66 @@ class Forum extends AdminController
|
|||||||
public function list()
|
public function list()
|
||||||
{
|
{
|
||||||
if(Request::isAjax()){
|
if(Request::isAjax()){
|
||||||
|
$data = Request::only(['id','name','title','sec']);
|
||||||
|
$where =array();
|
||||||
|
//var_dump($data);
|
||||||
|
if (!empty($data['sec'])) {
|
||||||
|
switch ($data['sec']) {
|
||||||
|
case '0':
|
||||||
|
$data['status'] = $data['sec'];
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
$data['status'] = $data['sec'];
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
$data['is_top'] = 1;
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
$data['is_hot'] = 1;
|
||||||
|
break;
|
||||||
|
case '4':
|
||||||
|
$data['is_replay'] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unset($data['sec']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($data['id'])){
|
||||||
|
$data['a.id'] = $data['id'];
|
||||||
|
unset($data['id']);
|
||||||
|
}
|
||||||
|
if(!empty($data['status'])){
|
||||||
|
$data['a.status'] = $data['status'];
|
||||||
|
unset($data['status']);
|
||||||
|
}
|
||||||
|
if(!empty($data['title'])){
|
||||||
|
$where[] = ['title', 'like', '%'.$data['title'].'%'];
|
||||||
|
//var_dump($map);
|
||||||
|
unset($data['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$map = array_filter($data);
|
||||||
|
|
||||||
$forumList = Db::name('article')
|
$forumList = Db::name('article')
|
||||||
->alias('a')
|
->alias('a')
|
||||||
->join('user u','a.user_id = u.id')
|
->join('user u','a.user_id = u.id')
|
||||||
->field('a.id as aid,name,user_img,title,a.update_time as update_time,is_top,is_hot,a.status as astatus')
|
->field('a.id as aid,name,user_img,title,a.update_time as update_time,is_top,is_hot,a.status as astatus')
|
||||||
->where('a.delete_time',0)
|
->where('a.delete_time',0)
|
||||||
|
->where($map)
|
||||||
|
->where($where)
|
||||||
->order('a.create_time', 'desc')
|
->order('a.create_time', 'desc')
|
||||||
->paginate(15);
|
->paginate(15);
|
||||||
$res = [];
|
$res = [];
|
||||||
if($forumList){
|
$count = $forumList->total();
|
||||||
|
if($count){
|
||||||
$res['code'] = 0;
|
$res['code'] = 0;
|
||||||
$res['msg'] = '';
|
$res['msg'] = '';
|
||||||
$res['count'] = $forumList->total();
|
$res['count'] = $count;
|
||||||
foreach($forumList as $k=>$v){
|
foreach($forumList as $k=>$v){
|
||||||
$res['data'][]= ['id'=>$v['aid'],'poster'=>$v['name'],'avatar'=>$v['user_img'],'content'=>$v['title'],'posttime'=>date("Y-m-d",$v['update_time']),'top'=>$v['is_top'],'hot'=>$v['is_hot'],'check'=>$v['astatus']];
|
$res['data'][]= ['id'=>$v['aid'],'poster'=>$v['name'],'avatar'=>$v['user_img'],'content'=>$v['title'],'posttime'=>date("Y-m-d",$v['update_time']),'top'=>$v['is_top'],'hot'=>$v['is_hot'],'check'=>$v['astatus']];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$res = ['code'=>-1,'msg'=>'没有查询结果!'];
|
||||||
}
|
}
|
||||||
return json($res);
|
return json($res);
|
||||||
}
|
}
|
||||||
@ -171,6 +216,14 @@ class Forum extends AdminController
|
|||||||
public function replys()
|
public function replys()
|
||||||
{
|
{
|
||||||
if(Request::isAjax()) {
|
if(Request::isAjax()) {
|
||||||
|
$data = Request::only(['name','content']);
|
||||||
|
$map = array_filter($data);
|
||||||
|
$where = array();
|
||||||
|
if(!empty($map['content'])){
|
||||||
|
$where[] = ['a.content','like','%'.$map['content'].'%'];
|
||||||
|
unset($map['content']);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$replys = Comment::field('id,article_id,user_id,content,create_time')->with([
|
$replys = Comment::field('id,article_id,user_id,content,create_time')->with([
|
||||||
'user' => function($query){
|
'user' => function($query){
|
||||||
@ -187,17 +240,21 @@ class Forum extends AdminController
|
|||||||
->join('article c','a.article_id = c.id')
|
->join('article c','a.article_id = c.id')
|
||||||
->field('a.id as aid,name,title,user_img,a.content as content,a.create_time as create_time,a.status as astatus,c.id as cid')
|
->field('a.id as aid,name,title,user_img,a.content as content,a.create_time as create_time,a.status as astatus,c.id as cid')
|
||||||
->where('a.delete_time',0)
|
->where('a.delete_time',0)
|
||||||
|
->where($map)
|
||||||
|
->where($where)
|
||||||
->order('a.create_time', 'desc')
|
->order('a.create_time', 'desc')
|
||||||
->paginate(15);
|
->paginate(15);
|
||||||
|
|
||||||
$count = $replys->total();
|
$count = $replys->total();
|
||||||
$res = [];
|
$res = [];
|
||||||
if ($replys) {
|
if ($count) {
|
||||||
$res = ['code'=>0,'msg'=>'','count'=>$count];
|
$res = ['code'=>0,'msg'=>'','count'=>$count];
|
||||||
foreach($replys as $k => $v){
|
foreach($replys as $k => $v){
|
||||||
//$res['data'][] = ['id'=>$v['id'],'replyer'=>$v->user->name,'cardid'=>$v->article->title,'avatar'=>$v->user->user_img,'content'=>$v['content'],'replytime'=>$v['create_time']];
|
//$res['data'][] = ['id'=>$v['id'],'replyer'=>$v->user->name,'cardid'=>$v->article->title,'avatar'=>$v->user->user_img,'content'=>$v['content'],'replytime'=>$v['create_time']];
|
||||||
$res['data'][] = ['id'=>$v['aid'],'replyer'=>$v['name'],'cardid'=>$v['title'],'avatar'=>$v['user_img'],'content'=>$v['content'],'replytime'=>date("Y-m-d",$v['create_time']),'check'=>$v['astatus'],'cid'=>$v['cid']];
|
$res['data'][] = ['id'=>$v['aid'],'replyer'=>$v['name'],'cardid'=>$v['title'],'avatar'=>$v['user_img'],'content'=>$v['content'],'replytime'=>date("Y-m-d",$v['create_time']),'check'=>$v['astatus'],'cid'=>$v['cid']];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$res = ['code'=>-1,'msg'=>'没有查询结果!'];
|
||||||
}
|
}
|
||||||
return json($res);
|
return json($res);
|
||||||
}
|
}
|
||||||
|
@ -14,22 +14,26 @@
|
|||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label class="layui-form-label">发帖人</label>
|
<label class="layui-form-label">发帖人</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="text" name="poster" placeholder="请输入" autocomplete="off" class="layui-input">
|
<input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label class="layui-form-label">发帖内容</label>
|
<label class="layui-form-label">发帖名称</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="text" name="content" placeholder="请输入" autocomplete="off" class="layui-input">
|
<input type="text" name="title" placeholder="请输入" autocomplete="off" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
<label class="layui-form-label">帖子状态</label>
|
<label class="layui-form-label">帖子状态</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<select name="top">
|
<select name="sec">
|
||||||
<option value="0">正常</option>
|
<option value="">选择状态</option>
|
||||||
<option value="1">置顶</option>
|
<option value="1">正常</option>
|
||||||
<option value="2">封禁</option>
|
<option value="2">置顶</option>
|
||||||
|
<option value="3">热门</option>
|
||||||
|
<option value="4">禁回</option>
|
||||||
|
<option value="0">封禁</option>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -67,7 +71,7 @@
|
|||||||
{{# } }}
|
{{# } }}
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="buttonCheck">
|
<script type="text/html" id="buttonCheck">
|
||||||
{if condition="checkRuleButton('admin/forum/check')"}<input type="checkbox" name="check" lay-skin="switch" lay-filter="forumcheck" lay-text="已审核|未审核" {{# if(d.check == 1){ }} checked {{# } }} id="{{d.id}}" >{else}<button class="layui-btn layui-btn-xs layui-btn-radius layui-btn-disabled">无审核权</button>{/if}
|
{if condition="checkRuleButton('admin/forum/check')"}<input type="checkbox" name="check" lay-skin="switch" lay-filter="forumcheck" lay-text="正常|封禁" {{# if(d.check == 1){ }} checked {{# } }} id="{{d.id}}" >{else}<button class="layui-btn layui-btn-xs layui-btn-radius layui-btn-disabled">无审核权</button>{/if}
|
||||||
</script>
|
</script>
|
||||||
<script type="text/html" id="table-forum-list">
|
<script type="text/html" id="table-forum-list">
|
||||||
<a class="layui-btn layui-btn-disabled layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
|
<a class="layui-btn layui-btn-disabled layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
|
||||||
@ -93,6 +97,23 @@
|
|||||||
//监听搜索
|
//监听搜索
|
||||||
form.on('submit(LAY-app-forumlist-search)', function(data){
|
form.on('submit(LAY-app-forumlist-search)', function(data){
|
||||||
var field = data.field;
|
var field = data.field;
|
||||||
|
$.ajax({
|
||||||
|
type:"post",
|
||||||
|
url:"{:url('admin/Forum/list')}",
|
||||||
|
data:{field},
|
||||||
|
daType:"json",
|
||||||
|
success:function (data){
|
||||||
|
if (data.code == 0) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
layer.open({
|
||||||
|
content:data.msg,
|
||||||
|
icon:5,
|
||||||
|
anim:6
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//执行重载
|
//执行重载
|
||||||
table.reload('LAY-app-forum-list', {
|
table.reload('LAY-app-forum-list', {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<div class="layui-inline layuiadmin-input-useradmin">
|
<div class="layui-inline layuiadmin-input-useradmin">
|
||||||
<label class="layui-form-label">回帖人</label>
|
<label class="layui-form-label">回帖人</label>
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
<input type="text" name="replyer" placeholder="请输入" autocomplete="off" class="layui-input">
|
<input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-inline">
|
<div class="layui-inline">
|
||||||
@ -63,6 +63,23 @@
|
|||||||
//监听搜索
|
//监听搜索
|
||||||
form.on('submit(LAY-app-forumreply-search)', function(data){
|
form.on('submit(LAY-app-forumreply-search)', function(data){
|
||||||
var field = data.field;
|
var field = data.field;
|
||||||
|
$.ajax({
|
||||||
|
type:"post",
|
||||||
|
url:"{:url('admin/Forum/replys')}",
|
||||||
|
data:{field},
|
||||||
|
daType:"json",
|
||||||
|
success:function (data){
|
||||||
|
if (data.code == 0) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
layer.open({
|
||||||
|
content:data.msg,
|
||||||
|
icon:5,
|
||||||
|
anim:6
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//执行重载
|
//执行重载
|
||||||
table.reload('LAY-app-forumreply-list', {
|
table.reload('LAY-app-forumreply-list', {
|
||||||
|
Loading…
Reference in New Issue
Block a user