Merge pull request #8 from tlerbao/master

登录日志新增数据搜索功能,修改路由Path单词用反了的问题
This commit is contained in:
JaguarJack 2020-07-18 20:51:11 +08:00 committed by GitHub
commit db18e71906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 607 additions and 576 deletions

View File

@ -1,4 +1,5 @@
<?php
namespace catchAdmin\system\controller;
use catcher\base\CatchController;
@ -17,7 +18,7 @@ class LoginLog extends CatchController
*/
public function list(Log $log)
{
return CatchResponse::paginate($log->paginate());
return CatchResponse::paginate($log->getList());
}
/**

View File

@ -381,7 +381,7 @@ class SystemPermissionSeed extends Seeder
'permission_name' => '登陆日志',
'parent_id' => 37,
'level' => '37',
'route' => '/system/log/operate',
'route' => '/system/log/login',
'icon' => 'export',
'module' => 'system',
'creator_id' => 1,
@ -453,7 +453,7 @@ class SystemPermissionSeed extends Seeder
'permission_name' => '操作日志',
'parent_id' => 37,
'level' => '37',
'route' => '/system/log/login',
'route' => '/system/log/operate',
'icon' => 'profile',
'module' => 'system',
'creator_id' => 1,

View File

@ -1,11 +1,13 @@
<?php
namespace catchAdmin\system\model;
use catcher\traits\db\BaseOptionsTrait;
use catchAdmin\system\model\search\LoginLogSearch;
class LoginLog extends \think\Model
{
use BaseOptionsTrait;
use BaseOptionsTrait, LoginLogSearch;
protected $name = 'login_log';
@ -18,4 +20,11 @@ class LoginLog extends \think\Model
'login_at', // 登录时间
'status', // 1 成功 2 失败
];
public function getList()
{
return $this->catchSearch()
->order('id', 'desc')
->paginate();
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace catchAdmin\system\model\search;
trait LoginLogSearch
{
public function searchLoginNameAttr($query, $value, $data)
{
return $query->whereLike('login_name', $value);
}
public function searchLoginIpAttr($query, $value, $data)
{
return $query->whereLike('login_ip', $value);
}
public function searchLoginAtAttr($query, $value, $data)
{
return $query->whereTime('login_at', 'between', $value);
}
}