<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace Modules\Account\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\BaseController;
use Modules\Account\Services\AdminStatisticsService;

class Statistics extends BaseController {

	/**
	 * @title 概览统计
	 *
	 * @param Request $request
	 * @param AdminStatisticsService $service
	 * @return void
	 */
	public function overview(Request $request, AdminStatisticsService $service) {
		try {
			$this->data['data'] = $service->getOverview($request);
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return response()->json($this->data);
	}

	/**
	 * @title 趋势统计
	 *
	 * @param Request $request
	 * @param AdminStatisticsService $service
	 * @return void
	 */
	public function trend(Request $request, AdminStatisticsService $service) {
		try {
			$this->data['data'] = $service->getTrend($request);
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return response()->json($this->data);
	}

	/**
	 * @title 分类统计
	 *
	 * @param Request $request
	 * @param AdminStatisticsService $service
	 * @return void
	 */
	public function category(Request $request, AdminStatisticsService $service) {
		try {
			$this->data['data'] = $service->getCategoryStatistics($request);
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return response()->json($this->data);
	}

	/**
	 * @title 用户统计
	 *
	 * @param Request $request
	 * @param AdminStatisticsService $service
	 * @return void
	 */
	public function user(Request $request, AdminStatisticsService $service) {
		try {
			$this->data['data'] = $service->getUserStatistics($request);
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return response()->json($this->data);
	}

	/**
	 * @title 家庭统计
	 *
	 * @param Request $request
	 * @param AdminStatisticsService $service
	 * @return void
	 */
	public function family(Request $request, AdminStatisticsService $service) {
		try {
			$this->data['data'] = $service->getFamilyStatistics($request);
		} catch (\Exception $e) {
			$this->data['code'] = 0;
			$this->data['message'] = $e->getMessage();
		}
		return response()->json($this->data);
	}
}
