Log.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace app\controller\admin\login;
  3. use laytp\controller\Backend;
  4. use laytp\library\CommonFun;
  5. use think\facade\Config;
  6. /**
  7. * 后台登录日志
  8. */
  9. class Log extends Backend
  10. {
  11. /**
  12. * admin_login_log模型对象
  13. * @var \app\model\admin\login\Log
  14. */
  15. protected $model;
  16. protected $hasSoftDel = 0;//是否拥有软删除功能
  17. protected $noNeedLogin = []; // 无需登录即可请求的方法
  18. protected $noNeedAuth = ['index', 'info']; // 无需鉴权即可请求的方法
  19. public function _initialize()
  20. {
  21. $this->model = new \app\model\admin\login\Log();
  22. }
  23. //查看和搜索列表
  24. /**
  25. * @throws \think\db\exception\DbException
  26. */
  27. public function index()
  28. {
  29. global $_W;
  30. $where = $this->buildSearchParams();
  31. $where[] = ['uniacid','=',$_W['uniacid']];
  32. $order = $this->buildOrder();
  33. $data = $this->model->where($where)->order($order)->with(['adminUser']);
  34. $paging = $this->request->param('paging', false);
  35. if ($paging) {
  36. $limit = $this->request->param('limit', Config::get('paginate.limit'));
  37. $data = $data->paginate($limit)->toArray();
  38. $data['data'] = $this->getSelectedData($data['data']);
  39. } else {
  40. $data = $data->select()->toArray();
  41. }
  42. return $this->success('数据获取成功', $data);
  43. }
  44. //查看详情
  45. public function info()
  46. {
  47. $id = $this->request->param('id');
  48. $info = $this->model->find($id);
  49. return $this->success('获取成功', $info);
  50. }
  51. //回收站
  52. public function recycle()
  53. {
  54. global $_W;
  55. $where = $this->buildSearchParams();
  56. $where[] = ['uniacid','=',$_W['uniacid']];
  57. $order = $this->buildOrder();
  58. $limit = $this->request->param('limit', Config::get('paginate.limit'));
  59. $data = $this->model->onlyTrashed()
  60. ->where($where)
  61. ->with(['adminUser'])
  62. ->order($order)->paginate($limit)->toArray();
  63. return $this->success('回收站数据获取成功', $data);
  64. }
  65. }