From c79310cd430c196ac89ddfe053af8ebfdc20edba Mon Sep 17 00:00:00 2001 From: "zhangf@suq.cn" Date: Mon, 15 Dec 2025 14:44:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(index):=20=E6=96=B0=E5=A2=9E=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加头部指引数据统计接口 - 实现AI平台收录统计接口 - 创建AI创作折线图数据接口 - 添加投喂任务线状图数据接口 - 配置相应路由规则及权限参数 --- app/controller/IndexController.php | 29 ++++++++++ app/route/route.php | 7 +++ app/service/IndexService.php | 113 +++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 app/controller/IndexController.php create mode 100644 app/service/IndexService.php diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php new file mode 100644 index 0000000..c2c348b --- /dev/null +++ b/app/controller/IndexController.php @@ -0,0 +1,29 @@ +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()); + } + +} \ No newline at end of file diff --git a/app/route/route.php b/app/route/route.php index b21e762..46121d5 100644 --- a/app/route/route.php +++ b/app/route/route.php @@ -18,7 +18,14 @@ use Webman\Route; Route::group('/service/v1', function () { //控制台 Route::group('/statistic', function () { + //数量统计 Route::get('/head', [IndexController::class, 'head'])->setParams(['perm' => ['indexHead']]); + //ai平台统计 + Route::get('/ai', [IndexController::class, 'aiStatistic'])->setParams(['perm' => ['indexAiStatistic']]); + //AI创作线状图 + Route::get('/creation', [IndexController::class, 'createStatistic'])->setParams(['perm' => ['indexCreationStatistic']]); + //投喂线状图 + Route::get('/feed', [IndexController::class, 'feedStatistic'])->setParams(['perm' => ['indexFeedStatistic']]); }); //蒸馏词 diff --git a/app/service/IndexService.php b/app/service/IndexService.php new file mode 100644 index 0000000..a6f5953 --- /dev/null +++ b/app/service/IndexService.php @@ -0,0 +1,113 @@ +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; + } +} \ No newline at end of file