正在显示
3 个修改的文件
包含
123 行增加
和
0 行删除
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AiBlogKeywordController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/11/4 14:35 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Bside\Ai; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Bside\BaseController; | ||
| 14 | +use App\Http\Logic\Bside\Ai\AiBlogKeywordLogic; | ||
| 15 | +use Illuminate\Http\Request; | ||
| 16 | + | ||
| 17 | +class AiBlogKeywordController extends BaseController | ||
| 18 | +{ | ||
| 19 | + public function __construct(Request $request) | ||
| 20 | + { | ||
| 21 | + parent::__construct($request); | ||
| 22 | + $this->logic = new AiBlogKeywordLogic(); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * @remark :获取关键词详情 | ||
| 27 | + * @name :getKeywordInfo | ||
| 28 | + * @author :lyh | ||
| 29 | + * @method :post | ||
| 30 | + * @time :2025/11/4 14:35 | ||
| 31 | + */ | ||
| 32 | + public function getKeywordInfo() | ||
| 33 | + { | ||
| 34 | + $this->request->validate([ | ||
| 35 | + 'project_id'=>['required'], | ||
| 36 | + ],[ | ||
| 37 | + 'project_id.required' => '项目ID不能为空', | ||
| 38 | + ]); | ||
| 39 | + $data = $this->logic->getKeywordInfo(); | ||
| 40 | + $this->response('success',Code::SUCCESS,$data); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * @remark :保存对应关键词 | ||
| 45 | + * @name :saveKeyword | ||
| 46 | + * @author :lyh | ||
| 47 | + * @method :post | ||
| 48 | + * @time :2025/11/4 14:35 | ||
| 49 | + */ | ||
| 50 | + public function saveKeyword() | ||
| 51 | + { | ||
| 52 | + $this->request->validate([ | ||
| 53 | + 'project_id'=>['required'], | ||
| 54 | + 'keywords'=>['required'], | ||
| 55 | + ],[ | ||
| 56 | + 'project_id.required' => '项目ID不能为空', | ||
| 57 | + 'keywords.required' => 'keywords不能为空', | ||
| 58 | + ]); | ||
| 59 | + $data = $this->logic->saveKeyword(); | ||
| 60 | + $this->response('success',Code::SUCCESS,$data); | ||
| 61 | + } | ||
| 62 | +} |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AiBlogKeywordLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/11/4 14:37 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Bside\Ai; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 13 | +use App\Models\Ai\AiBlogKeyword; | ||
| 14 | + | ||
| 15 | +class AiBlogKeywordLogic extends BaseLogic | ||
| 16 | +{ | ||
| 17 | + | ||
| 18 | + public function __construct() | ||
| 19 | + { | ||
| 20 | + parent::__construct(); | ||
| 21 | + $this->param = $this->requestAll; | ||
| 22 | + $this->model = new AiBlogKeyword(); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * @remark :获取当前详情 | ||
| 27 | + * @name :getKeywordInfo | ||
| 28 | + * @author :lyh | ||
| 29 | + * @method :post | ||
| 30 | + * @time :2025/11/4 14:39 | ||
| 31 | + */ | ||
| 32 | + public function getKeywordInfo() | ||
| 33 | + { | ||
| 34 | + $data = $this->model->read(['project_id'=>$this->param['project_id']]); | ||
| 35 | + return $this->success($data); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * @remark : | ||
| 40 | + * @name :saveKeyword | ||
| 41 | + * @author :lyh | ||
| 42 | + * @method :post | ||
| 43 | + * @time :2025/11/4 14:52 | ||
| 44 | + */ | ||
| 45 | + public function saveKeyword() | ||
| 46 | + { | ||
| 47 | + $data = $this->model->read(['project_id'=>$this->param['project_id']]); | ||
| 48 | + if($data !== false){ | ||
| 49 | + $id = $data['id']; | ||
| 50 | + $this->model->edit($this->param,['id'=>$id]); | ||
| 51 | + }else{ | ||
| 52 | + $id = $this->model->addReturnId($this->param); | ||
| 53 | + } | ||
| 54 | + return $this->success(['id'=>$id]); | ||
| 55 | + } | ||
| 56 | +} |
| @@ -777,6 +777,11 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -777,6 +777,11 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 777 | Route::any('/deleteFaq', [\App\Http\Controllers\Bside\Setting\SettingFaqController::class,'deleteFaq'])->name('faq_deleteFaq'); | 777 | Route::any('/deleteFaq', [\App\Http\Controllers\Bside\Setting\SettingFaqController::class,'deleteFaq'])->name('faq_deleteFaq'); |
| 778 | Route::any('/getInfo', [\App\Http\Controllers\Bside\Setting\SettingFaqController::class,'getInfo'])->name('faq_getInfo'); | 778 | Route::any('/getInfo', [\App\Http\Controllers\Bside\Setting\SettingFaqController::class,'getInfo'])->name('faq_getInfo'); |
| 779 | }); | 779 | }); |
| 780 | + //ai_blog随机关键词 | ||
| 781 | + Route::prefix('ai_blog_keyword')->group(function () { | ||
| 782 | + Route::any('/getKeywordInfo', [\App\Http\Controllers\Bside\Ai\AiBlogKeywordController::class,'getKeywordInfo'])->name('ai_blog_keyword_getKeywordInfo'); | ||
| 783 | + Route::any('/saveKeyword', [\App\Http\Controllers\Bside\Ai\AiBlogKeywordController::class,'saveKeyword'])->name('ai_blog_keyword_saveKeyword'); | ||
| 784 | + }); | ||
| 780 | }); | 785 | }); |
| 781 | //无需登录验证的路由组 | 786 | //无需登录验证的路由组 |
| 782 | Route::group([], function () { | 787 | Route::group([], function () { |
-
请 注册 或 登录 后发表评论