[''], 'allow'=>['index'] ]; Hook::listen('check_auth',$action); $request = Request::instance(); $a = strtolower($request->action()); if (!in_array($a, $action['permission'])) { parent::_initialize(); } $m = $this->m; $c = $this->c; $a = $this->a; } public function index() { $ruleModel = model('Rule'); $param = $this->param; $data = $ruleModel->getDataList($param); return resultArray(['data' => $data]); } /** * 新建规则 * @param * @return */ public function save() { $ruleModel = model('Rule'); $param = $this->param; $data = $ruleModel->createData($param); if (!$data) { return resultArray(['error' => $ruleModel->getError()]); } return resultArray(['data' => '添加成功']); } /** * 编辑规则 * @param * @return */ public function update() { $ruleModel = model('Rule'); $param = $this->param; $data = $ruleModel->updateDataById($param, $param['id']); if (!$data) { return resultArray(['error' => $ruleModel->getError()]); } return resultArray(['data' => '编辑成功']); } }