nk-lihaink-cn/app/admin/model/AdminLog.php

53 lines
1.7 KiB
PHP
Raw Normal View History

2021-01-30 20:59:12 +08:00
<?php
2021-07-26 17:41:59 +08:00
/**
* @copyright Copyright (c) 2021 勾股工作室
2021-11-24 17:17:29 +08:00
* @license https://opensource.org/licenses/Apache-2.0
2021-07-26 17:41:59 +08:00
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
2021-01-30 20:59:12 +08:00
namespace app\admin\model;
use think\Model;
class AdminLog extends Model
{
public function get_log_list($param = [])
{
$where = array();
if (!empty($param['no_delete'])) {
$where['type'] = ['neq', 'delete']; //过滤删除操作
}
if (!empty($param['no_admin'])) {
$where['uid'] = ['neq', 1]; //超级管理员删除操作
}
if (!empty($param['uid'])) {
$where['uid'] = $param['uid']; //查询指定用户的操作
}
$where['status'] = 1;
$rows = empty($param['limit']) ? get_config('app.pages') : $param['limit'];
2021-07-26 17:41:59 +08:00
$content = \think\facade\Db::name('AdminLog')
->field("id,uid,nickname,type,title,module,controller,function,param,content,create_time")
2021-01-30 20:59:12 +08:00
->order('create_time desc')
->where($where)
->paginate($rows, false, ['query' => $param]);
$content->toArray();
foreach ($content as $k => $v) {
$data = $v;
$param_array = json_decode($v['param'], true);
$name = '';
if (!empty($param_array['name'])) {
2021-07-26 17:41:59 +08:00
$name = '' . $param_array['name'];
2021-01-30 20:59:12 +08:00
}
if (!empty($param_array['title'])) {
2021-07-26 17:41:59 +08:00
$name = '' . $param_array['title'];
2021-01-30 20:59:12 +08:00
}
$data['content'] = $v['content'] . $name;
2021-01-30 20:59:12 +08:00
$data['times'] = time_trans($v['create_time']);
$content->offsetSet($k, $data);
}
return $content;
}
}