From 732dd19efd7049d658b5c5c7f07877d20cfcaea4 Mon Sep 17 00:00:00 2001 From: Amor Date: Mon, 20 Nov 2017 16:04:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=BB=E9=94=AE=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E6=9B=B4=E6=96=B0fa=5Fauth?= =?UTF-8?q?=5Frule=20=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Menu.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) mode change 100644 => 100755 application/admin/command/Menu.php diff --git a/application/admin/command/Menu.php b/application/admin/command/Menu.php old mode 100644 new mode 100755 index ecf1ebc6..12e278bb --- a/application/admin/command/Menu.php +++ b/application/admin/command/Menu.php @@ -264,10 +264,25 @@ class Menu extends Command $comment = preg_replace(array('/^\/\*\*(.*)[\n\r\t]/u', '/[\s]+\*\//u', '/\*\s@(.*)/u', '/[\s|\*]+/u'), '', $comment); $title = $comment ? $comment : ucfirst($n->name); - - $ruleArr[] = array('pid' => $pid, 'name' => $name . "/" . strtolower($n->name), 'icon' => 'fa fa-circle-o', 'title' => $title, 'ismenu' => 0, 'status' => 'normal'); + + //获取主键,作为AuthRule更新依据 + $id = $this->getAuthRulePK($name . "/" . strtolower($n->name)); + + $ruleArr[] = array('id' => $id, 'pid' => $pid, 'name' => $name . "/" . strtolower($n->name), 'icon' => 'fa fa-circle-o', 'title' => $title, 'ismenu' => 0, 'status' => 'normal'); } $this->model->saveAll($ruleArr); } + //获取主键 + protected function getAuthRulePK($name) { + if (!empty($name)) + { + $PK = $this->model + ->where('name', $name) + ->value('id'); + + } + return $PK; + } + }