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

use app\service\admin\BaseAdminService;
use Applications\sample\modules\stats\repository\StatsRepository;
use think\Request;

/**
 * Stats Service
 * @package Applications\sample\modules\stats\service\admin
 */
class StatsService extends BaseAdminService
{
    /**
     * 获取统计概览
     * @param Request $request
     * @return array
     */
    public function overview(Request $request): array
    {
        return [
            'code' => 0,
            'data' => [
                'update_time' => time(),
                'overview' => $this->repository()->overview(),
                'todo' => $this->repository()->todo(),
                'trend' => $this->repository()->trend(7),
            ],
        ];
    }

    /**
     * 获取统计仓库实例
     * @return StatsRepository
     */
    private function repository(): StatsRepository
    {
        return $this->app->make(StatsRepository::class);
    }
}
