ScanLog.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\controller;
  4. use app\common\controller\Backend;
  5. use app\admin\traits\Actions;
  6. use think\annotation\route\Group;
  7. use think\annotation\route\Route;
  8. use app\common\model\ScanLog as ScanLogModel;
  9. #[Group("scan_log")]
  10. class ScanLog extends Backend
  11. {
  12. use Actions{
  13. index as private _index;
  14. add as private _add;
  15. edit as private _edit;
  16. del as private _del;
  17. multi as private _multi;
  18. import as private _import;
  19. download as private _download;
  20. }
  21. protected function _initialize()
  22. {
  23. parent::_initialize();
  24. $this->model = new ScanLogModel();
  25. }
  26. //查看
  27. #[Route("GET,JSON","index")]
  28. public function index()
  29. {
  30. // return $this->_index();
  31. if (false === $this->request->isAjax()) {
  32. return $this->fetch();
  33. }
  34. if ($this->request->post('selectpage')) {
  35. return $this->selectpage();
  36. }
  37. [$where, $order, $limit, $with] = $this->buildparams();
  38. $list = $this->model->alias('s')
  39. ->join("user u", "s.user_id = u.id", "LEFT")
  40. // ->join("group_user g", "w.user_id = g.id", "LEFT")
  41. ->where($where)
  42. ->order($order)
  43. ->field(['s.*','u.avatar','u.nickname' => 'manage_nickname'])
  44. ->paginate($limit)->each(function ($item, $key) {
  45. $item['avatar']= startsWithHttp($item['avatar'])?$item['avatar']:request()->domain().'/' . $item['avatar'];
  46. return $item;
  47. });
  48. $result = ['total' => $list->total(), 'rows' => $list->items()];
  49. return json($result);
  50. }
  51. //添加
  52. #[Route("GET,POST","add")]
  53. public function add()
  54. {
  55. //通过定义postParams来增加或覆盖post提交的表单
  56. $this->postParams=[];
  57. //通过定义callback回调函数来执行添加后的操作
  58. $this->callback=function ($model){};
  59. return $this->_add();
  60. }
  61. //修改
  62. #[Route("GET,POST","edit")]
  63. public function edit()
  64. {
  65. //通过定义postParams来增加或覆盖post提交的表单
  66. $this->postParams=[];
  67. //通过定义callback回调函数来执行修改后的操作
  68. $this->callback=function ($model){};
  69. return $this->_edit();
  70. }
  71. //删除
  72. #[Route("GET,POST","del")]
  73. public function del()
  74. {
  75. //通过定义callback回调函数来执行删除后的操作
  76. $this->callback=function ($ids){};
  77. return $this->_del();
  78. }
  79. //更新
  80. #[Route("GET,POST","multi")]
  81. public function multi()
  82. {
  83. //通过定义callback回调函数来执行更新后的操作
  84. $this->callback=function ($ids,$field,$value){};
  85. return $this->_multi();
  86. }
  87. //导入
  88. #[Route("GET,POST","import")]
  89. public function import()
  90. {
  91. //通过定义callback回调函数来处理导入的数据
  92. $this->callback=function ($inserData){
  93. return $inserData;
  94. };
  95. return $this->_import();
  96. }
  97. //下载
  98. #[Route("GET,POST","download")]
  99. public function download()
  100. {
  101. //通过定义callback回调函数来处理下载的数据
  102. $this->callback=function ($downloadData){
  103. return $downloadData;
  104. };
  105. return $this->_download();
  106. }
  107. }