修改日志列表

This commit is contained in:
JaguarJack 2020-04-28 22:02:50 +08:00
parent 50bcb7e289
commit 08aee72ab9
5 changed files with 63 additions and 16 deletions

View File

@ -1 +1,20 @@
<?php
namespace catchAdmin\system\controller;
use catcher\base\CatchController;
use catcher\CatchResponse;
use catcher\generate\Generator;
use think\Request;
class Generate extends CatchController
{
public function save(Request $request, Generator $generator)
{
return CatchResponse::success($generator->done($request->param()));
}
public function preview()
{
}
}

View File

@ -4,16 +4,32 @@ namespace catchAdmin\system\controller;
use catcher\base\CatchController;
use catcher\CatchResponse;
use think\facade\Db;
use catchAdmin\system\model\LoginLog as Log;
class LoginLog extends CatchController
{
public function list()
/**
*
* @time 2020年04月28日
* @param Log $log
* @throws \think\db\exception\DbException
* @return \think\response\Json
*/
public function list(Log $log)
{
return CatchResponse::paginate(Db::name('login_log')->paginate(request()->param('limit') ?? 10));
return CatchResponse::paginate($log->paginate());
}
public function empty()
/**
* 清空
*
* @time 2020年04月28日
* @param Log $log
* @throws \Exception
* @return \think\response\Json
*/
public function empty(Log $log)
{
return CatchResponse::success(Db::name('login_log')->delete(true), '清空成功');
return CatchResponse::success($log->where('id', '>', 0)->delete(), '清空成功');
}
}

View File

@ -4,22 +4,31 @@ namespace catchAdmin\system\controller;
use catcher\base\CatchController;
use catcher\CatchResponse;
use think\facade\Db;
use catchAdmin\system\model\OperateLog as Log;
class OperateLog extends CatchController
{
public function list()
/**
*
* @time 2020年04月28日
* @param Log $log
* @throws \think\db\exception\DbException
* @return \think\response\Json
*/
public function list(Log $log)
{
return CatchResponse::paginate(
Db::name('operate_log')
->field(['operate_log.*', 'users.username as creator'])
->join('users','users.id = operate_log.creator_id')
->order('id', 'desc')
->paginate(request()->param('limit') ?? 10)
);
return CatchResponse::paginate($log->getList());
}
public function empty()
/**
*
* @time 2020年04月28日
* @param Log $log
* @throws \Exception
* @return \think\response\Json
*/
public function empty(Log $log)
{
return CatchResponse::success(Db::name('operate_log')->delete(true), '清空成功');
return CatchResponse::success($log->where('id', '>', 0)->delete(), '清空成功');
}
}

View File

@ -1,7 +1,6 @@
<?php
namespace catchAdmin\system\model;
use catcher\base\CatchModel;
use catcher\traits\db\BaseOptionsTrait;
class LoginLog extends \think\Model

View File

@ -22,3 +22,7 @@ $router->resource('attachments', '\catchAdmin\system\controller\Attachments');
// 配置
$router->get('config/parent', '\catchAdmin\system\controller\Config@parent');
$router->resource('config', '\catchAdmin\system\controller\Config');
// 代码生成
$router->post('generate', '\catchAdmin\system\controller\Generate@save');
$router->post('generate/preview', '\catchAdmin\system\controller\Generate@preview'); // 预览