Base.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\index\controller;
  3. use app\index\model\ActionLogModel;
  4. use think\Controller;
  5. class Base extends Controller{
  6. const redis_host = 'lredis';
  7. const redis_port = 6379;
  8. const queue_name = 'net_access_queue';
  9. private $no_check = ['order/checkorder' , 'order/recordstore' , 'order/checkfcode' , 'order/recordfetch' , 'cabinet/getcabinetsboxs' , 'cabinet/boxchangestatus'];
  10. public function initialize(){
  11. $control = lcfirst(request()->controller());
  12. $action = lcfirst(request()->action());
  13. if(!in_array($control . '/' . $action , $this->no_check)){
  14. if(empty(session('username')) || empty(session('id'))){
  15. //登录超时
  16. json(json_error_exception('1005'))->send();
  17. }
  18. }
  19. }
  20. protected function action_log(){
  21. $control = lcfirst(request()->controller());
  22. $action = lcfirst(request()->action());
  23. $ActionLogModel = new ActionLogModel();
  24. $params['admin_id'] = session('id');
  25. $params['username'] = session('username');
  26. $params['content'] = $control . '/' . $action;
  27. $params['ip'] = request()->ip();
  28. $params['date'] = date("Y-m-d H:i:s");
  29. $ActionLogModel->save($params);
  30. }
  31. }