|
|
@@ -0,0 +1,123 @@
|
|
|
+<?php
|
|
|
+declare (strict_types = 1);
|
|
|
+
|
|
|
+namespace app\admin\controller;
|
|
|
+
|
|
|
+use app\common\controller\Backend;
|
|
|
+use app\admin\traits\Actions;
|
|
|
+use think\annotation\route\Group;
|
|
|
+use think\annotation\route\Route;
|
|
|
+use app\common\model\ScanLog as ScanLogModel;
|
|
|
+
|
|
|
+#[Group("scan_log")]
|
|
|
+class ScanLog extends Backend
|
|
|
+{
|
|
|
+ use Actions{
|
|
|
+ index as private _index;
|
|
|
+ add as private _add;
|
|
|
+ edit as private _edit;
|
|
|
+ del as private _del;
|
|
|
+ multi as private _multi;
|
|
|
+ import as private _import;
|
|
|
+ download as private _download;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function _initialize()
|
|
|
+ {
|
|
|
+ parent::_initialize();
|
|
|
+ $this->model = new ScanLogModel();
|
|
|
+ }
|
|
|
+
|
|
|
+ //查看
|
|
|
+ #[Route("GET,JSON","index")]
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ // return $this->_index();
|
|
|
+ if (false === $this->request->isAjax()) {
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+ if ($this->request->post('selectpage')) {
|
|
|
+ return $this->selectpage();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ [$where, $order, $limit, $with] = $this->buildparams();
|
|
|
+ $list = $this->model->alias('s')
|
|
|
+ ->join("user u", "s.user_id = u.id", "LEFT")
|
|
|
+ // ->join("group_user g", "w.user_id = g.id", "LEFT")
|
|
|
+ ->where($where)
|
|
|
+ ->order($order)
|
|
|
+ ->field(['s.*','u.avatar','u.nickname' => 'manage_nickname'])
|
|
|
+ ->paginate($limit)->each(function ($item, $key) {
|
|
|
+ $item['avatar']= startsWithHttp($item['avatar'])?$item['avatar']:request()->domain().'/' . $item['avatar'];
|
|
|
+ return $item;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $result = ['total' => $list->total(), 'rows' => $list->items()];
|
|
|
+ return json($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加
|
|
|
+ #[Route("GET,POST","add")]
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+ //通过定义postParams来增加或覆盖post提交的表单
|
|
|
+ $this->postParams=[];
|
|
|
+ //通过定义callback回调函数来执行添加后的操作
|
|
|
+ $this->callback=function ($model){};
|
|
|
+ return $this->_add();
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改
|
|
|
+ #[Route("GET,POST","edit")]
|
|
|
+ public function edit()
|
|
|
+ {
|
|
|
+ //通过定义postParams来增加或覆盖post提交的表单
|
|
|
+ $this->postParams=[];
|
|
|
+ //通过定义callback回调函数来执行修改后的操作
|
|
|
+ $this->callback=function ($model){};
|
|
|
+ return $this->_edit();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除
|
|
|
+ #[Route("GET,POST","del")]
|
|
|
+ public function del()
|
|
|
+ {
|
|
|
+ //通过定义callback回调函数来执行删除后的操作
|
|
|
+ $this->callback=function ($ids){};
|
|
|
+ return $this->_del();
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新
|
|
|
+ #[Route("GET,POST","multi")]
|
|
|
+ public function multi()
|
|
|
+ {
|
|
|
+ //通过定义callback回调函数来执行更新后的操作
|
|
|
+ $this->callback=function ($ids,$field,$value){};
|
|
|
+ return $this->_multi();
|
|
|
+ }
|
|
|
+
|
|
|
+ //导入
|
|
|
+ #[Route("GET,POST","import")]
|
|
|
+ public function import()
|
|
|
+ {
|
|
|
+ //通过定义callback回调函数来处理导入的数据
|
|
|
+ $this->callback=function ($inserData){
|
|
|
+ return $inserData;
|
|
|
+ };
|
|
|
+ return $this->_import();
|
|
|
+ }
|
|
|
+
|
|
|
+ //下载
|
|
|
+ #[Route("GET,POST","download")]
|
|
|
+ public function download()
|
|
|
+ {
|
|
|
+ //通过定义callback回调函数来处理下载的数据
|
|
|
+ $this->callback=function ($downloadData){
|
|
|
+ return $downloadData;
|
|
|
+ };
|
|
|
+ return $this->_download();
|
|
|
+ }
|
|
|
+}
|