Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何实现排序分页呢,只看到有分页 #5

Closed
wyt232 opened this issue Feb 25, 2020 · 4 comments
Closed

如何实现排序分页呢,只看到有分页 #5

wyt232 opened this issue Feb 25, 2020 · 4 comments

Comments

@wyt232
Copy link

wyt232 commented Feb 25, 2020

如题,请教

@phper666
Copy link
Owner

@wyt232 我给个截图你参考下
image

@phper666
Copy link
Owner

@wyt232 图片要翻墙才能看,我直接给你看下代码

public function getList(array $params)
    {
        $filter = [];
        if (!empty($params['enterprise_id'])) $filter['enterprise_id'] = $params['enterprise_id'];
        if (!empty($params['name'])) $filter['name'] = ['$regex' => "{$params['name']}"];
        $options = [
            'sort' => ['parentid' => 1, 'order' => -1],
            'projection' => [
                'name' => 1,
                'name_en' => 1,
                'parentid' => 1,
                'order' => 1,
                'description' => 1,
                'updated_at' => 1,
                'enterprise_id' => 1,
                'department_id' => 1,
            ]
        ];
        $data = $this->enterpriseDepartmentModel->findPagination($params['page_no'], $params['page_size'], $filter, $options);
        foreach ($data['rows'] as &$v) {
            $v['staff_count'] = $this->getStaffCountByDepartment($params['enterprise_id'], $v['department_id']);
            $v['updated_at'] = date('Y-m-d H:i:s', $v['updated_at']);
        }
        return $data;
    }

@phper666
Copy link
Owner

sort就是可以直接排序

@wyt232
Copy link
Author

wyt232 commented Feb 26, 2020

sort就是可以直接排序

谢了大佬

@wyt232 wyt232 closed this as completed Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants