You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.2 KiB
93 lines
2.2 KiB
3 years ago
|
<?php
|
||
3 years ago
|
/*
|
||
|
* @Author: witersen
|
||
|
* @Date: 2022-04-24 23:37:05
|
||
|
* @LastEditors: witersen
|
||
3 years ago
|
* @LastEditTime: 2022-05-06 21:37:57
|
||
3 years ago
|
* @Description: QQ:1801168257
|
||
|
*/
|
||
3 years ago
|
|
||
3 years ago
|
namespace app\service;
|
||
3 years ago
|
|
||
3 years ago
|
class Logs extends Base
|
||
3 years ago
|
{
|
||
3 years ago
|
function __construct()
|
||
|
{
|
||
|
parent::__construct();
|
||
|
}
|
||
|
|
||
3 years ago
|
/**
|
||
|
* 获取日志列表
|
||
|
*/
|
||
3 years ago
|
public function GetLogList()
|
||
3 years ago
|
{
|
||
3 years ago
|
$pageSize = $this->payload['pageSize'];
|
||
|
$currentPage = $this->payload['currentPage'];
|
||
|
$searchKeyword = trim($this->payload['searchKeyword']);
|
||
3 years ago
|
|
||
|
//分页
|
||
|
$begin = $pageSize * ($currentPage - 1);
|
||
|
|
||
|
$list = $this->database->select('logs', [
|
||
|
'log_id',
|
||
|
'log_type_name',
|
||
|
'log_content',
|
||
|
'log_add_user_name',
|
||
|
'log_add_time',
|
||
|
], [
|
||
|
'AND' => [
|
||
|
'OR' => [
|
||
|
'log_type_name[~]' => $searchKeyword,
|
||
|
'log_content[~]' => $searchKeyword,
|
||
|
'log_add_user_name[~]' => $searchKeyword,
|
||
|
'log_add_time[~]' => $searchKeyword,
|
||
|
],
|
||
|
],
|
||
|
'LIMIT' => [$begin, $pageSize]
|
||
|
]);
|
||
|
|
||
|
$total = $this->database->count('logs', [
|
||
|
'log_id'
|
||
|
], [
|
||
|
'AND' => [
|
||
|
'OR' => [
|
||
|
'log_type_name[~]' => $searchKeyword,
|
||
|
'log_content[~]' => $searchKeyword,
|
||
|
'log_add_user_name[~]' => $searchKeyword,
|
||
|
'log_add_time[~]' => $searchKeyword,
|
||
|
],
|
||
|
]
|
||
|
]);
|
||
|
|
||
3 years ago
|
return message(200, 1, '成功', [
|
||
3 years ago
|
'data' => $list,
|
||
|
'total' => $total
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 清空日志
|
||
|
*/
|
||
3 years ago
|
public function ClearLogs()
|
||
3 years ago
|
{
|
||
|
$this->database->delete('logs', [
|
||
|
'log_id[>]' => 0
|
||
|
]);
|
||
|
|
||
3 years ago
|
return message();
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
|
/**
|
||
|
* 写入日志
|
||
|
*/
|
||
|
public function InsertLog($log_type_name = '', $log_content = '', $log_add_user_name = '')
|
||
|
{
|
||
|
$this->database->insert('logs', [
|
||
|
'log_type_name' => $log_type_name,
|
||
|
'log_content' => $log_content,
|
||
|
'log_add_user_name' => $log_add_user_name,
|
||
|
'log_add_time' => date('Y-m-d H:i:s')
|
||
|
]);
|
||
|
}
|
||
3 years ago
|
}
|