AdminCommentController.php
3.7 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author:kane < chengjin005@163.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use cmf\controller\AdminBaseController;
use function Qiniu\thumbnail;
use think\Db;
class AdminCommentController extends AdminBaseController
{
public function index()
{
//接收搜索参数
// $param = $this->request->param();
//添加搜索条件
// $where=[];
// $keyword = empty($param['keyword']) ? '' : $param['keyword'];
// if (!empty($keyword)) {
// $where['b.name'] = ['like', "%$keyword%"];
// }
// $category1=empty($param['category1']) ? '' : $param['category1'];
// if (!empty($category1)) {
// $where['b.category_id'] = $category1;
// }
// $category2=empty($param['category2']) ? '' : $param['category2'];
// if (!empty($category2)) {
// $where['b.floor_id'] = $category2;
// }
$data = Db::name('comment')
->alias('c')
->join('brand b','b.id=c.cid')
->join('users u','u.id=c.users_id')
->where('c.status',1)
->field('u.*,b.name,c.*')
->order('c.create_time','desc')
->paginate('15');
// $ca1=Db::name('brand_category')->where('status',1)->select();
// $ca2=Db::name('brand_category')->where('status',2)->select();
// $this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
// $this->assign('ca1', isset($param['category1']) ? $param['category1'] : '');
// $this->assign('ca2', isset($param['category2']) ? $param['category2'] : '');
// $this->assign('category1',$ca1);
// $this->assign('category2',$ca2);
$this->assign('list', $data);
$this->assign('page',$data->render());
return $this->fetch();
}
public function index2(){
$data = Db::name('comment')
->alias('c')
->join('active a','c.cid=a.id')
->join('users u','c.users_id=u.id')
->where('c.status',2)
->order('c.create_time','desc')
->field('u.*,a.name,c.*')
->paginate('15');
$this->assign('list', $data);
$this->assign('page',$data->render());
return $this->fetch();
}
public function index3(){
$data = Db::name('comment')
->alias('c')
->join('prize p','c.cid=p.id')
->join('users u','c.users_id=u.id')
->where('c.status',3)
->field('u.*,p.name,c.*')
->order('c.create_time','desc')
->paginate('15');
$this->assign('list', $data);
$this->assign('page',$data->render());
return $this->fetch();
}
public function delete()
{
$id = $this->request->param('id');
$data=Db::name('comment')->where('id', $id)->find();
switch ($data['status']){
case 1:$table='brand';
break;
case 2:$table='active';
break;
case 3:$table='prize';
break;
}
Db::name('comment')->where('id', $id)->delete();
Db::name($table)->where('id',$data['cid'])->setDec('comment',1);
$this->success('删除成功');
}
}