Log.php 2.0 KB

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