Ver Fonte

pc权限,管理员,管理组

lizhen_gitee há 7 meses atrás
pai
commit
fa607df9f6

+ 2 - 2
application/common/controller/Apic.php

@@ -143,12 +143,12 @@ class Apic
                 $this->error(__('Please login first'), null, 401);
             }
             // 判断是否需要验证权限
-            /*if (!$this->auth->match($this->noNeedRight)) {
+            if (!$this->auth->match($this->noNeedRight)) {
                 // 判断控制器和方法判断是否有对应权限
                 if (!$this->auth->check($path)) {
                     $this->error(__('You have no permission'), null, 403);
                 }
-            }*/
+            }
         } else {
             // 如果有传递token才验证是否登录状态
             if ($token) {

+ 6 - 6
application/common/library/Authcompany.php

@@ -2,7 +2,7 @@
 
 namespace app\common\library;
 
-use app\common\model\PcAdmin as User;
+use app\company\model\Admin as User;
 use fast\Tree;
 use fast\Random;
 use think\Config;
@@ -451,7 +451,7 @@ class Authcompany extends \fast\Authpc
             }
         }
         // 取出所有分组
-        $groupList = \app\admin\model\AuthGroup::where($this->isSuperAdmin() ? '1=1' : ['status' => 'normal'])->select();
+        $groupList = \app\company\model\AuthGroup::where($this->isSuperAdmin() ? '1=1' : ['status' => 'normal'])->select();
         $objList = [];
         foreach ($groups as $k => $v) {
             if ($v['rules'] === '*') {
@@ -483,7 +483,7 @@ class Authcompany extends \fast\Authpc
         $childrenAdminIds = [];
         if (!$this->isSuperAdmin()) {
             $groupIds = $this->getChildrenGroupIds(false);
-            $authGroupList = \app\admin\model\AuthGroupAccess::field('uid,group_id')
+            $authGroupList = \app\company\model\AuthGroupAccess::field('uid,group_id')
                 ->where('group_id', 'in', $groupIds)
                 ->select();
             foreach ($authGroupList as $k => $v) {
@@ -491,7 +491,7 @@ class Authcompany extends \fast\Authpc
             }
         } else {
             //超级管理员拥有所有人的权限
-            $childrenAdminIds = Admin::column('id');
+            $childrenAdminIds = User::column('id');
         }
         if ($withself) {
             if (!in_array($this->id, $childrenAdminIds)) {
@@ -617,12 +617,12 @@ class Authcompany extends \fast\Authpc
         $selected = $referer = [];
         $refererUrl = Session::get('referer');
         // 必须将结果集转换为数组
-        $ruleList = collection(\app\admin\model\AuthRule::where('status', 'normal')
+        $ruleList = collection(\app\admin\model\PcAuthRule::where('status', 'normal')
             ->where('ismenu', 1)
             ->order('weigh', 'desc')
             ->cache("__menu__")
             ->select())->toArray();
-        $indexRuleList = \app\admin\model\AuthRule::where('status', 'normal')
+        $indexRuleList = \app\admin\model\PcAuthRule::where('status', 'normal')
             ->where('ismenu', 0)
             ->where('name', 'like', '%/index')
             ->column('name,pid');

+ 13 - 21
application/company/controller/auth/Admin.php

@@ -59,8 +59,8 @@ class Admin extends Apic
             $groupdata = $result;
         }
 
-        $this->view->assign('groupdata', $groupdata);
-        $this->assignconfig("admin", ['id' => $this->auth->id]);
+        /*$this->view->assign('groupdata', $groupdata);
+        $this->assignconfig("admin", ['id' => $this->auth->id]);*/
     }
 
     /**
@@ -68,13 +68,7 @@ class Admin extends Apic
      */
     public function index()
     {
-        //设置过滤方法
-        $this->request->filter(['strip_tags', 'trim']);
-        if ($this->request->isAjax()) {
-            //如果发送的来源是Selectpage,则转发到Selectpage
-            if ($this->request->request('keyField')) {
-                return $this->selectpage();
-            }
+
             $childrenGroupIds = $this->childrenGroupIds;
             $groupName = AuthGroup::where('id', 'in', $childrenGroupIds)
                 ->column('id,name');
@@ -92,26 +86,25 @@ class Admin extends Apic
             foreach ($groups as $m => $n) {
                 $adminGroupName[$this->auth->id][$n['id']] = $n['name'];
             }
-            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
-            $list = $this->model
-                ->where($where)
+            $list = Db::name('pc_admin')
+                ->where('company_id',$this->auth->company_id)
                 ->where('id', 'in', $this->childrenAdminIds)
                 ->field(['password', 'salt', 'token'], true)
-                ->order($sort, $order)
-                ->paginate($limit);
+                ->order('id', 'asc')
+                ->autopage()
+                ->select();
 
             foreach ($list as $k => &$v) {
+                $v['avatar'] = localpath_to_netpath($v['avatar']);
                 $groups = isset($adminGroupName[$v['id']]) ? $adminGroupName[$v['id']] : [];
                 $v['groups'] = implode(',', array_keys($groups));
                 $v['groups_text'] = implode(',', array_values($groups));
             }
             unset($v);
-            $result = array("total" => $list->total(), "rows" => $list->items());
 
-            return json($result);
-        }
-        return $this->view->fetch();
+            $this->success(1,$list);
+
     }
 
     /**
@@ -119,7 +112,7 @@ class Admin extends Apic
      */
     public function add()
     {
-        if ($this->request->isPost()) {
+
             $this->token();
             $params = $this->request->post("row/a");
             if ($params) {
@@ -156,8 +149,7 @@ class Admin extends Apic
                 $this->success();
             }
             $this->error(__('Parameter %s can not be empty', ''));
-        }
-        return $this->view->fetch();
+
     }
 
     /**

+ 1 - 10
application/company/model/Admin.php

@@ -15,15 +15,6 @@ class Admin extends Model
     protected $updateTime = 'updatetime';
 
 
-    public static function init()
-    {
-        self::beforeWrite(function ($row) {
-            $changed = $row->getChangedData();
-            //如果修改了用户或或密码则需要重新登录
-            if (isset($changed['username']) || isset($changed['password']) || isset($changed['salt'])) {
-                $row->token = '';
-            }
-        });
-    }
+
 
 }