Browse Source
feat(index): 新增首页统计数据接口
feat(index): 新增首页统计数据接口
- 添加头部指引数据统计接口 - 实现AI平台收录统计接口 - 创建AI创作折线图数据接口 - 添加投喂任务线状图数据接口 - 配置相应路由规则及权限参数master
3 changed files with 149 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||||
|
<?php |
||||
|
namespace app\controller; |
||||
|
|
||||
|
use app\service\IndexService; |
||||
|
use support\Response; |
||||
|
|
||||
|
class IndexController |
||||
|
{ |
||||
|
public function head(IndexService $service): Response |
||||
|
{ |
||||
|
return success($service->processStatistic()); |
||||
|
} |
||||
|
|
||||
|
public function aiStatistic(IndexService $service) |
||||
|
{ |
||||
|
return success($service->aiStatistic()); |
||||
|
} |
||||
|
|
||||
|
public function createStatistic(IndexService $service) |
||||
|
{ |
||||
|
return success($service->createStatistic()); |
||||
|
} |
||||
|
|
||||
|
public function feedStatistic(IndexService $service) |
||||
|
{ |
||||
|
return success($service->feedStatistic()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,113 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace app\service; |
||||
|
|
||||
|
use app\dao\AiCommandDao; |
||||
|
use app\dao\CreationArticleDao; |
||||
|
use app\dao\DistillationQuestionsDao; |
||||
|
use app\dao\DistillationWordDao; |
||||
|
use app\dao\EnterprisePortraitLibraryDao; |
||||
|
use plugin\piadmin\app\base\BaseService; |
||||
|
use plugin\piadmin\app\utils\RequestUtils; |
||||
|
|
||||
|
class IndexService extends BaseService |
||||
|
{ |
||||
|
protected $user; |
||||
|
protected $distillationWordDao; |
||||
|
protected $portraitLibraryDao; |
||||
|
protected $aiCommandDao; |
||||
|
protected $creationArticleDao; |
||||
|
protected $questionDao; |
||||
|
|
||||
|
public function __construct() |
||||
|
{ |
||||
|
$this->user = RequestUtils::getUserInfo(); |
||||
|
$this->distillationWordDao = app()->make(DistillationWordDao::class); |
||||
|
$this->portraitLibraryDao = app()->make(EnterprisePortraitLibraryDao::class); |
||||
|
$this->aiCommandDao = app()->make(AICommandDao::class); |
||||
|
$this->creationArticleDao = app()->make(CreationArticleDao::class); |
||||
|
$this->questionDao = app()->make(DistillationQuestionsDao::class); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 头部指引 |
||||
|
*/ |
||||
|
public function processStatistic() |
||||
|
{ |
||||
|
return [ |
||||
|
//蒸馏词
|
||||
|
'word' => $this->distillationWordDao->count(), |
||||
|
//图库
|
||||
|
'library' => $this->portraitLibraryDao->count(), |
||||
|
//指令
|
||||
|
'command' => $this->aiCommandDao->count(), |
||||
|
//AI创作
|
||||
|
'ai' => $this->creationArticleDao->count(), |
||||
|
//授权账号
|
||||
|
'account' => 0, |
||||
|
//投喂任务
|
||||
|
'task' => 0, |
||||
|
//训练问题
|
||||
|
'question' => $this->questionDao->count(), |
||||
|
//收录问题
|
||||
|
'collect' => 0, |
||||
|
//媒体投喂
|
||||
|
'media' => 0 |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* AI收录统计 |
||||
|
*/ |
||||
|
public function aiStatistic() |
||||
|
{ |
||||
|
return [ |
||||
|
'deepseek' => 0, |
||||
|
'doubao' => 0, |
||||
|
'yuanbao' => 0, |
||||
|
'tongyiqianwen' => 0, |
||||
|
'wenxinyiyan' => 0, |
||||
|
'nami' => 0, |
||||
|
'kimi' => 0, |
||||
|
'zhipu' => 0 |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* AI创作折线图 |
||||
|
* 近五天 |
||||
|
*/ |
||||
|
public function createStatistic() |
||||
|
{ |
||||
|
$dates = []; |
||||
|
for ($i = 0; $i < 5; $i++) { |
||||
|
$dates[]['date'] = date('Y-m-d', strtotime("-{$i} days")); |
||||
|
} |
||||
|
foreach ($dates as &$date) { |
||||
|
$begin = strtotime($date['date']); |
||||
|
$end = strtotime("+1 day", $begin); |
||||
|
$date['count'] = $this->creationArticleDao->count([ |
||||
|
['create_time', 'between', [$begin, $end]], |
||||
|
]); |
||||
|
} |
||||
|
return $dates; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 投喂线状图 |
||||
|
*/ |
||||
|
public function feedStatistic() |
||||
|
{ |
||||
|
$dates = []; |
||||
|
for ($i = 0; $i < 5; $i++) { |
||||
|
$dates[]['date'] = date('Y-m-d', strtotime("-{$i} days")); |
||||
|
} |
||||
|
foreach ($dates as &$date) { |
||||
|
// $begin = strtotime($date['date']);
|
||||
|
// $end = strtotime("+1 day", $begin);
|
||||
|
$date['count'] = 0; |
||||
|
} |
||||
|
return $dates; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue