审查视图

app/portal/controller/CommonController.php 2.7 KB
sgj authored
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
<?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();
    }
sgj authored
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
    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();
    }
sgj authored
89
}