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.
 
 

188 lines
6.3 KiB

<?php
declare (strict_types=1);
namespace app\api\model;
use app\Request;
use auth\PermissAuth;
use think\Model;
/**
* swagger response返回数据引用
* @OA\Schema(
* schema="LogMsgExport",
* required={"code","msg","count","data"},
* @OA\Property(
* property="code",
* type="integer",
* format="int32",
* description="状态码"
* ),
* @OA\Property(
* property="msg",
* type="string",
* description="提示消息"
* ),
* @OA\Property(
* property="count",
* type="integer",
* format="int32",
* description="记录总数",
* ),
* @OA\Property(
* property="data",
* type="array",
* description="请求结果",
* @OA\Items(
* @OA\Property(
* property="id",
* type="integer",
* description="ID"
* ),
* @OA\Property(
* property="site_id",
* type="integer",
* description="站点ID"
* ),
* @OA\Property(
* property="user_id",
* type="integer",
* description="管理员ID",
* ),
* @OA\Property(
* property="username",
* type="string",
* description="管理员用户名",
* ),
* @OA\Property(
* property="action_ip",
* type="string",
* description="执行行为者ip"
* ),
* @OA\Property(
* property="model",
* type="string",
* description="操作模块"
* ),
* @OA\Property(
* property="request_param",
* type="string",
* description="请求参数",
* ),
* @OA\Property(
* property="url",
* type="string",
* description="触发行为完整的url",
* ),
* @OA\Property(
* property="request_method",
* type="string",
* description="请求方式",
* ),
* @OA\Property(
* property="spend_time",
* type="float",
* description="耗时几秒",
* ),
* @OA\Property(
* property="record_id",
* type="integer",
* description="触发行为的数据id",
* ),
* @OA\Property(
* property="remark",
* type="string",
* description="日志备注"
* ),
* @OA\Property(
* property="data",
* type="string",
* description="修改后数据集合"
* ),
* @OA\Property(
* property="origin",
* type="string",
* description="修改前源数据"
* ),
* @OA\Property(
* property="sql",
* type="string",
* description="执行的sql记录"
* ),
* @OA\Property(
* property="status",
* type="integer",
* description="状态 0:禁用 1:启用"
* ),
* @OA\Property(
* property="client_os",
* type="string",
* description="客户端系统类型"
* ),
* @OA\Property(
* property="client_browser",
* type="string",
* description="客户端浏览器类型"
* ),
* @OA\Property(
* property="client_device",
* type="string",
* description="客户端设备型号,如 phone x 由api传过来"
* ),
* @OA\Property(
* property="delete_time",
* type="integer",
* description="是否删除 null:未删除"
* ),
* @OA\Property(
* property="update_time",
* type="integer",
* description="更新时间"
* ),
* @OA\Property(
* property="create_time",
* type="integer",
* description="创建时间"
* ),
* )
* ),
*
* ),
*/
class Log extends Common
{
public $table = 'system_action_log';
/**
* 管理员列表数据模型
* @return array|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$start_time = $this->request->param('create_time_start', '');
$end_time = $this->request->param('create_time_end', '');
if ($start_time && $end_time) {
$_op = $this->whereTime('create_time', '>=', strtotime($start_time));
$_op->whereTime('create_time', '<=', strtotime('+1 day', strtotime($end_time)));
}
return parent::parentLists(!empty($_op) ? $_op : '');
}
/**
* 读取后
* @param Model $model
* @return bool|void
*/
public static function onAfterRead(Model $model)
{
if (in_array(request()->action(), ['edit', 'delete', 'status'])) {
return true;
}
$model->offsetSet('action_ip', long2ip((int)$model->getAttr('action_ip')));
}
}