Files
cunkebao_v3/Server/application/api/controller/StatsController.php
2025-03-17 10:09:27 +08:00

75 lines
2.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\controller;
/**
* 统计控制器
* Class StatsController
* @package app\frontend\controller
*/
class StatsController extends BaseController
{
/**
* API客户端类型
*/
const CLIENT_TYPE = 'system';
/**
* 账号基本信息
* @return \think\response\Json
*/
public function basicData()
{
$authorization = trim($this->request->header('authorization', ''));
if (empty($authorization)) {
return errorJson('缺少授权信息');
}
$headerData = ['client:' . self::CLIENT_TYPE];
$header = setHeader($headerData, $authorization, 'plain');
try {
$result = requestCurl($this->baseUrl . '/api/DashBoard/ListHomePageStatistics', ['refresh' => 10000], 'GET', $header);
return successJson($result);
} catch (\Exception $e) {
return errorJson('获取基础数据失败:' . $e->getMessage());
}
}
/**
* 好友统计
* @return \think\response\Json
*/
public function FansStatistics(){
/* 参数说明
lidu 数据搜索类型 0 小时 1 天 2月
from to 时间 当lidu为 0时2025-03-12 09:54:42 当lidu为 1时2025-03-12 当lidu为 2时2025-03
*/
$authorization = trim($this->request->header('authorization', ''));
$lidu = trim($this->request->param('lidu', ''));
$from = trim($this->request->param('from', ''));
$to = trim($this->request->param('to', ''));
if (empty($authorization)) {
return errorJson('缺少授权信息');
}
$params = [
'lidu' => $lidu,
'from' => $from,
'to' => $to,
];
$headerData = ['client:' . self::CLIENT_TYPE];
$header = setHeader($headerData, $authorization, 'plain');
try {
$result = requestCurl($this->baseUrl . 'api/DashBoard/listStatisticsCountDTOByCreateTimeAsync', $params, 'GET', $header);
return successJson($result);
} catch (\Exception $e) {
return errorJson('获取粉丝统计数据失败:' . $e->getMessage());
}
}
}