From 732dd19efd7049d658b5c5c7f07877d20cfcaea4 Mon Sep 17 00:00:00 2001
From: Amor <amor@amorpc.com>
Date: Mon, 20 Nov 2017 16:04:50 +0800
Subject: [PATCH] 添加主键,修复无法更新fa_auth_rule 问题

---
 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 ecf1ebc..12e278b
--- 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;
+    }
+
 }
--
libgit2 0.24.0