modified 优化筛选功能

This commit is contained in:
zhaoxiang 2019-06-26 15:05:25 +08:00
parent 71265083c9
commit b0aec7548f

View File

@ -27,21 +27,21 @@ class AppGroup extends Base {
$type = $this->request->get('type', ''); $type = $this->request->get('type', '');
$status = $this->request->get('status', ''); $status = $this->request->get('status', '');
$where = []; $obj = new AdminAppGroup();
if ($status === '1' || $status === '0') { if (strlen($status)) {
$where['status'] = $status; $obj = $obj->where('status', $status);
} }
if ($type) { if ($type) {
switch ($type) { switch ($type) {
case 1: case 1:
$where['hash'] = $keywords; $obj = $obj->where('hash', $keywords);
break; break;
case 2: case 2:
$where['name'] = ['like', "%{$keywords}%"]; $obj = $obj->whereLike('name', "%{$keywords}%");
break; break;
} }
} }
$listObj = (new AdminAppGroup())->where($where)->paginate($limit, false, ['page' => $start])->toArray(); $listObj = $obj->paginate($limit, false, ['page' => $start])->toArray();
return $this->buildSuccess([ return $this->buildSuccess([
'list' => $listObj['data'], 'list' => $listObj['data'],