Browse Source
feat(user): 新增数据看板功能模块
feat(user): 新增数据看板功能模块
- 新增 DataBoardController 控制器,提供各类统计数据接口 - 新增 DataBoardService 服务类,实现具体统计逻辑 - 在路由中注册数据看板相关接口路径及权限控制 - 为在线媒体列表增加名称模糊搜索功能 - 完善数据看板的五个统计维度:数据总量、AI平台问题占比、搜索报表、问题报表、品牌报表master
5 changed files with 170 additions and 0 deletions
-
1app/controller/admin/OnlineMediasController.php
-
34app/controller/user/DataBoardController.php
-
15app/route/route.php
-
3app/service/admin/OnlineMediasService.php
-
117app/service/user/DataBoardService.php
@ -0,0 +1,34 @@ |
|||
<?php |
|||
namespace app\controller\user; |
|||
|
|||
|
|||
use app\service\user\DataBoardService; |
|||
|
|||
class DataBoardController |
|||
{ |
|||
|
|||
public function countStatistic(DataBoardService $service) |
|||
{ |
|||
return success($service->countStatistic()); |
|||
} |
|||
|
|||
public function aiStatistic(DataBoardService $service) |
|||
{ |
|||
return success($service->aiStatistic()); |
|||
} |
|||
|
|||
public function searchStatistic(DataBoardService $service) |
|||
{ |
|||
return success($service->searchStatistic()); |
|||
} |
|||
|
|||
public function questionStatistic(DataBoardService $service) |
|||
{ |
|||
return success($service->questionStatistic()); |
|||
} |
|||
|
|||
public function brandStatistic(DataBoardService $service) |
|||
{ |
|||
return success($service->brandStatistic()); |
|||
} |
|||
} |
|||
@ -0,0 +1,117 @@ |
|||
<?php |
|||
|
|||
namespace app\service\user; |
|||
|
|||
use app\dao\user\DistillationExpandWordDao; |
|||
use app\dao\user\DistillationWordDao; |
|||
use plugin\piadmin\app\base\BaseService; |
|||
|
|||
class DataBoardService extends BaseService |
|||
{ |
|||
protected $distillationWordDao; |
|||
protected $distillationWordExtendDao; |
|||
|
|||
public function __construct() |
|||
{ |
|||
$this->distillationWordDao = app()->make(DistillationWordDao::class); |
|||
$this->distillationWordExtendDao = app()->make(DistillationExpandWordDao::class); |
|||
} |
|||
|
|||
/** |
|||
* 数据总量 |
|||
* 蒸馏词总量, 拓展此总量 |
|||
* 蒸馏词扩展词数量排名 |
|||
*/ |
|||
public function countStatistic() |
|||
{ |
|||
$res = $this->distillationWordDao->getList([], '*', 0, 0, 'expand_count DESC', [], ['expand']); |
|||
return [ |
|||
'word' => sizeof($res), |
|||
'extend' => array_sum(array_column($res, 'expand_count')), |
|||
'top' => collect($res)->sortByDesc('expand_count')->take(10)->map(function ($item) { |
|||
return collect($item)->only(['id', 'name', 'expand_count'])->toArray(); |
|||
})->toArray(), |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* AI平台问题占比 |
|||
*/ |
|||
public function aiStatistic() |
|||
{ |
|||
return [ |
|||
'deepseek' => 0, |
|||
'doubao' => 0, |
|||
'yuanbao' => 0, |
|||
'tongyiqianwen' => 0, |
|||
'wenxinyiyan' => 0, |
|||
'nami' => 0, |
|||
'kimi' => 0, |
|||
'zhipu' => 0 |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* 报表明细-搜索报表 |
|||
*/ |
|||
public function searchStatistic() |
|||
{ |
|||
return [ |
|||
'ai' => [ |
|||
'deepseek' => 0, |
|||
'doubao' => 0, |
|||
'yuanbao' => 0, |
|||
'tongyiqianwen' => 0, |
|||
'wenxinyiyan' => 0, |
|||
'nami' => 0, |
|||
'kimi' => 0, |
|||
'zhipu' => 0 |
|||
], |
|||
'list' => [], |
|||
'count' => 0, |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* 报表明细-问题报表 |
|||
*/ |
|||
public function questionStatistic() |
|||
{ |
|||
return [ |
|||
'ai' => [ |
|||
'deepseek' => 0, |
|||
'doubao' => 0, |
|||
'yuanbao' => 0, |
|||
'tongyiqianwen' => 0, |
|||
'wenxinyiyan' => 0, |
|||
'nami' => 0, |
|||
'kimi' => 0, |
|||
'zhipu' => 0 |
|||
], |
|||
'list' => [], |
|||
'count' => 0, |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* 报表明细-品牌报表 |
|||
*/ |
|||
public function brandStatistic() |
|||
{ |
|||
return [ |
|||
'ai' => [ |
|||
'deepseek' => 0, |
|||
'doubao' => 0, |
|||
'yuanbao' => 0, |
|||
'tongyiqianwen' => 0, |
|||
'wenxinyiyan' => 0, |
|||
'nami' => 0, |
|||
'kimi' => 0, |
|||
'zhipu' => 0 |
|||
], |
|||
'list' => [], |
|||
'count' => 0, |
|||
]; |
|||
} |
|||
|
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue