Base.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\index\controller;
  3. use think\Controller;
  4. use app\index\model\RoleModel;
  5. class Base extends Controller{
  6. private $noCheck = ['cabinet/check_fcode' , 'cabinet/record_store' , 'cabinet/record_fetch' , 'cabinet/add_cabinet' , 'order/order_bind_code'];
  7. const redis_host = 'lredis';
  8. const redis_port = 6379;
  9. const queue_name = 'net_access_queue';
  10. public function initialize(){
  11. $control = lcfirst(request()->controller());
  12. $action = lcfirst(request()->action());
  13. $checkUrl = $control . '/' . $action;
  14. // if(!in_array($checkUrl , $this->noCheck)){
  15. // if(empty(session('username')) || empty(session('id'))){
  16. // //登录超时
  17. // json(json_error_exception('1005'))->send();
  18. // }
  19. // $this->cacheCheck();
  20. // // 检测权限
  21. // if(empty(authCheck($checkUrl))){
  22. // json(json_error_exception('1000'))->send();
  23. // }
  24. // }
  25. }
  26. private function cacheCheck()
  27. {
  28. $action = cache(session('role_id'));
  29. if(is_null($action) || empty($action)){
  30. // 获取该管理员的角色信息
  31. $roleModel = new RoleModel();
  32. $info = $roleModel->getRoleInfo(session('role_id'));
  33. cache(session('role_id'), $info['action']);
  34. }
  35. }
  36. protected function removeRoleCache()
  37. {
  38. $roleModel = new RoleModel();
  39. $roleList = $roleModel->getRole();
  40. foreach ($roleList as $value) {
  41. cache($value['id'], null);
  42. }
  43. }
  44. }