<?php
// +----------------------------------------------------------------------
// | onezan-admin 快速开发的管理平台
// +----------------------------------------------------------------------
// | 官方网址：https://www.onezan.cn
// +----------------------------------------------------------------------
// | onezan团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: 543885307@qq.com
// +----------------------------------------------------------------------
namespace app\service\admin\operationlog;

use app\repository\admin\OperationLogRepository;
use app\service\RequestHelper;
use app\service\admin\BaseAdminService;
use think\Request;


/**
 * Operation Log Service
 * @package app\service\admin\operationlog
 */
class OperationLogService extends BaseAdminService
{

    /**
     * 操作日志分页列表
     * @param Request $request 请求对象
     * @return array
     */
    public function list(Request $request): array
    {
        return [
            'code' => 0,
            'data' => $this->repository()->paginate([
                'keyword' => $request->get('keyword', ''),
                'method' => $request->get('method', ''),
                'created_start' => $request->get('created_start', ''),
                'created_end' => $request->get('created_end', ''),
            ], RequestHelper::parseLimit($request, 'limit', 10, 100)),
        ];
    }

    /**
     * 获取操作日志仓储实例
     * @return OperationLogRepository
     */
    private function repository(): OperationLogRepository
    {
        return $this->app->make(OperationLogRepository::class);
    }
}