From 8c648d90357f6834f57939dbd38bafcd2acdb4b0 Mon Sep 17 00:00:00 2001 From: "zhangf@suq.cn" Date: Mon, 15 Dec 2025 16:43:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E6=96=B0=E5=A2=9E=E5=AA=92?= =?UTF-8?q?=E4=BB=8B=E5=9C=88=E8=B5=84=E6=BA=90=E5=90=8C=E6=AD=A5=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20refactor:=E5=8C=BA=E5=88=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=EF=BC=8C=E4=BB=A3=E7=90=86=E7=AB=AF=EF=BC=8C=E8=BF=90?= =?UTF-8?q?=E8=90=A5=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/AiCommandController.php | 69 ------- app/controller/ArticleCategoryController.php | 56 ------ app/controller/CreationArticleController.php | 66 ------ app/controller/CreationTaskController.php | 70 ------- app/controller/DistillationQuestionsController.php | 54 ----- app/controller/DistillationWordController.php | 70 ------- .../EnterprisePortraitCategoryController.php | 56 ------ .../EnterprisePortraitLibraryController.php | 39 ---- app/controller/ExpiosiveReplicaController.php | 46 ----- app/controller/GlobalProxyController.php | 24 --- app/controller/IndexController.php | 29 --- app/controller/KnowledgeLibraryController.php | 40 ---- app/controller/admin/ApiController.php | 13 ++ app/controller/user/AiCommandController.php | 69 +++++++ app/controller/user/ArticleCategoryController.php | 56 ++++++ app/controller/user/CreationArticleController.php | 66 ++++++ app/controller/user/CreationTaskController.php | 70 +++++++ .../user/DistillationQuestionsController.php | 54 +++++ app/controller/user/DistillationWordController.php | 70 +++++++ .../user/EnterprisePortraitCategoryController.php | 56 ++++++ .../user/EnterprisePortraitLibraryController.php | 39 ++++ app/controller/user/ExpiosiveReplicaController.php | 46 +++++ app/controller/user/GlobalProxyController.php | 24 +++ app/controller/user/IndexController.php | 29 +++ app/controller/user/KnowledgeLibraryController.php | 40 ++++ app/dao/AiCommandDao.php | 15 -- app/dao/ArticleCategoryDao.php | 15 -- app/dao/CreationArticleDao.php | 15 -- app/dao/CreationTaskDao.php | 15 -- app/dao/DistillationExpandWordDao.php | 17 -- app/dao/DistillationQuestionsDao.php | 17 -- app/dao/DistillationTransWordDao.php | 17 -- app/dao/DistillationWordDao.php | 17 -- app/dao/EnterprisePortraitCategoryDao.php | 15 -- app/dao/EnterprisePortraitLibraryDao.php | 15 -- app/dao/ExpiosiveReplicaDao.php | 15 -- app/dao/GlobalProxyDao.php | 15 -- app/dao/KnowledgeLibraryDao.php | 15 -- app/dao/user/AiCommandDao.php | 15 ++ app/dao/user/ArticleCategoryDao.php | 15 ++ app/dao/user/CreationArticleDao.php | 15 ++ app/dao/user/CreationTaskDao.php | 15 ++ app/dao/user/DistillationExpandWordDao.php | 17 ++ app/dao/user/DistillationQuestionsDao.php | 17 ++ app/dao/user/DistillationTransWordDao.php | 17 ++ app/dao/user/DistillationWordDao.php | 17 ++ app/dao/user/EnterprisePortraitCategoryDao.php | 15 ++ app/dao/user/EnterprisePortraitLibraryDao.php | 15 ++ app/dao/user/ExpiosiveReplicaDao.php | 15 ++ app/dao/user/GlobalProxyDao.php | 15 ++ app/dao/user/KnowledgeLibraryDao.php | 15 ++ app/model/AiCommand.php | 33 --- app/model/ArticleCategory.php | 37 ---- app/model/CreationArticle.php | 37 ---- app/model/CreationTask.php | 38 ---- app/model/DistillationExpandWord.php | 33 --- app/model/DistillationQuestions.php | 38 ---- app/model/DistillationTransWord.php | 33 --- app/model/DistillationWord.php | 48 ----- app/model/EnterprisePortraitCategory.php | 37 ---- app/model/EnterprisePortraitLibrary.php | 37 ---- app/model/ExpiosiveReplica.php | 37 ---- app/model/GlobalProxy.php | 33 --- app/model/KnowLedgeLibrary.php | 33 --- app/model/user/AiCommand.php | 33 +++ app/model/user/ArticleCategory.php | 37 ++++ app/model/user/CreationArticle.php | 37 ++++ app/model/user/CreationTask.php | 38 ++++ app/model/user/DistillationExpandWord.php | 33 +++ app/model/user/DistillationQuestions.php | 38 ++++ app/model/user/DistillationTransWord.php | 33 +++ app/model/user/DistillationWord.php | 48 +++++ app/model/user/EnterprisePortraitCategory.php | 37 ++++ app/model/user/EnterprisePortraitLibrary.php | 37 ++++ app/model/user/ExpiosiveReplica.php | 37 ++++ app/model/user/GlobalProxy.php | 33 +++ app/model/user/KnowLedgeLibrary.php | 33 +++ app/queue/redis/CreationTask.php | 12 +- app/queue/redis/ExpiosiveReplica.php | 6 +- app/route/admin.php | 19 ++ app/route/proxy.php | 14 ++ app/route/route.php | 27 +-- app/service/AiCommandService.php | 131 ------------ app/service/ArticleCategoryService.php | 125 ------------ app/service/CreationArticleService.php | 140 ------------- app/service/CreationTaskService.php | 149 -------------- app/service/DistillationQuestionsService.php | 131 ------------ app/service/DistillationWordService.php | 222 --------------------- app/service/EnterprisePortraitCategoryService.php | 131 ------------ app/service/EnterprisePortraitLibraryService.php | 95 --------- app/service/ExpiosiveReplicaService.php | 108 ---------- app/service/GlobalProxyService.php | 68 ------- app/service/IndexService.php | 113 ----------- app/service/KnowledgeLibraryService.php | 92 --------- app/service/meijianquan/ApiService.php | 43 ++++ app/service/user/AiCommandService.php | 131 ++++++++++++ app/service/user/ArticleCategoryService.php | 125 ++++++++++++ app/service/user/CreationArticleService.php | 140 +++++++++++++ app/service/user/CreationTaskService.php | 149 ++++++++++++++ app/service/user/DistillationQuestionsService.php | 131 ++++++++++++ app/service/user/DistillationWordService.php | 222 +++++++++++++++++++++ .../user/EnterprisePortraitCategoryService.php | 131 ++++++++++++ .../user/EnterprisePortraitLibraryService.php | 95 +++++++++ app/service/user/ExpiosiveReplicaService.php | 108 ++++++++++ app/service/user/GlobalProxyService.php | 68 +++++++ app/service/user/IndexService.php | 113 +++++++++++ app/service/user/KnowledgeLibraryService.php | 92 +++++++++ composer.json | 3 +- composer.lock | 5 +- config/route.php | 2 + plugin/piadmin/app/model/SystemDept.php | 1 - 111 files changed, 2921 insertions(+), 2826 deletions(-) delete mode 100644 app/controller/AiCommandController.php delete mode 100644 app/controller/ArticleCategoryController.php delete mode 100644 app/controller/CreationArticleController.php delete mode 100644 app/controller/CreationTaskController.php delete mode 100644 app/controller/DistillationQuestionsController.php delete mode 100644 app/controller/DistillationWordController.php delete mode 100644 app/controller/EnterprisePortraitCategoryController.php delete mode 100644 app/controller/EnterprisePortraitLibraryController.php delete mode 100644 app/controller/ExpiosiveReplicaController.php delete mode 100644 app/controller/GlobalProxyController.php delete mode 100644 app/controller/IndexController.php delete mode 100644 app/controller/KnowledgeLibraryController.php create mode 100644 app/controller/admin/ApiController.php create mode 100644 app/controller/user/AiCommandController.php create mode 100644 app/controller/user/ArticleCategoryController.php create mode 100644 app/controller/user/CreationArticleController.php create mode 100644 app/controller/user/CreationTaskController.php create mode 100644 app/controller/user/DistillationQuestionsController.php create mode 100644 app/controller/user/DistillationWordController.php create mode 100644 app/controller/user/EnterprisePortraitCategoryController.php create mode 100644 app/controller/user/EnterprisePortraitLibraryController.php create mode 100644 app/controller/user/ExpiosiveReplicaController.php create mode 100644 app/controller/user/GlobalProxyController.php create mode 100644 app/controller/user/IndexController.php create mode 100644 app/controller/user/KnowledgeLibraryController.php delete mode 100644 app/dao/AiCommandDao.php delete mode 100644 app/dao/ArticleCategoryDao.php delete mode 100644 app/dao/CreationArticleDao.php delete mode 100644 app/dao/CreationTaskDao.php delete mode 100644 app/dao/DistillationExpandWordDao.php delete mode 100644 app/dao/DistillationQuestionsDao.php delete mode 100644 app/dao/DistillationTransWordDao.php delete mode 100644 app/dao/DistillationWordDao.php delete mode 100644 app/dao/EnterprisePortraitCategoryDao.php delete mode 100644 app/dao/EnterprisePortraitLibraryDao.php delete mode 100644 app/dao/ExpiosiveReplicaDao.php delete mode 100644 app/dao/GlobalProxyDao.php delete mode 100644 app/dao/KnowledgeLibraryDao.php create mode 100644 app/dao/user/AiCommandDao.php create mode 100644 app/dao/user/ArticleCategoryDao.php create mode 100644 app/dao/user/CreationArticleDao.php create mode 100644 app/dao/user/CreationTaskDao.php create mode 100644 app/dao/user/DistillationExpandWordDao.php create mode 100644 app/dao/user/DistillationQuestionsDao.php create mode 100644 app/dao/user/DistillationTransWordDao.php create mode 100644 app/dao/user/DistillationWordDao.php create mode 100644 app/dao/user/EnterprisePortraitCategoryDao.php create mode 100644 app/dao/user/EnterprisePortraitLibraryDao.php create mode 100644 app/dao/user/ExpiosiveReplicaDao.php create mode 100644 app/dao/user/GlobalProxyDao.php create mode 100644 app/dao/user/KnowledgeLibraryDao.php delete mode 100644 app/model/AiCommand.php delete mode 100644 app/model/ArticleCategory.php delete mode 100644 app/model/CreationArticle.php delete mode 100644 app/model/CreationTask.php delete mode 100644 app/model/DistillationExpandWord.php delete mode 100644 app/model/DistillationQuestions.php delete mode 100644 app/model/DistillationTransWord.php delete mode 100644 app/model/DistillationWord.php delete mode 100644 app/model/EnterprisePortraitCategory.php delete mode 100644 app/model/EnterprisePortraitLibrary.php delete mode 100644 app/model/ExpiosiveReplica.php delete mode 100644 app/model/GlobalProxy.php delete mode 100644 app/model/KnowLedgeLibrary.php create mode 100644 app/model/user/AiCommand.php create mode 100644 app/model/user/ArticleCategory.php create mode 100644 app/model/user/CreationArticle.php create mode 100644 app/model/user/CreationTask.php create mode 100644 app/model/user/DistillationExpandWord.php create mode 100644 app/model/user/DistillationQuestions.php create mode 100644 app/model/user/DistillationTransWord.php create mode 100644 app/model/user/DistillationWord.php create mode 100644 app/model/user/EnterprisePortraitCategory.php create mode 100644 app/model/user/EnterprisePortraitLibrary.php create mode 100644 app/model/user/ExpiosiveReplica.php create mode 100644 app/model/user/GlobalProxy.php create mode 100644 app/model/user/KnowLedgeLibrary.php create mode 100644 app/route/admin.php create mode 100644 app/route/proxy.php delete mode 100644 app/service/AiCommandService.php delete mode 100644 app/service/ArticleCategoryService.php delete mode 100644 app/service/CreationArticleService.php delete mode 100644 app/service/CreationTaskService.php delete mode 100644 app/service/DistillationQuestionsService.php delete mode 100644 app/service/DistillationWordService.php delete mode 100644 app/service/EnterprisePortraitCategoryService.php delete mode 100644 app/service/EnterprisePortraitLibraryService.php delete mode 100644 app/service/ExpiosiveReplicaService.php delete mode 100644 app/service/GlobalProxyService.php delete mode 100644 app/service/IndexService.php delete mode 100644 app/service/KnowledgeLibraryService.php create mode 100644 app/service/meijianquan/ApiService.php create mode 100644 app/service/user/AiCommandService.php create mode 100644 app/service/user/ArticleCategoryService.php create mode 100644 app/service/user/CreationArticleService.php create mode 100644 app/service/user/CreationTaskService.php create mode 100644 app/service/user/DistillationQuestionsService.php create mode 100644 app/service/user/DistillationWordService.php create mode 100644 app/service/user/EnterprisePortraitCategoryService.php create mode 100644 app/service/user/EnterprisePortraitLibraryService.php create mode 100644 app/service/user/ExpiosiveReplicaService.php create mode 100644 app/service/user/GlobalProxyService.php create mode 100644 app/service/user/IndexService.php create mode 100644 app/service/user/KnowledgeLibraryService.php diff --git a/app/controller/AiCommandController.php b/app/controller/AiCommandController.php deleted file mode 100644 index 30e2d51..0000000 --- a/app/controller/AiCommandController.php +++ /dev/null @@ -1,69 +0,0 @@ - '', - 'type' => '', - 'content' => '' - ]); - validate(AiCommandValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function update(AiCommandService $service): Response - { - $params = requestOnly([ - 'id' => '', - 'name' => '', - 'type' => '', - 'content' => '' - ]); - validate(AiCommandValidate::class)->check($params, 'update'); - return success($service->updateData(ArrayUtils::filterNotEmpty($params))); - } - - public function index(AiCommandService $service): Response - { - $params = requestOnly([ - 'name' => '', - 'type' => '', - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function read(AiCommandService $service): Response - { - $id = input('id'); - return success($service->readData($id)); - } - - public function delete(AiCommandService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - - public function pureIndex(AiCommandService $service) - { - $type = input('type'); - if (!$type) { - throw new ApiException('请选择类型'); - } - if (!in_array($type, [1,2,3])) { - throw new ApiException('请选择正确的类型'); - } - return success($service->selectData($type)); - } -} \ No newline at end of file diff --git a/app/controller/ArticleCategoryController.php b/app/controller/ArticleCategoryController.php deleted file mode 100644 index 47689be..0000000 --- a/app/controller/ArticleCategoryController.php +++ /dev/null @@ -1,56 +0,0 @@ - '', - ]); - validate(ArticleCategoryValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function update(ArticleCategoryService $service): Response - { - $params = requestOnly([ - 'id' => '', - 'name' => '', - ]); - validate(ArticleCategoryValidate::class)->check($params, 'update'); - return success($service->updateData(ArrayUtils::filterNotEmpty($params))); - } - - public function index(ArticleCategoryService $service): Response - { - $params = requestOnly([ - 'name' => '', - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function read(ArticleCategoryService $service): Response - { - $id = input('id'); - return success($service->readData($id)); - } - - public function delete(ArticleCategoryService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - - public function pureIndex(ArticleCategoryService $service) - { - return success($service->selectData()); - } -} \ No newline at end of file diff --git a/app/controller/CreationArticleController.php b/app/controller/CreationArticleController.php deleted file mode 100644 index 4dc05ed..0000000 --- a/app/controller/CreationArticleController.php +++ /dev/null @@ -1,66 +0,0 @@ - '', - 'article_category_id' => '', - 'cover' => '', - 'content' => '', - 'status' => '', - ]); - validate(CreationArticleValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function update(CreationArticleService $service): Response - { - $params = requestOnly([ - 'id' => '', - 'title' => '', - 'article_category_id' => '', - 'cover' => '', - 'content' => '', - 'status' => '', - ]); - validate(CreationArticleValidate::class)->check($params, 'update'); - return success($service->updateData(ArrayUtils::filterNotEmpty($params))); - } - - public function index(CreationArticleService $service): Response - { - $params = requestOnly([ - 'article_category_id' => '', - 'article_category' => '', - 'task_id' => '', - 'task' => '', - 'title' => '', - 'status' => '', - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function read(CreationArticleService $service): Response - { - $id = input('id'); - return success($service->readData($id)); - } - - public function delete(CreationArticleService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - - -} \ No newline at end of file diff --git a/app/controller/CreationTaskController.php b/app/controller/CreationTaskController.php deleted file mode 100644 index 768047c..0000000 --- a/app/controller/CreationTaskController.php +++ /dev/null @@ -1,70 +0,0 @@ - '', - 'distillation_id' => '', - 'portrait_category_id' => '', - 'image_count' => '', - 'knowledge_ids' => '', - 'content_ai_command_id' => '', - 'title_ai_command_id' => '', - 'creation_count' => '' - ]); - validate(CreationTaskValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function update(CreationTaskService $service): Response - { - $params = requestOnly([ - 'id' => '', - 'name' => '', - 'distillation_id' => '', - 'portrait_category_id' => '', - 'image_count' => '', - 'knowledge_id' => '', - 'content_ai_command_id' => '', - 'title_ai_command_id' => '', - 'creation_count' => '', - 'status' => '' - ]); - validate(CreationTaskValidate::class)->check($params, 'update'); - return success($service->updateData(ArrayUtils::filterNotEmpty($params))); - } - - public function index(CreationTaskService $service): Response - { - $params = requestOnly([ - 'name' => '', - 'distillation_word' => '', - 'status' => '', - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function read(CreationTaskService $service): Response - { - $id = input('id'); - return success($service->readData($id)); - } - - public function delete(CreationTaskService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - - -} \ No newline at end of file diff --git a/app/controller/DistillationQuestionsController.php b/app/controller/DistillationQuestionsController.php deleted file mode 100644 index aea94d2..0000000 --- a/app/controller/DistillationQuestionsController.php +++ /dev/null @@ -1,54 +0,0 @@ - '', - 'names' => '', - ]); - validate(DistillationQuestionsValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function update(DistillationQuestionsService $service): Response - { - $params = requestOnly([ - 'id' => '', - 'name' => '', - ]); - validate(DistillationQuestionsValidate::class)->check($params, 'update'); - return success($service->updateData(ArrayUtils::filterNotEmpty($params))); - } - - public function index(DistillationQuestionsService $service): Response - { - $params = requestOnly([ - 'word_name' => '', - 'name' => '', - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function read(DistillationQuestionsService $service): Response - { - $id = input('id'); - return success($service->readData($id)); - } - - public function delete(DistillationQuestionsService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - -} \ No newline at end of file diff --git a/app/controller/DistillationWordController.php b/app/controller/DistillationWordController.php deleted file mode 100644 index b7ab732..0000000 --- a/app/controller/DistillationWordController.php +++ /dev/null @@ -1,70 +0,0 @@ - '', - 'trans_words' => '', - 'expand_words' => [], - ]); - validate(DistillationWordValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function update(DistillationWordService $service): Response - { - $params = requestOnly([ - 'id' => '', - 'name' => '', - 'trans_words' => '', - 'drill_status' => 1, - 'algorithm' => 1 - ]); - validate(DistillationWordValidate::class)->check($params, 'update'); - return success($service->updateData(ArrayUtils::filterNotEmpty($params))); - } - - public function index(DistillationWordService $service): Response - { - $params = requestOnly([ - 'name' => '', - 'drill_status' => '', - 'algorithm' => '', - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function read(DistillationWordService $service): Response - { - $id = input('id'); - return success($service->readData($id)); - } - - public function delete(DistillationWordService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - - public function pureIndex(DistillationWordService $service) - { - return success($service->selectData()); - } - - public function aiExtend(DistillationWordService $service) - { - $word = input('word'); - return success($service->aiExtend($word)); - } - -} \ No newline at end of file diff --git a/app/controller/EnterprisePortraitCategoryController.php b/app/controller/EnterprisePortraitCategoryController.php deleted file mode 100644 index 30a1339..0000000 --- a/app/controller/EnterprisePortraitCategoryController.php +++ /dev/null @@ -1,56 +0,0 @@ - '', - ]); - validate(EnterprisePortraitCategoryValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function update(EnterprisePortraitCategoryService $service): Response - { - $params = requestOnly([ - 'id' => '', - 'name' => '', - ]); - validate(EnterprisePortraitCategoryValidate::class)->check($params, 'update'); - return success($service->updateData(ArrayUtils::filterNotEmpty($params))); - } - - public function index(EnterprisePortraitCategoryService $service): Response - { - $params = requestOnly([ - 'name' => '', - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function read(EnterprisePortraitCategoryService $service): Response - { - $id = input('id'); - return success($service->readData($id)); - } - - public function delete(EnterprisePortraitCategoryService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - - public function pureIndex(EnterprisePortraitCategoryService $service) - { - return success($service->selectData()); - } -} \ No newline at end of file diff --git a/app/controller/EnterprisePortraitLibraryController.php b/app/controller/EnterprisePortraitLibraryController.php deleted file mode 100644 index b64ec2f..0000000 --- a/app/controller/EnterprisePortraitLibraryController.php +++ /dev/null @@ -1,39 +0,0 @@ - '', - 'url' => '', - ]); - validate(EnterprisePortraitLibraryValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function index(EnterprisePortraitLibraryService $service): Response - { - $params = requestOnly([ - 'category_id' => '', - 'category' => '', - 'use_count' => '', - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function delete(EnterprisePortraitLibraryService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - - -} \ No newline at end of file diff --git a/app/controller/ExpiosiveReplicaController.php b/app/controller/ExpiosiveReplicaController.php deleted file mode 100644 index 130ad9a..0000000 --- a/app/controller/ExpiosiveReplicaController.php +++ /dev/null @@ -1,46 +0,0 @@ - '', - 'portrait_category_id' => '', - 'ai_command_id' => '' - ]); - validate(ExpiosiveReplicaValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function index(ExpiosiveReplicaService $service): Response - { - $params = requestOnly([ - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function read(ExpiosiveReplicaService $service): Response - { - $id = input('id'); - return success($service->readData($id)); - } - - public function delete(ExpiosiveReplicaService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - - public function pureIndex(ExpiosiveReplicaService $service) - { - return success($service->selectData()); - } -} \ No newline at end of file diff --git a/app/controller/GlobalProxyController.php b/app/controller/GlobalProxyController.php deleted file mode 100644 index a708f63..0000000 --- a/app/controller/GlobalProxyController.php +++ /dev/null @@ -1,24 +0,0 @@ - '', - 'agent_pass' => '' - ]); - return success($service->save($params)); - } - - - public function read(GlobalProxyService $service): Response - { - return success($service->readData()); - } - -} \ No newline at end of file diff --git a/app/controller/IndexController.php b/app/controller/IndexController.php deleted file mode 100644 index c2c348b..0000000 --- a/app/controller/IndexController.php +++ /dev/null @@ -1,29 +0,0 @@ -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/controller/KnowledgeLibraryController.php b/app/controller/KnowledgeLibraryController.php deleted file mode 100644 index ca832fe..0000000 --- a/app/controller/KnowledgeLibraryController.php +++ /dev/null @@ -1,40 +0,0 @@ - '', - 'url' => '', - ]); - validate(KnowledgeLibraryValidate::class)->check($params, 'save'); - return success($service->saveData($params)); - } - - public function index(KnowledgeLibraryService $service): Response - { - $params = requestOnly([ - 'name' => '', - 'begin_time' => '', - 'end_time' => '' - ]); - return success($service->listData($params)); - } - - public function delete(KnowledgeLibraryService $service): Response - { - $ids = input('ids'); - return success($service->deleteData($ids)); - } - - public function pureIndex(KnowledgeLibraryService $service) - { - return success($service->selectData()); - } -} \ No newline at end of file diff --git a/app/controller/admin/ApiController.php b/app/controller/admin/ApiController.php new file mode 100644 index 0000000..4016184 --- /dev/null +++ b/app/controller/admin/ApiController.php @@ -0,0 +1,13 @@ +syncResource()); + } +} \ No newline at end of file diff --git a/app/controller/user/AiCommandController.php b/app/controller/user/AiCommandController.php new file mode 100644 index 0000000..edb9c64 --- /dev/null +++ b/app/controller/user/AiCommandController.php @@ -0,0 +1,69 @@ + '', + 'type' => '', + 'content' => '' + ]); + validate(AiCommandValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function update(AiCommandService $service): Response + { + $params = requestOnly([ + 'id' => '', + 'name' => '', + 'type' => '', + 'content' => '' + ]); + validate(AiCommandValidate::class)->check($params, 'update'); + return success($service->updateData(ArrayUtils::filterNotEmpty($params))); + } + + public function index(AiCommandService $service): Response + { + $params = requestOnly([ + 'name' => '', + 'type' => '', + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function read(AiCommandService $service): Response + { + $id = input('id'); + return success($service->readData($id)); + } + + public function delete(AiCommandService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + + public function pureIndex(AiCommandService $service) + { + $type = input('type'); + if (!$type) { + throw new ApiException('请选择类型'); + } + if (!in_array($type, [1,2,3])) { + throw new ApiException('请选择正确的类型'); + } + return success($service->selectData($type)); + } +} \ No newline at end of file diff --git a/app/controller/user/ArticleCategoryController.php b/app/controller/user/ArticleCategoryController.php new file mode 100644 index 0000000..bddde2f --- /dev/null +++ b/app/controller/user/ArticleCategoryController.php @@ -0,0 +1,56 @@ + '', + ]); + validate(ArticleCategoryValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function update(ArticleCategoryService $service): Response + { + $params = requestOnly([ + 'id' => '', + 'name' => '', + ]); + validate(ArticleCategoryValidate::class)->check($params, 'update'); + return success($service->updateData(ArrayUtils::filterNotEmpty($params))); + } + + public function index(ArticleCategoryService $service): Response + { + $params = requestOnly([ + 'name' => '', + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function read(ArticleCategoryService $service): Response + { + $id = input('id'); + return success($service->readData($id)); + } + + public function delete(ArticleCategoryService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + + public function pureIndex(ArticleCategoryService $service) + { + return success($service->selectData()); + } +} \ No newline at end of file diff --git a/app/controller/user/CreationArticleController.php b/app/controller/user/CreationArticleController.php new file mode 100644 index 0000000..3b1a89b --- /dev/null +++ b/app/controller/user/CreationArticleController.php @@ -0,0 +1,66 @@ + '', + 'article_category_id' => '', + 'cover' => '', + 'content' => '', + 'status' => '', + ]); + validate(CreationArticleValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function update(CreationArticleService $service): Response + { + $params = requestOnly([ + 'id' => '', + 'title' => '', + 'article_category_id' => '', + 'cover' => '', + 'content' => '', + 'status' => '', + ]); + validate(CreationArticleValidate::class)->check($params, 'update'); + return success($service->updateData(ArrayUtils::filterNotEmpty($params))); + } + + public function index(CreationArticleService $service): Response + { + $params = requestOnly([ + 'article_category_id' => '', + 'article_category' => '', + 'task_id' => '', + 'task' => '', + 'title' => '', + 'status' => '', + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function read(CreationArticleService $service): Response + { + $id = input('id'); + return success($service->readData($id)); + } + + public function delete(CreationArticleService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + + +} \ No newline at end of file diff --git a/app/controller/user/CreationTaskController.php b/app/controller/user/CreationTaskController.php new file mode 100644 index 0000000..0905277 --- /dev/null +++ b/app/controller/user/CreationTaskController.php @@ -0,0 +1,70 @@ + '', + 'distillation_id' => '', + 'portrait_category_id' => '', + 'image_count' => '', + 'knowledge_ids' => '', + 'content_ai_command_id' => '', + 'title_ai_command_id' => '', + 'creation_count' => '' + ]); + validate(CreationTaskValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function update(CreationTaskService $service): Response + { + $params = requestOnly([ + 'id' => '', + 'name' => '', + 'distillation_id' => '', + 'portrait_category_id' => '', + 'image_count' => '', + 'knowledge_id' => '', + 'content_ai_command_id' => '', + 'title_ai_command_id' => '', + 'creation_count' => '', + 'status' => '' + ]); + validate(CreationTaskValidate::class)->check($params, 'update'); + return success($service->updateData(ArrayUtils::filterNotEmpty($params))); + } + + public function index(CreationTaskService $service): Response + { + $params = requestOnly([ + 'name' => '', + 'distillation_word' => '', + 'status' => '', + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function read(CreationTaskService $service): Response + { + $id = input('id'); + return success($service->readData($id)); + } + + public function delete(CreationTaskService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + + +} \ No newline at end of file diff --git a/app/controller/user/DistillationQuestionsController.php b/app/controller/user/DistillationQuestionsController.php new file mode 100644 index 0000000..27262e7 --- /dev/null +++ b/app/controller/user/DistillationQuestionsController.php @@ -0,0 +1,54 @@ + '', + 'names' => '', + ]); + validate(DistillationQuestionsValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function update(DistillationQuestionsService $service): Response + { + $params = requestOnly([ + 'id' => '', + 'name' => '', + ]); + validate(DistillationQuestionsValidate::class)->check($params, 'update'); + return success($service->updateData(ArrayUtils::filterNotEmpty($params))); + } + + public function index(DistillationQuestionsService $service): Response + { + $params = requestOnly([ + 'word_name' => '', + 'name' => '', + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function read(DistillationQuestionsService $service): Response + { + $id = input('id'); + return success($service->readData($id)); + } + + public function delete(DistillationQuestionsService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + +} \ No newline at end of file diff --git a/app/controller/user/DistillationWordController.php b/app/controller/user/DistillationWordController.php new file mode 100644 index 0000000..eb6d626 --- /dev/null +++ b/app/controller/user/DistillationWordController.php @@ -0,0 +1,70 @@ + '', + 'trans_words' => '', + 'expand_words' => [], + ]); + validate(DistillationWordValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function update(DistillationWordService $service): Response + { + $params = requestOnly([ + 'id' => '', + 'name' => '', + 'trans_words' => '', + 'drill_status' => 1, + 'algorithm' => 1 + ]); + validate(DistillationWordValidate::class)->check($params, 'update'); + return success($service->updateData(ArrayUtils::filterNotEmpty($params))); + } + + public function index(DistillationWordService $service): Response + { + $params = requestOnly([ + 'name' => '', + 'drill_status' => '', + 'algorithm' => '', + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function read(DistillationWordService $service): Response + { + $id = input('id'); + return success($service->readData($id)); + } + + public function delete(DistillationWordService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + + public function pureIndex(DistillationWordService $service) + { + return success($service->selectData()); + } + + public function aiExtend(DistillationWordService $service) + { + $word = input('word'); + return success($service->aiExtend($word)); + } + +} \ No newline at end of file diff --git a/app/controller/user/EnterprisePortraitCategoryController.php b/app/controller/user/EnterprisePortraitCategoryController.php new file mode 100644 index 0000000..e18672f --- /dev/null +++ b/app/controller/user/EnterprisePortraitCategoryController.php @@ -0,0 +1,56 @@ + '', + ]); + validate(EnterprisePortraitCategoryValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function update(EnterprisePortraitCategoryService $service): Response + { + $params = requestOnly([ + 'id' => '', + 'name' => '', + ]); + validate(EnterprisePortraitCategoryValidate::class)->check($params, 'update'); + return success($service->updateData(ArrayUtils::filterNotEmpty($params))); + } + + public function index(EnterprisePortraitCategoryService $service): Response + { + $params = requestOnly([ + 'name' => '', + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function read(EnterprisePortraitCategoryService $service): Response + { + $id = input('id'); + return success($service->readData($id)); + } + + public function delete(EnterprisePortraitCategoryService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + + public function pureIndex(EnterprisePortraitCategoryService $service) + { + return success($service->selectData()); + } +} \ No newline at end of file diff --git a/app/controller/user/EnterprisePortraitLibraryController.php b/app/controller/user/EnterprisePortraitLibraryController.php new file mode 100644 index 0000000..62b19ac --- /dev/null +++ b/app/controller/user/EnterprisePortraitLibraryController.php @@ -0,0 +1,39 @@ + '', + 'url' => '', + ]); + validate(EnterprisePortraitLibraryValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function index(EnterprisePortraitLibraryService $service): Response + { + $params = requestOnly([ + 'category_id' => '', + 'category' => '', + 'use_count' => '', + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function delete(EnterprisePortraitLibraryService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + + +} \ No newline at end of file diff --git a/app/controller/user/ExpiosiveReplicaController.php b/app/controller/user/ExpiosiveReplicaController.php new file mode 100644 index 0000000..8d54796 --- /dev/null +++ b/app/controller/user/ExpiosiveReplicaController.php @@ -0,0 +1,46 @@ + '', + 'portrait_category_id' => '', + 'ai_command_id' => '' + ]); + validate(ExpiosiveReplicaValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function index(ExpiosiveReplicaService $service): Response + { + $params = requestOnly([ + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function read(ExpiosiveReplicaService $service): Response + { + $id = input('id'); + return success($service->readData($id)); + } + + public function delete(ExpiosiveReplicaService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + + public function pureIndex(ExpiosiveReplicaService $service) + { + return success($service->selectData()); + } +} \ No newline at end of file diff --git a/app/controller/user/GlobalProxyController.php b/app/controller/user/GlobalProxyController.php new file mode 100644 index 0000000..fd535cb --- /dev/null +++ b/app/controller/user/GlobalProxyController.php @@ -0,0 +1,24 @@ + '', + 'agent_pass' => '' + ]); + return success($service->save($params)); + } + + + public function read(GlobalProxyService $service): Response + { + return success($service->readData()); + } + +} \ No newline at end of file diff --git a/app/controller/user/IndexController.php b/app/controller/user/IndexController.php new file mode 100644 index 0000000..4ee8747 --- /dev/null +++ b/app/controller/user/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/controller/user/KnowledgeLibraryController.php b/app/controller/user/KnowledgeLibraryController.php new file mode 100644 index 0000000..913de37 --- /dev/null +++ b/app/controller/user/KnowledgeLibraryController.php @@ -0,0 +1,40 @@ + '', + 'url' => '', + ]); + validate(KnowledgeLibraryValidate::class)->check($params, 'save'); + return success($service->saveData($params)); + } + + public function index(KnowledgeLibraryService $service): Response + { + $params = requestOnly([ + 'name' => '', + 'begin_time' => '', + 'end_time' => '' + ]); + return success($service->listData($params)); + } + + public function delete(KnowledgeLibraryService $service): Response + { + $ids = input('ids'); + return success($service->deleteData($ids)); + } + + public function pureIndex(KnowledgeLibraryService $service) + { + return success($service->selectData()); + } +} \ No newline at end of file diff --git a/app/dao/AiCommandDao.php b/app/dao/AiCommandDao.php deleted file mode 100644 index 832a0c0..0000000 --- a/app/dao/AiCommandDao.php +++ /dev/null @@ -1,15 +0,0 @@ -hasMany(CreationArticle::class, 'article_category_id', 'id'); - } -} \ No newline at end of file diff --git a/app/model/CreationArticle.php b/app/model/CreationArticle.php deleted file mode 100644 index c39a269..0000000 --- a/app/model/CreationArticle.php +++ /dev/null @@ -1,37 +0,0 @@ -belongsTo(ArticleCategory::class, 'article_category_id', 'id'); - } -} \ No newline at end of file diff --git a/app/model/CreationTask.php b/app/model/CreationTask.php deleted file mode 100644 index 5215b16..0000000 --- a/app/model/CreationTask.php +++ /dev/null @@ -1,38 +0,0 @@ -belongsTo(DistillationWord::class, 'distillation_id', 'id'); - } - -} \ No newline at end of file diff --git a/app/model/DistillationExpandWord.php b/app/model/DistillationExpandWord.php deleted file mode 100644 index f112d1c..0000000 --- a/app/model/DistillationExpandWord.php +++ /dev/null @@ -1,33 +0,0 @@ -belongsTo(DistillationWord::class, 'distillation_id', 'id'); - } - -} \ No newline at end of file diff --git a/app/model/DistillationTransWord.php b/app/model/DistillationTransWord.php deleted file mode 100644 index 9689e69..0000000 --- a/app/model/DistillationTransWord.php +++ /dev/null @@ -1,33 +0,0 @@ -hasMany(DistillationTransWord::class, 'distillation_id', 'id'); - } - - public function expand() - { - return $this->hasMany(DistillationExpandWord::class, 'distillation_id', 'id'); - } - - public function questions() - { - return $this->hasMany(DistillationQuestions::class, 'distillation_id', 'id')->where(['delete_time' => 0]); - } - -} \ No newline at end of file diff --git a/app/model/EnterprisePortraitCategory.php b/app/model/EnterprisePortraitCategory.php deleted file mode 100644 index c7371a9..0000000 --- a/app/model/EnterprisePortraitCategory.php +++ /dev/null @@ -1,37 +0,0 @@ -hasMany(EnterprisePortraitLibrary::class, 'category_id', 'id'); - } -} \ No newline at end of file diff --git a/app/model/EnterprisePortraitLibrary.php b/app/model/EnterprisePortraitLibrary.php deleted file mode 100644 index 197fb81..0000000 --- a/app/model/EnterprisePortraitLibrary.php +++ /dev/null @@ -1,37 +0,0 @@ -belongsTo(EnterprisePortraitCategory::class, 'category_id', 'id'); - } -} \ No newline at end of file diff --git a/app/model/ExpiosiveReplica.php b/app/model/ExpiosiveReplica.php deleted file mode 100644 index edf843f..0000000 --- a/app/model/ExpiosiveReplica.php +++ /dev/null @@ -1,37 +0,0 @@ -hasMany(CreationArticle::class, 'article_category_id', 'id'); + } +} \ No newline at end of file diff --git a/app/model/user/CreationArticle.php b/app/model/user/CreationArticle.php new file mode 100644 index 0000000..a5a8c3f --- /dev/null +++ b/app/model/user/CreationArticle.php @@ -0,0 +1,37 @@ +belongsTo(ArticleCategory::class, 'article_category_id', 'id'); + } +} \ No newline at end of file diff --git a/app/model/user/CreationTask.php b/app/model/user/CreationTask.php new file mode 100644 index 0000000..27fc304 --- /dev/null +++ b/app/model/user/CreationTask.php @@ -0,0 +1,38 @@ +belongsTo(DistillationWord::class, 'distillation_id', 'id'); + } + +} \ No newline at end of file diff --git a/app/model/user/DistillationExpandWord.php b/app/model/user/DistillationExpandWord.php new file mode 100644 index 0000000..e208b11 --- /dev/null +++ b/app/model/user/DistillationExpandWord.php @@ -0,0 +1,33 @@ +belongsTo(DistillationWord::class, 'distillation_id', 'id'); + } + +} \ No newline at end of file diff --git a/app/model/user/DistillationTransWord.php b/app/model/user/DistillationTransWord.php new file mode 100644 index 0000000..8ca184e --- /dev/null +++ b/app/model/user/DistillationTransWord.php @@ -0,0 +1,33 @@ +hasMany(DistillationTransWord::class, 'distillation_id', 'id'); + } + + public function expand() + { + return $this->hasMany(DistillationExpandWord::class, 'distillation_id', 'id'); + } + + public function questions() + { + return $this->hasMany(DistillationQuestions::class, 'distillation_id', 'id')->where(['delete_time' => 0]); + } + +} \ No newline at end of file diff --git a/app/model/user/EnterprisePortraitCategory.php b/app/model/user/EnterprisePortraitCategory.php new file mode 100644 index 0000000..e437284 --- /dev/null +++ b/app/model/user/EnterprisePortraitCategory.php @@ -0,0 +1,37 @@ +hasMany(EnterprisePortraitLibrary::class, 'category_id', 'id'); + } +} \ No newline at end of file diff --git a/app/model/user/EnterprisePortraitLibrary.php b/app/model/user/EnterprisePortraitLibrary.php new file mode 100644 index 0000000..acf5bdc --- /dev/null +++ b/app/model/user/EnterprisePortraitLibrary.php @@ -0,0 +1,37 @@ +belongsTo(EnterprisePortraitCategory::class, 'category_id', 'id'); + } +} \ No newline at end of file diff --git a/app/model/user/ExpiosiveReplica.php b/app/model/user/ExpiosiveReplica.php new file mode 100644 index 0000000..ac3675f --- /dev/null +++ b/app/model/user/ExpiosiveReplica.php @@ -0,0 +1,37 @@ +setParams(['perm' => ['meijiequanSyncResource']]); + }); + +})->middleware([ + AdminAuthorizationMiddleware::class, +// PermissionsMiddleware::class +]); \ No newline at end of file diff --git a/app/route/proxy.php b/app/route/proxy.php new file mode 100644 index 0000000..4829e7a --- /dev/null +++ b/app/route/proxy.php @@ -0,0 +1,14 @@ +middleware([ + ProxyUserAuthorizationMiddleware::class +]); \ No newline at end of file diff --git a/app/route/route.php b/app/route/route.php index 46121d5..12fdf32 100644 --- a/app/route/route.php +++ b/app/route/route.php @@ -1,20 +1,23 @@ dao = $dao; - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - $data = $this->dao->save($params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $data->toArray(); - } - - /** - * 修改信息 - * @param array $params - * @return array - */ - public function updateData(array $params): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update(['id' => $params['id']], $params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $params; - } - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['name'])) { - $query[] = ['name', 'like', '%' . $params['name'] . '%']; - } - if (isNotBlank($params['type'])) { - $query[] = ['type', '=', $params['type']]; - } - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, 'id,name,type,create_time', $page, $limit, "$sortField $sortRule"); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - /** - * 获取信息 - * @param mixed $id - * @return array - */ - public function readData(mixed $id): array - { - $aiCommand = $this->dao->get(['id' => $id]); - if (empty($aiCommand)) { - throw new ApiException('数据不存在'); - } - return $aiCommand->toArray(); - } - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - - public function selectData($type) - { - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($type)) { - $query[] = ['type', '=', $type]; - } - $list = $this->dao->getList($query); - return $list; - } -} \ No newline at end of file diff --git a/app/service/ArticleCategoryService.php b/app/service/ArticleCategoryService.php deleted file mode 100644 index a9656f9..0000000 --- a/app/service/ArticleCategoryService.php +++ /dev/null @@ -1,125 +0,0 @@ -dao = $dao; - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - $data = $this->dao->save($params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $data->toArray(); - } - - /** - * 修改信息 - * @param array $params - * @return array - */ - public function updateData(array $params): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update(['id' => $params['id']], $params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $params; - } - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['name'])) { - $query[] = ['name', 'like', '%' . $params['name'] . '%']; - } - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", [], ['article']); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - /** - * 获取信息 - * @param mixed $id - * @return array - */ - public function readData(mixed $id): array - { - $category = $this->dao->get(['id' => $id]); - if (empty($category)) { - throw new ApiException('数据不存在'); - } - return $category->toArray(); - } - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - - public function selectData() - { - $query = [ - 'delete_time' => 0 - ]; - $list = $this->dao->getList($query); - return $list; - } -} \ No newline at end of file diff --git a/app/service/CreationArticleService.php b/app/service/CreationArticleService.php deleted file mode 100644 index 6da337e..0000000 --- a/app/service/CreationArticleService.php +++ /dev/null @@ -1,140 +0,0 @@ -dao = $dao; - $this->articleCategoryDao = app()->make(ArticleCategoryDao::class); - $this->taskDao = app()->make(CreationTaskDao::class); - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - $data = $this->dao->save($params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $data->toArray(); - } - - /** - * 修改信息 - * @param array $params - * @return array - */ - public function updateData(array $params): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update(['id' => $params['id']], $params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $params; - } - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['article_category_id'])) { - $query[] = ['article_category_id', '=', $params['article_category_id']]; - } - if (isNotBlank($params['article_category'])) { - $cids = $this->articleCategoryDao->getColumn([['name', 'like', '%' . $params['article_category'] . '%']], 'id'); - $query[] = ['article_category_id', 'in', $cids]; - } - if (isNotBlank($params['task_id'])) { - $query[] = ['task_id', '=', $params['task_id']]; - } - if (isNotBlank($params['task'])) { - $tids = $this->taskDao->getColumn([['name', 'like', '%' . $params['task'] . '%']], 'id'); - $query[] = ['task_id', 'in', $tids]; - } - if (isNotBlank($params['title'])) { - $query[] = ['title', 'like', '%' . $params['title'] . '%']; - } - if (isNotBlank($params['status'])) { - $query[] = ['status', '=', $params['status']]; - } - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, 'id,title,status,create_time,article_category_id', $page, $limit, "$sortField $sortRule", ['category']); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - /** - * 获取信息 - * @param mixed $id - * @return array - */ - public function readData(mixed $id): array - { - $aiCommand = $this->dao->get(['id' => $id]); - if (empty($aiCommand)) { - throw new ApiException('数据不存在'); - } - return $aiCommand->toArray(); - } - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - -} \ No newline at end of file diff --git a/app/service/CreationTaskService.php b/app/service/CreationTaskService.php deleted file mode 100644 index 9048e99..0000000 --- a/app/service/CreationTaskService.php +++ /dev/null @@ -1,149 +0,0 @@ -dao = $dao; - $this->distillationDao = app()->make(DistillationWordDao::class); - $this->articleCategoryDao = app()->make(ArticleCategoryDao::class); - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - //同步创建文章分类,若存在则不创建 - $category = $this->articleCategoryDao->getOne([ - 'name' => $params['name'] - ]); - if (!$category) { - $category = $this->articleCategoryDao->save([ - 'name' => $params['name'] - ]); - } - $params['article_category_id'] = $category['id']; - if (isNotBlank($params['knowledge_ids'])) { - $params['knowledge_ids'] = implode(',', $params['knowledge_ids']); - } - $data = $this->dao->save($params); - Db::commit(); - //投递消息 - Redis::send('creation-task', ['task_id' => $data['id']]); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $data->toArray(); - } - - /** - * 修改信息 - * @param array $params - * @return array - */ - public function updateData(array $params): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update(['id' => $params['id']], $params); - Db::commit(); - //投递消息 - Redis::send('creation-task', ['task_id' => $params['id']]); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $params; - } - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['name'])) { - $query[] = ['name', 'like', '%' . $params['name'] . '%']; - } - if (isNotBlank($params['distillation_word'])) { - $ids = $this->distillationDao->getColumn([['name', 'like', '%' . $params['distillation_word'] . '%']], 'id'); - $query[] = ['distillation_id', 'in', $ids]; - } - if (isNotBlank($params['status'])) { - $query[] = ['status', '=', $params['status']]; - } - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", ['distillaction']); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - /** - * 获取信息 - * @param mixed $id - * @return array - */ - public function readData(mixed $id): array - { - $aiCommand = $this->dao->get(['id' => $id]); - if (empty($aiCommand)) { - throw new ApiException('数据不存在'); - } - $aiCommand['knowledge_ids'] = array_map('intval', explode(',', $aiCommand['knowledge_ids'])); - return $aiCommand->toArray(); - } - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - -} \ No newline at end of file diff --git a/app/service/DistillationQuestionsService.php b/app/service/DistillationQuestionsService.php deleted file mode 100644 index b629068..0000000 --- a/app/service/DistillationQuestionsService.php +++ /dev/null @@ -1,131 +0,0 @@ -dao = $dao; - $this->wordDao = app()->make(DistillationWordDao::class); - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - $questions = []; - foreach ($params['names'] as $item) { - $questions[] = [ - 'distillation_id' => $params['distillation_id'], - 'name' => $item - ]; - } - $this->dao->insertAll($questions); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $questions; - } - - /** - * 修改信息 - * @param array $params - * @return array - */ - public function updateData(array $params): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update(['id' => $params['id']], $params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $params; - } - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['word_name'])) { - $word_ids = $this->wordDao->getColumn([['name', 'like', '%' . $params['word_name'] . '%']], 'id'); - $query[] = ['distillation_id', 'in', $word_ids]; - } - if (isNotBlank($params['name'])) { - $query[] = ['name', 'like', '%' . $params['name'] . '%']; - } - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", ['distillation']); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - /** - * 获取信息 - * @param mixed $id - * @return array - */ - public function readData(mixed $id): array - { - $question = $this->dao->get(['id' => $id], ['*'], ['distillation']); - if (empty($question)) { - throw new ApiException('数据不存在'); - } - return $question->toArray(); - } - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - -} \ No newline at end of file diff --git a/app/service/DistillationWordService.php b/app/service/DistillationWordService.php deleted file mode 100644 index 3a6329b..0000000 --- a/app/service/DistillationWordService.php +++ /dev/null @@ -1,222 +0,0 @@ -dao = $dao; - $this->transDao = app()->make(DistillationTransWordDao::class); - $this->expandDao = app()->make(DistillationExpandWordDao::class); - $this->questionsDao = app()->make(DistillationQuestionsDao::class); - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - //保存主表 - $data = $this->dao->save([ - 'name' => $params['name'] - ]); - //保存目标转化此 - $trans_words = str_replace(',', ',', $params['trans_words']); - $trans_words = explode(',', $trans_words); - $trans = []; - foreach ($trans_words as $item) { - $trans[] = [ - 'distillation_id' => $data['id'], - 'name' => $item - ]; - } - $this->transDao->insertAll($trans); - //保存扩展此 - $expands = []; - foreach ($params['expand_words'] as $item) { - $expands[] = [ - 'distillation_id' => $data['id'], - 'name' => $item - ]; - } - $this->expandDao->insertAll($expands); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $data->toArray(); - } - - /** - * 修改信息 - * @param array $params - * @return array - */ - public function updateData(array $params): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update(['id' => $params['id']], $params); - //目标转化词,先删后加 - $this->transDao->delete(['distillation_id' => $params['id']]); - $trans_words = str_replace(',', ',', $params['trans_words']); - $trans_words = explode(',', $trans_words); - $trans = []; - foreach ($trans_words as $item) { - if (empty($item)) { - continue; - } - $trans[] = [ - 'distillation_id' => $params['id'], - 'name' => $item - ]; - } - $this->transDao->insertAll($trans); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $params; - } - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['name'])) { - $query[] = ['name', 'like', '%' . $params['name'] . '%']; - } - if (isNotBlank($params['drill_status'])) { - $query[] = ['drill_status', '=', $params['drill_status']]; - } - if (isNotBlank($params['algorithm'])) { - $query[] = ['algorithm', '=', $params['algorithm']]; - } - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", [], ['questions']); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - /** - * 获取信息 - * @param mixed $id - * @return array - */ - public function readData(mixed $id): array - { - $distillationWords = $this->dao->get(['id' => $id], ['*'], ['trans']); - if (empty($distillationWords)) { - throw new ApiException('数据不存在'); - } - $data = $distillationWords->toArray(); - $data['trans_str'] = implode(',', array_column($data['trans'], 'name')); - unset($data['trans']); - return $data; - } - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - //删主表 - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - //删子表 - $this->transDao->update([['distillation_id', 'in', $ids]], ['delete_time' => time()]); - $this->expandDao->update([['distillation_id', 'in', $ids]], ['delete_time' => time()]); - $this->questionsDao->update([['distillation_id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - - public function selectData() - { - $query = [ - 'delete_time' => 0 - ]; - $list = $this->dao->getList($query, '*', 0, 0, 'id DESC', [], ['questions']); - return $list; - } - - public function aiExtend($word) - { - $prompt = '- Role: 市场调研专家和品牌分析顾问 -- Background: 用户需要根据一个主关键词批量生成相关的拓展内容。例如,用户提供“洗地机品牌”,需要生成“市面上口碑好的洗地机品牌哪家好”等相关的拓展内容。这表明用户需要对某一领域的热门品牌进行深入了解和分析,以便获取有价值的信息。 -- Profile: 你是一位在市场调研和品牌分析领域有着丰富经验的专家,能够精准把握市场动态,提供权威的品牌分析和市场洞察。你熟悉各类产品的市场情况,能够根据用户提供的主关键词,快速生成相关的拓展内容。 -- Skills: 你具备市场调研能力、品牌分析技巧、数据收集与整理能力,以及对消费者口碑的敏锐洞察力。能够根据用户提供的主关键词,结合市场数据和消费者评价,生成有价值且具有参考意义的拓展内容。 -- Goals: 根据用户提供的主关键词,批量生成相关的拓展内容,如“市面上口碑好的洗地机品牌哪家好”,确保内容准确、权威且具有参考价值。 -- Constrains: 拓展内容必须与用户提供的主关键词相关,且基于市场调研和消费者评价,确保信息的真实性和可靠性。内容应简洁明了,避免冗长和复杂的表述。 -- OutputFormat: 输出格式为JSON格式,将生成的拓展内容放在`content`字段中,每个拓展内容独立成行,便于用户查看和使用。 -- Workflow: - 1. 接收用户提供的主关键词。 - 2. 根据主关键词,结合市场调研数据和消费者评价,生成相关的拓展内容,拓展内容数量在20以上,且不重复或相似。 - 3. 对生成的拓展内容进行审核和优化,确保内容准确、权威且具有参考价值。 - 4. 将拓展内容整合到JSON格式中,放在`content`字段中。 -- Examples: - - 假设用户提供的主关键词是“洗涤剂品牌”,生成的拓展内容如下: - ```json - { - "content": [ - "市面上口碑好的洗涤剂品牌有哪些?", - "洗涤剂品牌哪个好用又实惠?", - "推荐几款性价比高的洗涤剂品牌", - "洗涤剂品牌排行榜:哪些值得购买?", - "家用洗涤剂品牌,哪个更环保?", - "洗涤剂品牌对比:哪个更适合手洗?", - "洗涤剂品牌推荐:哪个适合敏感肌肤?", - "洗涤剂品牌测评:哪个去污力更强?", - "洗涤剂品牌选购指南:如何挑选?", - "洗涤剂品牌哪个更受欢迎?" - ] - },我提供的主关键词:' . $word; - $result = OpenAiClient::chat($prompt); - return $result['content']['content']; - } -} \ No newline at end of file diff --git a/app/service/EnterprisePortraitCategoryService.php b/app/service/EnterprisePortraitCategoryService.php deleted file mode 100644 index f992466..0000000 --- a/app/service/EnterprisePortraitCategoryService.php +++ /dev/null @@ -1,131 +0,0 @@ -dao = $dao; - $this->libraryDao = app()->make(EnterprisePortraitLibraryDao::class); - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - $data = $this->dao->save($params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $data->toArray(); - } - - /** - * 修改信息 - * @param array $params - * @return array - */ - public function updateData(array $params): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update(['id' => $params['id']], $params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $params; - } - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['name'])) { - $query[] = ['name', 'like', '%' . $params['name'] . '%']; - } - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", [], ['files']); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - /** - * 获取信息 - * @param mixed $id - * @return array - */ - public function readData(mixed $id): array - { - $category = $this->dao->get(['id' => $id]); - if (empty($category)) { - throw new ApiException('数据不存在'); - } - return $category->toArray(); - } - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - //删除表 - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - //删图库 - $this->libraryDao->update([['category_id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - - public function selectData() - { - $query = [ - 'delete_time' => 0 - ]; - $list = $this->dao->getList($query, '*', 0, 0, 'id DESC', [], ['files']); - return $list; - } -} \ No newline at end of file diff --git a/app/service/EnterprisePortraitLibraryService.php b/app/service/EnterprisePortraitLibraryService.php deleted file mode 100644 index 8a3a626..0000000 --- a/app/service/EnterprisePortraitLibraryService.php +++ /dev/null @@ -1,95 +0,0 @@ -dao = $dao; - $this->categoryDao = app()->make(EnterprisePortraitCategoryDao::class); - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - $data = $this->dao->save($params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $data->toArray(); - } - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['category_id']) && empty($params['category'])) { - $query[] = ['category_id', '=', $params['category_id']]; - } - if (isNotBlank($params['category'])) { - $cids = $this->categoryDao->getColumn([['name', 'like', '%' . $params['category'] . '%']], 'id'); - $query[] = ['category_id', 'in', $cids]; - } - if (isNotBlank($params['use_count'])) { - $query[] = ['use_count', '=', $params['use_count']]; - } - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", ['category']); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - -} \ No newline at end of file diff --git a/app/service/ExpiosiveReplicaService.php b/app/service/ExpiosiveReplicaService.php deleted file mode 100644 index 4b270c9..0000000 --- a/app/service/ExpiosiveReplicaService.php +++ /dev/null @@ -1,108 +0,0 @@ -dao = $dao; - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - $params['name'] = '全网爆文复刻[' . date('Y-m-d H:i') . ']'; - $data = $this->dao->save($params); - Db::commit(); - // 投递消息 - Redis::send('expiosive_replica', ['replica_id' => $data['id']]); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $data->toArray(); - } - - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, 'id,name,url,title,ai_time,status,status_msg', $page, $limit, "$sortField $sortRule"); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - /** - * 获取信息 - * @param mixed $id - * @return array - */ - public function readData(mixed $id): array - { - $replica = $this->dao->get(['id' => $id]); - if (empty($replica)) { - throw new ApiException('数据不存在'); - } - return $replica->toArray(); - } - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - - public function selectData() - { - $query = [ - 'delete_time' => 0 - ]; - $list = $this->dao->getList($query); - return $list; - } -} \ No newline at end of file diff --git a/app/service/GlobalProxyService.php b/app/service/GlobalProxyService.php deleted file mode 100644 index 5efca9b..0000000 --- a/app/service/GlobalProxyService.php +++ /dev/null @@ -1,68 +0,0 @@ -dao = $dao; - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function save(array $params): array - { - // 落库 - Db::startTrans(); - try { - $userInfo = RequestUtils::getUserInfo(); - $proxy = $this->dao->getOne(['uid' => $userInfo['id']]); - if ($proxy) { - $this->dao->update(['id' => $proxy['id']], $params); - } else { - $params['uid'] = $userInfo['id']; - $this->dao->save($params); - } - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $params; - } - - - /** - * 获取信息 - * @param mixed $id - * @return array - */ - public function readData(): array - { - $userInfo = RequestUtils::getUserInfo(); - $proxy = $this->dao->getOne(['uid' => $userInfo['id']]); - if (empty($proxy)) { - return [ - 'uid' => $userInfo['id'], - 'agent_ip' => '', - 'agent_pass' => '' - ]; - } - return $proxy->toArray(); - } - - -} \ No newline at end of file diff --git a/app/service/IndexService.php b/app/service/IndexService.php deleted file mode 100644 index a6f5953..0000000 --- a/app/service/IndexService.php +++ /dev/null @@ -1,113 +0,0 @@ -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 diff --git a/app/service/KnowledgeLibraryService.php b/app/service/KnowledgeLibraryService.php deleted file mode 100644 index f4bd200..0000000 --- a/app/service/KnowledgeLibraryService.php +++ /dev/null @@ -1,92 +0,0 @@ -dao = $dao; - } - - /** - * 保存信息 - * @param array $params - * @return array - */ - public function saveData(array $params): array - { - Db::startTrans(); - try { - $data = $this->dao->save($params); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return $data->toArray(); - } - - /** - * 获取列表 - * @param array $params - * @return array - */ - public function listData(array $params): array - { - [$page, $limit] = RequestUtils::getPageParameter(); - [$sortRule, $sortField] = RequestUtils::getSortParameter(); - $query = [ - 'delete_time' => 0 - ]; - if (isNotBlank($params['name'])) { - $query[] = ['name', 'like', '%' . $params['name'] . '%']; - } - if (isNotBlank($params['begin_time'])) { - $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; - } - if (isNotBlank($params['end_time'])) { - $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; - } - $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule"); - $count = $this->dao->getCount($query); - return compact('list', 'count'); - } - - /** - * 删除信息 - * @param mixed $id - * @return array - */ - public function deleteData(array $ids): array - { - // 落库 - Db::startTrans(); - try { - $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); - Db::commit(); - } catch (\Exception $exception) { - Db::rollback(); - throw new ApiException($exception->getMessage()); - } - return ['id' => $ids]; - } - - public function selectData() - { - $query = [ - 'delete_time' => 0 - ]; - $list = $this->dao->getList($query); - return $list; - } -} \ No newline at end of file diff --git a/app/service/meijianquan/ApiService.php b/app/service/meijianquan/ApiService.php new file mode 100644 index 0000000..80d6b46 --- /dev/null +++ b/app/service/meijianquan/ApiService.php @@ -0,0 +1,43 @@ +"35075", + "model_id"=>"1", + "limit"=>"300", + "page"=>"1" + ); + //加密 + $app_key = "de06270f3515bad109aa1fd2c023dd41"; + $data_info = serialize($data ); + $time_out = 60; + $iv = random_bytes(16); + $info['iv'] = base64_encode($iv); + $info['value'] = openssl_encrypt($data_info, 'AES-256-CBC', $app_key, 0, + base64_decode($info['iv'])); + $encrypt = base64_encode(json_encode($info)); + $sign = md5($encrypt); + $result = ['response' => $encrypt, 'sign' => $sign, 'app_key' => $app_key]; + //curl + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); + curl_setopt($ch, CURLOPT_TIMEOUT, $time_out); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $result); + $output = curl_exec($ch); + curl_close($ch); + return $output; + } +} \ No newline at end of file diff --git a/app/service/user/AiCommandService.php b/app/service/user/AiCommandService.php new file mode 100644 index 0000000..6fbb3a1 --- /dev/null +++ b/app/service/user/AiCommandService.php @@ -0,0 +1,131 @@ +dao = $dao; + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + $data = $this->dao->save($params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $data->toArray(); + } + + /** + * 修改信息 + * @param array $params + * @return array + */ + public function updateData(array $params): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update(['id' => $params['id']], $params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $params; + } + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['name'])) { + $query[] = ['name', 'like', '%' . $params['name'] . '%']; + } + if (isNotBlank($params['type'])) { + $query[] = ['type', '=', $params['type']]; + } + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, 'id,name,type,create_time', $page, $limit, "$sortField $sortRule"); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + /** + * 获取信息 + * @param mixed $id + * @return array + */ + public function readData(mixed $id): array + { + $aiCommand = $this->dao->get(['id' => $id]); + if (empty($aiCommand)) { + throw new ApiException('数据不存在'); + } + return $aiCommand->toArray(); + } + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + + public function selectData($type) + { + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($type)) { + $query[] = ['type', '=', $type]; + } + $list = $this->dao->getList($query); + return $list; + } +} \ No newline at end of file diff --git a/app/service/user/ArticleCategoryService.php b/app/service/user/ArticleCategoryService.php new file mode 100644 index 0000000..32cf453 --- /dev/null +++ b/app/service/user/ArticleCategoryService.php @@ -0,0 +1,125 @@ +dao = $dao; + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + $data = $this->dao->save($params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $data->toArray(); + } + + /** + * 修改信息 + * @param array $params + * @return array + */ + public function updateData(array $params): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update(['id' => $params['id']], $params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $params; + } + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['name'])) { + $query[] = ['name', 'like', '%' . $params['name'] . '%']; + } + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", [], ['article']); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + /** + * 获取信息 + * @param mixed $id + * @return array + */ + public function readData(mixed $id): array + { + $category = $this->dao->get(['id' => $id]); + if (empty($category)) { + throw new ApiException('数据不存在'); + } + return $category->toArray(); + } + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + + public function selectData() + { + $query = [ + 'delete_time' => 0 + ]; + $list = $this->dao->getList($query); + return $list; + } +} \ No newline at end of file diff --git a/app/service/user/CreationArticleService.php b/app/service/user/CreationArticleService.php new file mode 100644 index 0000000..ca3ee92 --- /dev/null +++ b/app/service/user/CreationArticleService.php @@ -0,0 +1,140 @@ +dao = $dao; + $this->articleCategoryDao = app()->make(ArticleCategoryDao::class); + $this->taskDao = app()->make(CreationTaskDao::class); + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + $data = $this->dao->save($params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $data->toArray(); + } + + /** + * 修改信息 + * @param array $params + * @return array + */ + public function updateData(array $params): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update(['id' => $params['id']], $params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $params; + } + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['article_category_id'])) { + $query[] = ['article_category_id', '=', $params['article_category_id']]; + } + if (isNotBlank($params['article_category'])) { + $cids = $this->articleCategoryDao->getColumn([['name', 'like', '%' . $params['article_category'] . '%']], 'id'); + $query[] = ['article_category_id', 'in', $cids]; + } + if (isNotBlank($params['task_id'])) { + $query[] = ['task_id', '=', $params['task_id']]; + } + if (isNotBlank($params['task'])) { + $tids = $this->taskDao->getColumn([['name', 'like', '%' . $params['task'] . '%']], 'id'); + $query[] = ['task_id', 'in', $tids]; + } + if (isNotBlank($params['title'])) { + $query[] = ['title', 'like', '%' . $params['title'] . '%']; + } + if (isNotBlank($params['status'])) { + $query[] = ['status', '=', $params['status']]; + } + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, 'id,title,status,create_time,article_category_id', $page, $limit, "$sortField $sortRule", ['category']); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + /** + * 获取信息 + * @param mixed $id + * @return array + */ + public function readData(mixed $id): array + { + $aiCommand = $this->dao->get(['id' => $id]); + if (empty($aiCommand)) { + throw new ApiException('数据不存在'); + } + return $aiCommand->toArray(); + } + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + +} \ No newline at end of file diff --git a/app/service/user/CreationTaskService.php b/app/service/user/CreationTaskService.php new file mode 100644 index 0000000..6842be8 --- /dev/null +++ b/app/service/user/CreationTaskService.php @@ -0,0 +1,149 @@ +dao = $dao; + $this->distillationDao = app()->make(DistillationWordDao::class); + $this->articleCategoryDao = app()->make(ArticleCategoryDao::class); + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + //同步创建文章分类,若存在则不创建 + $category = $this->articleCategoryDao->getOne([ + 'name' => $params['name'] + ]); + if (!$category) { + $category = $this->articleCategoryDao->save([ + 'name' => $params['name'] + ]); + } + $params['article_category_id'] = $category['id']; + if (isNotBlank($params['knowledge_ids'])) { + $params['knowledge_ids'] = implode(',', $params['knowledge_ids']); + } + $data = $this->dao->save($params); + Db::commit(); + //投递消息 + Redis::send('creation-task', ['task_id' => $data['id']]); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $data->toArray(); + } + + /** + * 修改信息 + * @param array $params + * @return array + */ + public function updateData(array $params): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update(['id' => $params['id']], $params); + Db::commit(); + //投递消息 + Redis::send('creation-task', ['task_id' => $params['id']]); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $params; + } + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['name'])) { + $query[] = ['name', 'like', '%' . $params['name'] . '%']; + } + if (isNotBlank($params['distillation_word'])) { + $ids = $this->distillationDao->getColumn([['name', 'like', '%' . $params['distillation_word'] . '%']], 'id'); + $query[] = ['distillation_id', 'in', $ids]; + } + if (isNotBlank($params['status'])) { + $query[] = ['status', '=', $params['status']]; + } + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", ['distillaction']); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + /** + * 获取信息 + * @param mixed $id + * @return array + */ + public function readData(mixed $id): array + { + $aiCommand = $this->dao->get(['id' => $id]); + if (empty($aiCommand)) { + throw new ApiException('数据不存在'); + } + $aiCommand['knowledge_ids'] = array_map('intval', explode(',', $aiCommand['knowledge_ids'])); + return $aiCommand->toArray(); + } + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + +} \ No newline at end of file diff --git a/app/service/user/DistillationQuestionsService.php b/app/service/user/DistillationQuestionsService.php new file mode 100644 index 0000000..c8a264b --- /dev/null +++ b/app/service/user/DistillationQuestionsService.php @@ -0,0 +1,131 @@ +dao = $dao; + $this->wordDao = app()->make(DistillationWordDao::class); + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + $questions = []; + foreach ($params['names'] as $item) { + $questions[] = [ + 'distillation_id' => $params['distillation_id'], + 'name' => $item + ]; + } + $this->dao->insertAll($questions); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $questions; + } + + /** + * 修改信息 + * @param array $params + * @return array + */ + public function updateData(array $params): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update(['id' => $params['id']], $params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $params; + } + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['word_name'])) { + $word_ids = $this->wordDao->getColumn([['name', 'like', '%' . $params['word_name'] . '%']], 'id'); + $query[] = ['distillation_id', 'in', $word_ids]; + } + if (isNotBlank($params['name'])) { + $query[] = ['name', 'like', '%' . $params['name'] . '%']; + } + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", ['distillation']); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + /** + * 获取信息 + * @param mixed $id + * @return array + */ + public function readData(mixed $id): array + { + $question = $this->dao->get(['id' => $id], ['*'], ['distillation']); + if (empty($question)) { + throw new ApiException('数据不存在'); + } + return $question->toArray(); + } + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + +} \ No newline at end of file diff --git a/app/service/user/DistillationWordService.php b/app/service/user/DistillationWordService.php new file mode 100644 index 0000000..c167394 --- /dev/null +++ b/app/service/user/DistillationWordService.php @@ -0,0 +1,222 @@ +dao = $dao; + $this->transDao = app()->make(DistillationTransWordDao::class); + $this->expandDao = app()->make(DistillationExpandWordDao::class); + $this->questionsDao = app()->make(DistillationQuestionsDao::class); + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + //保存主表 + $data = $this->dao->save([ + 'name' => $params['name'] + ]); + //保存目标转化此 + $trans_words = str_replace(',', ',', $params['trans_words']); + $trans_words = explode(',', $trans_words); + $trans = []; + foreach ($trans_words as $item) { + $trans[] = [ + 'distillation_id' => $data['id'], + 'name' => $item + ]; + } + $this->transDao->insertAll($trans); + //保存扩展此 + $expands = []; + foreach ($params['expand_words'] as $item) { + $expands[] = [ + 'distillation_id' => $data['id'], + 'name' => $item + ]; + } + $this->expandDao->insertAll($expands); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $data->toArray(); + } + + /** + * 修改信息 + * @param array $params + * @return array + */ + public function updateData(array $params): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update(['id' => $params['id']], $params); + //目标转化词,先删后加 + $this->transDao->delete(['distillation_id' => $params['id']]); + $trans_words = str_replace(',', ',', $params['trans_words']); + $trans_words = explode(',', $trans_words); + $trans = []; + foreach ($trans_words as $item) { + if (empty($item)) { + continue; + } + $trans[] = [ + 'distillation_id' => $params['id'], + 'name' => $item + ]; + } + $this->transDao->insertAll($trans); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $params; + } + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['name'])) { + $query[] = ['name', 'like', '%' . $params['name'] . '%']; + } + if (isNotBlank($params['drill_status'])) { + $query[] = ['drill_status', '=', $params['drill_status']]; + } + if (isNotBlank($params['algorithm'])) { + $query[] = ['algorithm', '=', $params['algorithm']]; + } + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", [], ['questions']); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + /** + * 获取信息 + * @param mixed $id + * @return array + */ + public function readData(mixed $id): array + { + $distillationWords = $this->dao->get(['id' => $id], ['*'], ['trans']); + if (empty($distillationWords)) { + throw new ApiException('数据不存在'); + } + $data = $distillationWords->toArray(); + $data['trans_str'] = implode(',', array_column($data['trans'], 'name')); + unset($data['trans']); + return $data; + } + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + //删主表 + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + //删子表 + $this->transDao->update([['distillation_id', 'in', $ids]], ['delete_time' => time()]); + $this->expandDao->update([['distillation_id', 'in', $ids]], ['delete_time' => time()]); + $this->questionsDao->update([['distillation_id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + + public function selectData() + { + $query = [ + 'delete_time' => 0 + ]; + $list = $this->dao->getList($query, '*', 0, 0, 'id DESC', [], ['questions']); + return $list; + } + + public function aiExtend($word) + { + $prompt = '- Role: 市场调研专家和品牌分析顾问 +- Background: 用户需要根据一个主关键词批量生成相关的拓展内容。例如,用户提供“洗地机品牌”,需要生成“市面上口碑好的洗地机品牌哪家好”等相关的拓展内容。这表明用户需要对某一领域的热门品牌进行深入了解和分析,以便获取有价值的信息。 +- Profile: 你是一位在市场调研和品牌分析领域有着丰富经验的专家,能够精准把握市场动态,提供权威的品牌分析和市场洞察。你熟悉各类产品的市场情况,能够根据用户提供的主关键词,快速生成相关的拓展内容。 +- Skills: 你具备市场调研能力、品牌分析技巧、数据收集与整理能力,以及对消费者口碑的敏锐洞察力。能够根据用户提供的主关键词,结合市场数据和消费者评价,生成有价值且具有参考意义的拓展内容。 +- Goals: 根据用户提供的主关键词,批量生成相关的拓展内容,如“市面上口碑好的洗地机品牌哪家好”,确保内容准确、权威且具有参考价值。 +- Constrains: 拓展内容必须与用户提供的主关键词相关,且基于市场调研和消费者评价,确保信息的真实性和可靠性。内容应简洁明了,避免冗长和复杂的表述。 +- OutputFormat: 输出格式为JSON格式,将生成的拓展内容放在`content`字段中,每个拓展内容独立成行,便于用户查看和使用。 +- Workflow: + 1. 接收用户提供的主关键词。 + 2. 根据主关键词,结合市场调研数据和消费者评价,生成相关的拓展内容,拓展内容数量在20以上,且不重复或相似。 + 3. 对生成的拓展内容进行审核和优化,确保内容准确、权威且具有参考价值。 + 4. 将拓展内容整合到JSON格式中,放在`content`字段中。 +- Examples: + - 假设用户提供的主关键词是“洗涤剂品牌”,生成的拓展内容如下: + ```json + { + "content": [ + "市面上口碑好的洗涤剂品牌有哪些?", + "洗涤剂品牌哪个好用又实惠?", + "推荐几款性价比高的洗涤剂品牌", + "洗涤剂品牌排行榜:哪些值得购买?", + "家用洗涤剂品牌,哪个更环保?", + "洗涤剂品牌对比:哪个更适合手洗?", + "洗涤剂品牌推荐:哪个适合敏感肌肤?", + "洗涤剂品牌测评:哪个去污力更强?", + "洗涤剂品牌选购指南:如何挑选?", + "洗涤剂品牌哪个更受欢迎?" + ] + },我提供的主关键词:' . $word; + $result = OpenAiClient::chat($prompt); + return $result['content']['content']; + } +} \ No newline at end of file diff --git a/app/service/user/EnterprisePortraitCategoryService.php b/app/service/user/EnterprisePortraitCategoryService.php new file mode 100644 index 0000000..262650f --- /dev/null +++ b/app/service/user/EnterprisePortraitCategoryService.php @@ -0,0 +1,131 @@ +dao = $dao; + $this->libraryDao = app()->make(EnterprisePortraitLibraryDao::class); + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + $data = $this->dao->save($params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $data->toArray(); + } + + /** + * 修改信息 + * @param array $params + * @return array + */ + public function updateData(array $params): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update(['id' => $params['id']], $params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $params; + } + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['name'])) { + $query[] = ['name', 'like', '%' . $params['name'] . '%']; + } + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", [], ['files']); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + /** + * 获取信息 + * @param mixed $id + * @return array + */ + public function readData(mixed $id): array + { + $category = $this->dao->get(['id' => $id]); + if (empty($category)) { + throw new ApiException('数据不存在'); + } + return $category->toArray(); + } + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + //删除表 + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + //删图库 + $this->libraryDao->update([['category_id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + + public function selectData() + { + $query = [ + 'delete_time' => 0 + ]; + $list = $this->dao->getList($query, '*', 0, 0, 'id DESC', [], ['files']); + return $list; + } +} \ No newline at end of file diff --git a/app/service/user/EnterprisePortraitLibraryService.php b/app/service/user/EnterprisePortraitLibraryService.php new file mode 100644 index 0000000..8ae0f2e --- /dev/null +++ b/app/service/user/EnterprisePortraitLibraryService.php @@ -0,0 +1,95 @@ +dao = $dao; + $this->categoryDao = app()->make(EnterprisePortraitCategoryDao::class); + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + $data = $this->dao->save($params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $data->toArray(); + } + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['category_id']) && empty($params['category'])) { + $query[] = ['category_id', '=', $params['category_id']]; + } + if (isNotBlank($params['category'])) { + $cids = $this->categoryDao->getColumn([['name', 'like', '%' . $params['category'] . '%']], 'id'); + $query[] = ['category_id', 'in', $cids]; + } + if (isNotBlank($params['use_count'])) { + $query[] = ['use_count', '=', $params['use_count']]; + } + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule", ['category']); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + +} \ No newline at end of file diff --git a/app/service/user/ExpiosiveReplicaService.php b/app/service/user/ExpiosiveReplicaService.php new file mode 100644 index 0000000..9ba9581 --- /dev/null +++ b/app/service/user/ExpiosiveReplicaService.php @@ -0,0 +1,108 @@ +dao = $dao; + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + $params['name'] = '全网爆文复刻[' . date('Y-m-d H:i') . ']'; + $data = $this->dao->save($params); + Db::commit(); + // 投递消息 + Redis::send('expiosive_replica', ['replica_id' => $data['id']]); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $data->toArray(); + } + + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, 'id,name,url,title,ai_time,status,status_msg', $page, $limit, "$sortField $sortRule"); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + /** + * 获取信息 + * @param mixed $id + * @return array + */ + public function readData(mixed $id): array + { + $replica = $this->dao->get(['id' => $id]); + if (empty($replica)) { + throw new ApiException('数据不存在'); + } + return $replica->toArray(); + } + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + + public function selectData() + { + $query = [ + 'delete_time' => 0 + ]; + $list = $this->dao->getList($query); + return $list; + } +} \ No newline at end of file diff --git a/app/service/user/GlobalProxyService.php b/app/service/user/GlobalProxyService.php new file mode 100644 index 0000000..271de4a --- /dev/null +++ b/app/service/user/GlobalProxyService.php @@ -0,0 +1,68 @@ +dao = $dao; + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function save(array $params): array + { + // 落库 + Db::startTrans(); + try { + $userInfo = RequestUtils::getUserInfo(); + $proxy = $this->dao->getOne(['uid' => $userInfo['id']]); + if ($proxy) { + $this->dao->update(['id' => $proxy['id']], $params); + } else { + $params['uid'] = $userInfo['id']; + $this->dao->save($params); + } + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $params; + } + + + /** + * 获取信息 + * @param mixed $id + * @return array + */ + public function readData(): array + { + $userInfo = RequestUtils::getUserInfo(); + $proxy = $this->dao->getOne(['uid' => $userInfo['id']]); + if (empty($proxy)) { + return [ + 'uid' => $userInfo['id'], + 'agent_ip' => '', + 'agent_pass' => '' + ]; + } + return $proxy->toArray(); + } + + +} \ No newline at end of file diff --git a/app/service/user/IndexService.php b/app/service/user/IndexService.php new file mode 100644 index 0000000..8968437 --- /dev/null +++ b/app/service/user/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 diff --git a/app/service/user/KnowledgeLibraryService.php b/app/service/user/KnowledgeLibraryService.php new file mode 100644 index 0000000..779809e --- /dev/null +++ b/app/service/user/KnowledgeLibraryService.php @@ -0,0 +1,92 @@ +dao = $dao; + } + + /** + * 保存信息 + * @param array $params + * @return array + */ + public function saveData(array $params): array + { + Db::startTrans(); + try { + $data = $this->dao->save($params); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return $data->toArray(); + } + + /** + * 获取列表 + * @param array $params + * @return array + */ + public function listData(array $params): array + { + [$page, $limit] = RequestUtils::getPageParameter(); + [$sortRule, $sortField] = RequestUtils::getSortParameter(); + $query = [ + 'delete_time' => 0 + ]; + if (isNotBlank($params['name'])) { + $query[] = ['name', 'like', '%' . $params['name'] . '%']; + } + if (isNotBlank($params['begin_time'])) { + $query[] = ['create_time', '>=', strtotime($params['begin_time'])]; + } + if (isNotBlank($params['end_time'])) { + $query[] = ['create_time', '<=', strtotime($params['end_time'] . ' 23:59:59')]; + } + $list = $this->dao->getList($query, '*', $page, $limit, "$sortField $sortRule"); + $count = $this->dao->getCount($query); + return compact('list', 'count'); + } + + /** + * 删除信息 + * @param mixed $id + * @return array + */ + public function deleteData(array $ids): array + { + // 落库 + Db::startTrans(); + try { + $this->dao->update([['id', 'in', $ids]], ['delete_time' => time()]); + Db::commit(); + } catch (\Exception $exception) { + Db::rollback(); + throw new ApiException($exception->getMessage()); + } + return ['id' => $ids]; + } + + public function selectData() + { + $query = [ + 'delete_time' => 0 + ]; + $list = $this->dao->getList($query); + return $list; + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 5804562..c6db195 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,8 @@ "ext-simplexml": "*", "ext-dom": "*", "webman/redis-queue": "^2.1", - "ext-curl": "*" + "ext-curl": "*", + "ext-openssl": "*" }, "suggest": { "ext-event": "For better performance. " diff --git a/composer.lock b/composer.lock index 0ebe724..09a795e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d2977073765d5166d7ae2431f3b3afa2", + "content-hash": "b4809669623ee48ba422c769b1b0cceb", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -7906,7 +7906,8 @@ "php": ">=8.1", "ext-simplexml": "*", "ext-dom": "*", - "ext-curl": "*" + "ext-curl": "*", + "ext-openssl": "*" }, "platform-dev": {}, "plugin-api-version": "2.6.0" diff --git a/config/route.php b/config/route.php index 6fb573a..8bd9d4a 100644 --- a/config/route.php +++ b/config/route.php @@ -16,6 +16,8 @@ use Webman\Route; // 引入业务 require_once base_path() . '/app/route/route.php'; +require_once base_path() . '/app/route/admin.php'; +require_once base_path() . '/app/route/proxy.php'; // 处理404路由 Route::fallback(function(){ diff --git a/plugin/piadmin/app/model/SystemDept.php b/plugin/piadmin/app/model/SystemDept.php index 89ff78a..30a876c 100644 --- a/plugin/piadmin/app/model/SystemDept.php +++ b/plugin/piadmin/app/model/SystemDept.php @@ -2,7 +2,6 @@ namespace plugin\piadmin\app\model; -use app\model\DistillationWord; use plugin\piadmin\app\base\BaseModel; use think\model\concern\SoftDelete;