123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace app\index\controller;
- use think\Controller;
- use app\index\model\RoleModel;
- class Base extends Controller{
- private $noCheck = ['cabinet/check_fcode' , 'cabinet/record_store' , 'cabinet/record_fetch' , 'cabinet/add_cabinet' , 'order/order_bind_code'];
- public function initialize(){
- $control = lcfirst(request()->controller());
- $action = lcfirst(request()->action());
- $checkUrl = $control . '/' . $action;
- // if(!in_array($checkUrl , $this->noCheck)){
- // if(empty(session('username')) || empty(session('id'))){
- // //登录超时
- // json(json_error_exception('1005'))->send();
- // }
- // $this->cacheCheck();
- // // 检测权限
- // if(empty(authCheck($checkUrl))){
- // json(json_error_exception('1000'))->send();
- // }
- // }
- }
- private function cacheCheck()
- {
- $action = cache(session('role_id'));
- if(is_null($action) || empty($action)){
- // 获取该管理员的角色信息
- $roleModel = new RoleModel();
- $info = $roleModel->getRoleInfo(session('role_id'));
- cache(session('role_id'), $info['action']);
- }
- }
- protected function removeRoleCache()
- {
- $roleModel = new RoleModel();
- $roleList = $roleModel->getRole();
- foreach ($roleList as $value) {
- cache($value['id'], null);
- }
- }
- }
|