CommonController.php
1.6 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
<?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();
}
}