[], 'allow' => ['verification'] ]; Hook::listen('check_auth',$action); $request = Request::instance(); $a = strtolower($request->action()); if (!in_array($a, $action['permission'])) { parent::_initialize(); } } /** * 列表 * * @return \think\response\Json */ public function index() { $data = [ ['type' => 1, 'name' => '全部应用'], ['type' => 2, 'name' => '客户管理'], ['type' => 3, 'name' => '任务/审批'], ['type' => 4, 'name' => '日志'], ['type' => 5, 'name' => '项目管理'], ['type' => 6, 'name' => '日历'], // ['type' => 7, 'name' => '知识库'], ]; return resultArray(['data' => $data]); } /** * 初始化数据 * * @param InitializeLogic $initializeLogic * @return \think\response\Json * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function update(InitializeLogic $initializeLogic) { if (empty($this->param['type']) || !is_array($this->param['type'])) return resultArray(['error' => '模块类型错误!']); if (!empty($this->param['password']) && !$initializeLogic->verification($this->userInfo['id'], $this->param['password'])) { return resultArray(['error' => '密码错误!']); } $initializeLogic->update($this->param['type']); return resultArray(['data' => $initializeLogic->log]); } /** * 验证密码 * * @param InitializeLogic $initializeLogic * @return \think\response\Json * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function verification(InitializeLogic $initializeLogic) { if (empty($this->param['password'])) return resultArray(['error' => '参数错误!']); if (!$initializeLogic->verification($this->userInfo['id'], $this->param['password'])) return resultArray(['error' => '密码错误!']); return resultArray(['data' => '密码正确!']); } }