AdminIndexController.php
4.8 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\user\controller;
use app\user\model\ScoreLogModel;
use cmf\controller\AdminBaseController;
use think\Db;
/**
* Class AdminIndexController
* @package app\user\controller
*
* @adminMenuRoot(
* 'name' =>'用户管理',
* 'action' =>'default',
* 'parent' =>'',
* 'display'=> true,
* 'order' => 10,
* 'icon' =>'group',
* 'remark' =>'用户管理'
* )
*
* @adminMenuRoot(
* 'name' =>'用户组',
* 'action' =>'default1',
* 'parent' =>'user/AdminIndex/default',
* 'display'=> true,
* 'order' => 10000,
* 'icon' =>'',
* 'remark' =>'用户组'
* )
*/
class AdminIndexController extends AdminBaseController
{
/**
* 用户列表
* @adminMenu(
* 'name' => '用户列表',
* 'parent' => 'default1',
* 'display'=> true,
* 'hasView'=> true,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '用户列表',
* 'param' => ''
* )
*/
public function index()
{
$data = $this->request->param();
$return = $this->adminIndex($data);
$page_arr = $return['page_arr'];
$where_member = $return['where_arr'];
$where_member['status'] = array('not in','8,9');
if(!empty($data['name'])){
$where_member['name'] = array('like','%'.$data['name'].'%');
$this->assign('name', $data['name']);
$page_arr['name'] = $data['name'];
}
if(!empty($data['up'])){
if($data['up'] == 1){
$order['all_score'] = 'asc';
}else if($data['up'] == 2){
$order['all_score'] = 'desc';
}
$page_arr['all_score'] = $data['up'];
}else{
$order['create_time'] = 'desc';
}
$list = Db::name('Member')->where($where_member)->order($order)->paginate(10,false,['query'=>$page_arr]);
// 获取分页显示
$page = $list->render();
$this->assign('lists', $list);
$this->assign('page', $page);
// 渲染模板输出
return $this->fetch();
}
/**查看详情
*
* @adminMenu(
* 'name' => '查看详情',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '查看详情',
* 'param' => ''
* )
*/
public function detail()
{
$data = $this->request->param();
$where_member['status'] = array('neq',9);
$where_member['id'] = $data['id'];
$list = Db::name('Member')->where($where_member)->find();
$this->assign('list', $list);
// 渲染模板输出
return $this->fetch();
}
/**修改用户信息
*
* @adminMenu(
* 'name' => '修改用户信息',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '修改用户信息',
* 'param' => ''
* )
*/
public function changeUser()
{
$data = $this->request->param();
$where_member['id'] = $data['id'];
$up = $data;
unset($up['update_time']);
unset($up['create_time']);
$up['update_time'] = time();
$list = Db::name('Member')->where($where_member)->update($up);
if($list){
$this->success('修改成功','index');
}else{
$this->error('修改失败');
}
}
/**删除用户
*
* @adminMenu(
* 'name' => '删除用户',
* 'parent' => 'index',
* 'display'=> false,
* 'hasView'=> false,
* 'order' => 10000,
* 'icon' => '',
* 'remark' => '删除用户',
* 'param' => ''
* )
*/
public function del()
{
$data = $this->request->param();
$where_member['id'] = $data['id'];
$up['update_time'] = time();
$up['status'] = 8;
$list = Db::name('Member')->where($where_member)->update($up);
if($list){
$this->apiResponse('1','操作成功');
}else{
$this->apiResponse('0','操作失败');
}
}
}