diff --git a/application/admin/controller/Base.php b/application/admin/controller/Base.php index 226710f..1fa2045 100644 --- a/application/admin/controller/Base.php +++ b/application/admin/controller/Base.php @@ -9,7 +9,7 @@ abstract class Base extends Controller { use ControllerTrait; - protected $limit = 20; + protected $limit = 10; protected $page = 1; @@ -32,7 +32,6 @@ abstract class Base extends Controller unset($params[$key]); } } - $this->start = $this->start(); } diff --git a/application/admin/controller/Log.php b/application/admin/controller/Log.php new file mode 100644 index 0000000..6833fd7 --- /dev/null +++ b/application/admin/controller/Log.php @@ -0,0 +1,30 @@ +request->param(); + $this->checkParams($params); + + $this->list = $logRecordModel->getAll($params, $this->limit); + + return $this->fetch(); + } +} \ No newline at end of file diff --git a/application/model/BaseModel.php b/application/model/BaseModel.php index 41415b5..d3bf2d7 100644 --- a/application/model/BaseModel.php +++ b/application/model/BaseModel.php @@ -11,7 +11,7 @@ use think\Model; class BaseModel extends Model { - const LIMIT = 20; + const LIMIT = 10; /** * Store Data diff --git a/application/model/LogRecordModel.php b/application/model/LogRecordModel.php index ece53c6..d26dfb7 100644 --- a/application/model/LogRecordModel.php +++ b/application/model/LogRecordModel.php @@ -7,8 +7,30 @@ */ namespace app\model; +use http\Env\Request; + class LogRecordModel extends BaseModel { protected $name = 'option_log'; + /** + * 日志列表 + * + * @time at 2019年01月18日 + * @param array $params + * @param int $limit + * @return mixed + */ + public function getAll(array $params, $limit = self::LIMIT) + { + if (!count($params)) { + return $this->paginate($limit, false, ['query' => request()->param()]); + } + + if (isset($params['name'])) { + $list = $this->whereLike('user_name', '%'.$params['name'].'%'); + } + + return $list->paginate($limit, false, ['query' => request()->param()]); + } } \ No newline at end of file diff --git a/views/admin/log/index.html b/views/admin/log/index.html new file mode 100644 index 0000000..35518ed --- /dev/null +++ b/views/admin/log/index.html @@ -0,0 +1,44 @@ +{extend name="public:base" /} +{block name="menu"}日志列表{/block} +{block name="search"} +
+ + +
+{:searchButton()} +{/block} +{block name="table-head"} + + ID + 用户名 + 操作 + 模块 + 控制器 + 方法 + 请求类型 + 时间 + +{/block} +{block name="table-body"} +{if condition="!$list->count()"} + + 没有数据 + +{else/} +{foreach $list as $key => $log} + + {$start + $key} + {$log->user_name} + {$log->option} + {$log->module} + {$log->controller} + {$log->action} + {$log->method} + {$log->created_at} + +{/foreach} +{/if} +{/block} +{block name="paginate"} +{$list->render()|raw} +{/block}