CommonController.php
4.0 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
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2018/12/8
* Time: 15:25
*/
namespace app\portal\controller;
use think\Db;
use cmf\controller\AdminBaseController;
class CommonController extends AdminBaseController
{
public function selectUsers()
{
$param = $this->request->param();
$ids = $this->request->param('ids');
$selectedIds = explode(',',$ids);
if (!is_array($selectedIds)) {
$selectedIds = [$selectedIds];
}
$where['user_type'] = ['in','1,2,3'];
$request = input('request.');
if (!empty($request['uid'])) {
$where['id'] = intval($request['uid']);
}
$keywordComplex = [];
if (!empty($request['keyword'])) {
$keyword = $request['keyword'];
$keywordComplex['user_login|user_nickname|mobile'] = ['like', "%$keyword%"];
}
$usersQuery = Db::name('user');
$list = $usersQuery->field('id,user_nickname,user_login,avatar,mobile')
->whereOr($keywordComplex)
->where($where)
->order("create_time DESC")
->paginate(50);
$list->appends($param);
$this->assign('selectedIds', $selectedIds);
$this->assign('uid', isset($param['uid']) ? $param['uid'] : '');
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
$this->assign('ids', isset($param['ids']) ? $param['ids'] : '');
$this->assign('list', $list->items());
$this->assign('page', $list->render());
return $this->fetch();
}
public function selectUsersMore()
{
$param = $this->request->param();
$ids = $this->request->param('ids');
$selectedIds = explode(',',$ids);
if (!is_array($selectedIds)) {
$selectedIds = [$selectedIds];
}
$where['user_type'] = ['in','1,2,3'];
$request = input('request.');
if (!empty($request['uid'])) {
$where['id'] = intval($request['uid']);
}
$keywordComplex = [];
if (!empty($request['keyword'])) {
$keyword = $request['keyword'];
$keywordComplex['user_login|user_nickname|mobile'] = ['like', "%$keyword%"];
}
$usersQuery = Db::name('user');
$list = $usersQuery->field('id,user_nickname,user_login,avatar,mobile')
->whereOr($keywordComplex)
->where($where)
->order("create_time DESC")
->paginate(50);
$list->appends($param);
$this->assign('selectedIds', $selectedIds);
$this->assign('uid', isset($param['uid']) ? $param['uid'] : '');
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
$this->assign('ids', isset($param['ids']) ? $param['ids'] : '');
$this->assign('list', $list->items());
$this->assign('page', $list->render());
return $this->fetch();
}
public function selectGroup(){
$param = $this->request->param();
$ids = $this->request->param('ids');
$selectedIds = explode(',',$ids);
if (!is_array($selectedIds)) {
$selectedIds = [$selectedIds];
}
$request = input('request.');
if (!empty($request['uid'])) {
$where['id'] = intval($request['uid']);
}
$keywordComplex = [];
$usersQuery = Db::name('group');
$list = $usersQuery->field('id,name,descripe')
->whereOr($keywordComplex)
// ->where($where)
->order("addtime DESC")
->paginate(50);
$list->appends($param);
$this->assign('selectedIds', $selectedIds);
$this->assign('gid', isset($param['uid']) ? $param['uid'] : '');
$this->assign('keyword', isset($param['keyword']) ? $param['keyword'] : '');
$this->assign('ids', isset($param['ids']) ? $param['ids'] : '');
$this->assign('list', $list->items());
$this->assign('page', $list->render());
return $this->fetch();
}
}