| 12345678910111213141516171819202122232425262728293031323334353637383940414243 | <?phpnamespace app\api\controller;use app\api\controller\base\Base;class Specialist extends Base{    private function getModel()    {        return new \app\common\model\Specialist();    }    public function index()    {        $post = $this->request->param();        $validate = new \think\Validate([            ['id', 'number'],            ['page', 'number'],            ['pagenum', 'number|<=:1000']        ]);        if (!$validate->check($post)) {            $this->json_error('提交失败:' . $validate->getError());        }        $where = [];        if (isset($post['id'])) {            $where['id'] = $post['id'];        }        if (isset($post['id'])) {            $datalist = ($this->getModel())->where($where)->find();        } else {            $pagenum = $this->request->param('pagenum', 20, 'intval');            $datalist = ($this->getModel())->where($where)->paginate($pagenum, true);        }        if (empty($datalist)) {            $this->json_error("没有数据");        }        $this->json_success("查询成功", $datalist);    }}
 |