log 展示

This commit is contained in:
JaguarJack 2019-01-18 10:00:08 +08:00
parent 3d0cbac664
commit 6f8ee42207
5 changed files with 98 additions and 3 deletions

View File

@ -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();
}

View File

@ -0,0 +1,30 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/1/18
* Time: 9:01
*/
namespace app\admin\controller;
use app\model\LogRecordModel;
class Log extends Base
{
/**
* 日志列表
*
* @time at 2019年01月18日
* @param LogRecordModel $logRecordModel
* @return mixed
*/
public function index(LogRecordModel $logRecordModel)
{
$params = $this->request->param();
$this->checkParams($params);
$this->list = $logRecordModel->getAll($params, $this->limit);
return $this->fetch();
}
}

View File

@ -11,7 +11,7 @@ use think\Model;
class BaseModel extends Model
{
const LIMIT = 20;
const LIMIT = 10;
/**
* Store Data

View File

@ -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()]);
}
}

View File

@ -0,0 +1,44 @@
{extend name="public:base" /}
{block name="menu"}日志列表{/block}
{block name="search"}
<div class="form-group">
<label for="name" class="sr-only">用户名</label>
<input type="text" name="name" placeholder="请输入用户名" id="name" class="form-control" value="{$Request.param.name}">
</div>
{:searchButton()}
{/block}
{block name="table-head"}
<tr>
<th>ID</th>
<th>用户名</th>
<th>操作</th>
<th>模块</th>
<th>控制器</th>
<th>方法</th>
<th>请求类型</th>
<th>时间</th>
</tr>
{/block}
{block name="table-body"}
{if condition="!$list->count()"}
<tr>
<td colspan="7" class="text-center">没有数据</td>
</tr>
{else/}
{foreach $list as $key => $log}
<tr>
<td>{$start + $key}</td>
<td>{$log->user_name}</td>
<td>{$log->option}</td>
<td>{$log->module}</td>
<td>{$log->controller}</td>
<td>{$log->action}</td>
<td>{$log->method}</td>
<td>{$log->created_at}</td>
</tr>
{/foreach}
{/if}
{/block}
{block name="paginate"}
{$list->render()|raw}
{/block}