超管后台 - 获取基础统计信息

This commit is contained in:
柳清爽
2025-04-21 12:04:37 +08:00
parent e8843a3010
commit e39b71d540
3 changed files with 66 additions and 58 deletions

View File

@@ -0,0 +1,61 @@
<?php
namespace app\superadmin\controller\dashboard;
use app\common\model\Administrator as AdministratorModel;
use app\common\model\Company as CompanyModel;
use think\Controller;
/**
* 仪表盘控制器
*/
class GetBasestatisticsController extends Controller
{
/**
* 项目总数
*
* @return CompanyModel
*/
protected function getCompanyCount(): int
{
return CompanyModel::count('*');
}
/**
* 管理员数量
*
* @return int
*/
protected function getAdminCount(): int
{
return AdministratorModel::count('*');
}
/**
* 客户总数
*
* @return int
*/
protected function getCustomerCount(): int
{
return $this->getCompanyCount();
}
/**
* 获取基础统计信息
*
* @return \think\response\Json
*/
public function index()
{
return json([
'code' => 200,
'msg' => '获取成功',
'data' => [
'companyCount' => $this->getCompanyCount(),
'adminCount' => $this->getAdminCount(),
'customerCount' => $this->getCustomerCount(),
]
]);
}
}