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