Przeglądaj źródła

权限修改操作

shish 6 lat temu
rodzic
commit
c67a1da3f6

+ 15 - 4
app/business/controllers/AdminRoleAuthController.php

@@ -3,6 +3,7 @@
 namespace business\controllers;
 
 use biz\admin\services\AdminRoleAuthService;
+use biz\admin\services\AdminRoleService;
 use biz\admin\services\AdminService;
 use common\components\util;
 use Yii;
@@ -13,14 +14,24 @@ class AdminRoleAuthController extends BaseController
     //管理员角色权限 shish 2020.1.23
     public function actionAuth()
     {
-        $adminId = Yii::$app->request->get('adminId', 0);
-        $admin = AdminService::getById($adminId);
-        AdminService::valid($admin, $this->merchantId);
-        $roleId = $admin['roleId'];
+        $roleId = Yii::$app->request->get('roleId', 0);
+        $role = AdminRoleService::getById($roleId);
+        AdminRoleService::valid($role, $this->merchantId);
         $roleAuth = AdminRoleAuthService::getByCondition(['roleId' => $roleId, 'endId' => 1]);
         $auth = isset($roleAuth['auth']) ? $roleAuth['auth'] : '';
         $ids = !empty($auth) ? explode(',', $auth) : [];
         util::success(['ids' => $ids]);
     }
 
+    //权限更新 shish 2020.1.23
+    public function actionUpdate()
+    {
+        $roleId = Yii::$app->request->post('roleId', 0);
+        $authIdList = Yii::$app->request->post('authIdList', ['*']);
+        $auth = AdminRoleAuthService::getByCondition(['roleId' => $roleId, 'endId' => 1]);
+        AdminRoleAuthService::valid($auth, $this->merchantId);
+        AdminRoleAuthService::updateByCondition(['roleId' => $roleId, 'endId' => 1], ['auth' => implode(',', $authIdList)]);
+        util::ok();
+    }
+
 }

+ 19 - 11
biz/admin/services/AdminRoleAuthService.php

@@ -3,20 +3,28 @@
 namespace biz\admin\services;
 
 use biz\base\services\BaseService;
+use common\components\util;
 use Yii;
 
 class AdminRoleAuthService extends BaseService
 {
-	
-	public static $baseFile = '\biz\admin\classes\AdminRoleAuthClass';
-	
-	//角色在业务端的权限 shish 2019.11.25
-	public static function getAuthIdList($roleId, $endId)
-	{
-		$info = self::getByCondition(['roleId' => $roleId, 'endId' => $endId]);
-		$auth = isset($info['auth']) ? $info['auth'] : '';
-		$ids = !empty($auth) ? explode(',', $auth) : [];
-		return $ids;
-	}
+
+    public static $baseFile = '\biz\admin\classes\AdminRoleAuthClass';
+
+    //角色在业务端的权限 shish 2019.11.25
+    public static function getAuthIdList($roleId, $endId)
+    {
+        $info = self::getByCondition(['roleId' => $roleId, 'endId' => $endId]);
+        $auth = isset($info['auth']) ? $info['auth'] : '';
+        $ids = !empty($auth) ? explode(',', $auth) : [];
+        return $ids;
+    }
+
+    public static function valid($auth, $merchantId)
+    {
+        if (isset($auth['merchantId']) == false || $auth['merchantId'] != $merchantId) {
+            util::fail('您没有权限操作');
+        }
+    }
 
 }

+ 1 - 1
console/controllers/UpgradeController.php

@@ -832,7 +832,7 @@ ALTER TABLE `xhMerchantCapital` MODIFY `io` TINYINT NOT NULL DEFAULT 0 COMMENT '
                 }
             }
         }
-        $sql = "ALTER TABLE `xhUserGrowth` MODIFY `relateId` INT NOT NULL DEFAULT 0 COMMENT '关联id';";
+        $sql = "ALTER TABLE `xhUserGrowth` MODIFY `relateId` INT NOT NULL DEFAULT 0 COMMENT '关联id';ALTER TABLE `xhAdminRoleAuth` ADD merchantId INT NOT NULL DEFAULT 0 COMMENT '商家id' AFTER `endId`;";
         Yii::$app->db->createCommand($sql)->execute();