Log.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\admin\controller\system;
  3. use app\common\model\SystemLog;
  4. use app\common\controller\AdminController;
  5. use EasyAdmin\annotation\ControllerAnnotation;
  6. use EasyAdmin\annotation\NodeAnotation;
  7. use think\App;
  8. /**
  9. * @ControllerAnnotation(title="操作日志管理")
  10. * Class Auth
  11. * @package app\admin\controller\system
  12. */
  13. class Log extends AdminController
  14. {
  15. public function __construct(App $app)
  16. {
  17. parent::__construct($app);
  18. $this->model = new SystemLog();
  19. }
  20. /**
  21. * @NodeAnotation(title="列表")
  22. */
  23. public function index()
  24. {
  25. if ($this->request->isAjax()) {
  26. if (input('selectFields')) {
  27. return $this->selectList();
  28. }
  29. [$page, $limit, $where, $excludeFields] = $this->buildTableParames(['month']);
  30. $month = (isset($excludeFields['month']) && !empty($excludeFields['month']))
  31. ? date('Ym',strtotime($excludeFields['month']))
  32. : date('Ym');
  33. // todo TP6框架有一个BUG,非模型名与表名不对应时(name属性自定义),withJoin生成的sql有问题
  34. $count = $this->model
  35. ->setMonth($month)
  36. ->with('admin')
  37. ->where($where)
  38. ->select();
  39. $list = $this->model
  40. ->setMonth($month)
  41. ->with('admin')
  42. ->where($where)
  43. ->page($page, $limit)
  44. ->order($this->sort)
  45. ->select();
  46. $data = [
  47. 'code' => 0,
  48. 'msg' => '',
  49. 'count' => $count,
  50. 'data' => $list,
  51. ];
  52. return json($data);
  53. }
  54. return $this->fetch();
  55. }
  56. }