AdminLog.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\admin\controller\auth;
  3. use Throwable;
  4. use app\common\controller\Backend;
  5. use app\admin\model\AdminLog as AdminLogModel;
  6. class AdminLog extends Backend
  7. {
  8. /**
  9. * @var object
  10. * @phpstan-var AdminLogModel
  11. */
  12. protected object $model;
  13. protected string|array $preExcludeFields = ['create_time', 'admin_id', 'username'];
  14. protected string|array $quickSearchField = ['title'];
  15. public function initialize(): void
  16. {
  17. parent::initialize();
  18. $this->model = new AdminLogModel();
  19. }
  20. /**
  21. * 查看
  22. * @throws Throwable
  23. */
  24. public function index(): void
  25. {
  26. if ($this->request->param('select')) {
  27. $this->select();
  28. }
  29. list($where, $alias, $limit, $order) = $this->queryBuilder();
  30. if (!$this->auth->isSuperAdmin()) {
  31. $where[] = ['admin_id', '=', $this->auth->id];
  32. }
  33. $res = $this->model
  34. ->withJoin($this->withJoinTable, $this->withJoinType)
  35. ->alias($alias)
  36. ->where($where)
  37. ->order($order)
  38. ->paginate($limit);
  39. $this->success('', [
  40. 'list' => $res->items(),
  41. 'total' => $res->total(),
  42. 'remark' => get_route_remark(),
  43. ]);
  44. }
  45. }