更新若干代码
This commit is contained in:
@@ -6,6 +6,8 @@ use think\facade\Db;
|
||||
use think\facade\Request;
|
||||
use think\facade\View;
|
||||
use think\facade\Cookie;
|
||||
use app\admin\model\Log\LogsLogin;
|
||||
use app\admin\model\Log\LogsOperation;
|
||||
|
||||
class Log extends Base
|
||||
{
|
||||
@@ -23,27 +25,25 @@ class Log extends Base
|
||||
$startTime = input('post.start_time');
|
||||
$endTime = input('post.end_time');
|
||||
|
||||
$query = Db::name('yz_logs_login');
|
||||
|
||||
// 搜索条件
|
||||
if ($username) {
|
||||
$query = $query->where('username', 'like', "%{$username}%");
|
||||
$query = LogsLogin::where('username', 'like', "%{$username}%");
|
||||
}
|
||||
if ($ip) {
|
||||
$query = $query->where('ip_address', 'like', "%{$ip}%");
|
||||
$query = LogsLogin::where('ip_address', 'like', "%{$ip}%");
|
||||
}
|
||||
if ($status !== '') {
|
||||
$query = $query->where('login_status', $status);
|
||||
$query = LogsLogin::where('login_status', $status);
|
||||
}
|
||||
if ($startTime) {
|
||||
$query = $query->where('login_time', '>=', $startTime);
|
||||
$query = LogsLogin::where('login_time', '>=', $startTime);
|
||||
}
|
||||
if ($endTime) {
|
||||
$query = $query->where('login_time', '<=', $endTime);
|
||||
$query = LogsLogin::where('login_time', '<=', $endTime);
|
||||
}
|
||||
|
||||
$count = $query->count();
|
||||
$list = $query->order('id desc')
|
||||
$count = LogsLogin::count();
|
||||
$list = LogsLogin::order('id desc')
|
||||
->page($page, $limit)
|
||||
->select();
|
||||
|
||||
@@ -67,8 +67,6 @@ class Log extends Base
|
||||
$page = $params['page'] ?? 1;
|
||||
$limit = $params['limit'] ?? 10;
|
||||
|
||||
$query = Db::name('yz_logs_operation');
|
||||
|
||||
// 构建搜索条件
|
||||
$searchFields = [
|
||||
'username' => ['field' => 'username', 'type' => 'like'],
|
||||
@@ -79,6 +77,8 @@ class Log extends Base
|
||||
'end_time' => ['field' => 'operation_time', 'type' => '<=']
|
||||
];
|
||||
|
||||
$query = LogsOperation::where('1=1');
|
||||
|
||||
foreach ($searchFields as $param => $config) {
|
||||
if (!empty($params[$param])) {
|
||||
$value = $params[$param];
|
||||
@@ -89,8 +89,9 @@ class Log extends Base
|
||||
}
|
||||
}
|
||||
|
||||
$count = $query->count();
|
||||
$list = $query->order('id desc')
|
||||
$count = LogsOperation::where('1=1')->count();
|
||||
$list = LogsOperation::where('1=1')
|
||||
->order('id desc')
|
||||
->page($page, $limit)
|
||||
->select();
|
||||
|
||||
@@ -129,7 +130,7 @@ class Log extends Base
|
||||
'execution_time' => 0
|
||||
];
|
||||
|
||||
Db::name('yz_logs_operation')->insert($data);
|
||||
LogsOperation::insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,8 +143,7 @@ class Log extends Base
|
||||
return json(['code' => 1, 'msg' => '参数错误']);
|
||||
}
|
||||
|
||||
$info = Db::name('yz_logs_operation')
|
||||
->where('id', $id)
|
||||
$info = LogsOperation::where('id', $id)
|
||||
->find();
|
||||
|
||||
if (!$info) {
|
||||
|
||||
Reference in New Issue
Block a user