Ver Fonte

总后台的权限管理

shish há 6 anos atrás
pai
commit
3077de78f8
1 ficheiros alterados com 13 adições e 7 exclusões
  1. 13 7
      app/platform/controllers/AuthController.php

+ 13 - 7
app/platform/controllers/AuthController.php

@@ -10,7 +10,7 @@ class AuthController extends BaseController
 {
 	
 	public $enableCsrfValidation = false;
-
+	
 	//获取权限树 shish 2019.11.24
 	public function actionTree()
 	{
@@ -19,7 +19,7 @@ class AuthController extends BaseController
 		$tree = AuthService::getTree($endId);
 		util::success($tree);
 	}
-
+	
 	//添加权限 shish 2019.11.24
 	public function actionAdd()
 	{
@@ -33,17 +33,23 @@ class AuthController extends BaseController
 		AuthService::add($_POST);
 		util::ok();
 	}
-
+	
+	//修改 shish 2019.11.24
 	public function actionModify()
 	{
 		$post = Yii::$app->request->post();
-		$endId = isset($post['endId']) ? $post['endId'] : 1;
+		$id = isset($post['id']) ? $post['id'] : 0;
+		$auth = AuthService::getById($id);
+		if (empty($auth)) {
+			util::fail('没有找到权限');
+		}
+		$endId = $auth['endId'];
+		$nameList = AuthService::getNameList($endId);
 		$authName = isset($post['authName']) ? $post['authName'] : '';
-		$list = AuthService::getNameList($endId);
-		if (in_array($authName, $list)) {
+		if ($authName != $auth['authName'] && in_array($authName, $nameList)) {
 			util::fail('名称已经存在');
 		}
-		AuthService::add($_POST);
+		AuthService::updateById($id, $_POST);
 		util::ok();
 	}