<?php
/**
 * 用户管理Controller
 * Created by PhpStorm.
 * User: 小威
 * Date: 2020/03/28
 * Time: 14:59
 */

namespace JinDouYun\Controller\Manage;

use Mall\Framework\Core\ErrorCode;
use Mall\Framework\Core\StatusCode;

use JinDouYun\Controller\BaseController;

use JinDouYun\Model\Manage\MUser;

class User extends BaseController
{
    private $objMUser;

    public function __construct($isCheckAcl = false, $isMustLogin = false, $checkToken = false)
    {
        parent::__construct($isCheckAcl, $isMustLogin, $checkToken);
        $this->objMUser = new MUser();
    }

    /**
     * 获取用户列表
     * @throws \Exception
     */
    public function getAllUser()
    {
        $params = $this->request->getRawJson();

        $data = [
            'page' => isset($params['page']) ? $params['page'] : 1,
            'pageSize' => isset($params['pageSize']) ? $params['pageSize'] : 10,
        ];

        $selectParams = [
            'offset' => ($data['page'] - 1) * $data['pageSize'],
            'limit' => $data['pageSize'],
        ];
        $result = $this->objMUser->getAllUser($selectParams);
        if ($result->isSuccess()) {
            parent::sendOutput($result->getData());
        } else {
            parent::sendOutput($result->getData(), ErrorCode::$dberror);
        }
    }

}