Browse Source

更新权限管理模块

邹景立 8 years ago
parent
commit
9825efee7c
2 changed files with 66 additions and 0 deletions
  1. 62 0
      application/admin/controller/Auth.php
  2. 4 0
      application/admin/view/auth.index.html

+ 62 - 0
application/admin/controller/Auth.php

@@ -15,6 +15,7 @@
 namespace app\admin\controller;
 
 use controller\BasicAdmin;
+use library\Data;
 
 /**
  * 系统权限管理控制器
@@ -25,11 +26,72 @@ use controller\BasicAdmin;
  */
 class Auth extends BasicAdmin {
 
+    /**
+     * 默认数据模型
+     * @var string
+     */
     protected $table = 'SystemAuth';
 
+    /**
+     * 权限列表
+     */
     public function index() {
         $this->title = '系统权限管理';
         parent::_list($this->table);
     }
 
+    /**
+     * 权限授权
+     */
+    public function apply() {
+        return $this->_form($this->table, 'apply');
+    }
+
+    /**
+     * 权限添加
+     */
+    public function add() {
+        return $this->_form($this->table, 'form');
+    }
+
+    /**
+     * 权限编辑
+     */
+    public function edit() {
+        return $this->add();
+    }
+
+    /**
+     * 权限禁用
+     */
+    public function forbid() {
+        if (Data::update($this->table)) {
+            $this->success("权限禁用成功!", '');
+        } else {
+            $this->error("权限禁用失败,请稍候再试!");
+        }
+    }
+
+    /**
+     * 权限恢复
+     */
+    public function resume() {
+        if (Data::update($this->table)) {
+            $this->success("权限启用成功!", '');
+        } else {
+            $this->error("权限启用失败,请稍候再试!");
+        }
+    }
+
+    /**
+     * 权限删除
+     */
+    public function del() {
+        if (Data::update($this->table)) {
+            $this->success("权限删除成功!", '');
+        } else {
+            $this->error("权限删除失败,请稍候再试!");
+        }
+    }
+
 }

+ 4 - 0
application/admin/view/auth.index.html

@@ -47,6 +47,10 @@
                     <span class="text-explode">|</span>
                     <a data-modal='{:url("$classuri/edit")}?id={$vo.id}' href="javascript:void(0)">编辑</a>
                     {/if}
+                    {if auth("$classuri/apply")}
+                    <span class="text-explode">|</span>
+                    <a data-modal='{:url("$classuri/apple")}?id={$vo.id}' href="javascript:void(0)">授权</a>
+                    {/if}
                     {if $vo.status eq 1 and auth("$classuri/forbid")}
                     <span class="text-explode">|</span>
                     <a data-update="{$vo.id}" data-field='status' data-value='0'data-action='{:url("$classuri/forbid")}' href="javascript:void(0)">禁用</a>