ZjCommentController.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* Created by PhpStorm.
* User: wz
* Date: 2018/7/4
* Time: 16:42
*/
namespace app\admin\controller;
use ClassesWithParents\D;
use cmf\controller\AdminBaseController;
use think\Db;
class ZjCommentController extends AdminBaseController
{
/**
* 评论管理首页
*/
public function index()
{
$where=[];
if ($this->request->isPost()){
$in=input('post.');
if (strlen($in['ser_type'])>'0'){
$where['s.ser_type']=$in['ser_type'];
}
if (strlen($in['name'])>'0'){
$where['s.id']=$in['name'];
}
if (strlen($in['level'])>'0'){
$where['c.level']=$in['level'];
}
}
$com=Db::name('zj_comment')->alias('c')->join('user u','c.user_id=u.id')->join('zj_service s','c.service_id=s.id')->field('c.*,u.user_nickname as uname')->where($where)->paginate('10');
$service=Db::name('zj_service')->field('id,name,ser_type')->select();//查询服务名称 联动筛选
$this->assign('allservice',$service);
$this->assign('allcom',$com);
return $this->fetch();
}
/**
* 评论显示与隐藏
*/
public function comstate()
{
$param=$this->request->param();
if ($param){
$id=$this->request->param('ids/a');
if ($param['yes']=='1'){
$com=Db::name('zj_comment')->where(['id'=>['in',$id]])->update(['is_sta'=>'1']);
}else{
$com=Db::name('zj_comment')->where(['id'=>['in',$id]])->update(['is_sta'=>'0']);
}
if ($com){
$this->success('评论可见度修改成功','');
}else{
$this->error('评论可见度修改失败');
}
}
}
/**
* 删除评论
*/
public function delete()
{
if ($this->request->param()){
$id=$this->request->param('ids/a');
$del=Db::name('zj_comment')->where(['id'=>['in',$id]])->delete();
if($del){
$this->success('评论删除成功','');
}else{
$this->error('评论删除失败');
}
}
}
}