From 732dd19efd7049d658b5c5c7f07877d20cfcaea4 Mon Sep 17 00:00:00 2001 From: Amor Date: Mon, 20 Nov 2017 16:04:50 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=BB=E9=94=AE?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E6=9B=B4=E6=96=B0?= =?UTF-8?q?fa=5Fauth=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 ecf1ebc6b..12e278bb7 --- 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; + } + } -- Gitee From 8e29c5f9c7a91f5a42b3d86a31a1f21c9fbcd5c5 Mon Sep 17 00:00:00 2001 From: Amor Date: Mon, 20 Nov 2017 16:20:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=20Menu.php=20getAuthRule?= =?UTF-8?q?PK=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Menu.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application/admin/command/Menu.php b/application/admin/command/Menu.php index 12e278bb7..8d218d385 100755 --- a/application/admin/command/Menu.php +++ b/application/admin/command/Menu.php @@ -277,12 +277,11 @@ class Menu extends Command protected function getAuthRulePK($name) { if (!empty($name)) { - $PK = $this->model + return $this->model ->where('name', $name) ->value('id'); } - return $PK; } } -- Gitee