合并分支 'master-server' 到 'master'
Master server 查看合并请求 !1340
正在显示
3 个修改的文件
包含
220 行增加
和
42 行删除
| @@ -7,21 +7,18 @@ | @@ -7,21 +7,18 @@ | ||
| 7 | * @time :2023/11/20 15:07 | 7 | * @time :2023/11/20 15:07 |
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | -namespace App\Console\Commands\Test; | 10 | +namespace App\Console\Commands\LyhTest; |
| 11 | 11 | ||
| 12 | use App\Helper\Arr; | 12 | use App\Helper\Arr; |
| 13 | use App\Helper\Translate; | 13 | use App\Helper\Translate; |
| 14 | use App\Models\Blog\Blog; | 14 | use App\Models\Blog\Blog; |
| 15 | -use App\Models\CustomModule\CustomModuleCategory; | ||
| 16 | use App\Models\CustomModule\CustomModuleContent; | 15 | use App\Models\CustomModule\CustomModuleContent; |
| 17 | use App\Models\Product\CategoryRelated; | 16 | use App\Models\Product\CategoryRelated; |
| 18 | use App\Models\Product\Keyword; | 17 | use App\Models\Product\Keyword; |
| 19 | use App\Models\Product\Product; | 18 | use App\Models\Product\Product; |
| 20 | -use App\Models\Project\ProcessRecords; | ||
| 21 | use App\Models\Project\Project; | 19 | use App\Models\Project\Project; |
| 22 | use App\Models\RouteMap\RouteMap; | 20 | use App\Models\RouteMap\RouteMap; |
| 23 | -use App\Models\Template\BTemplate; | ||
| 24 | -use App\Models\Template\Setting; | 21 | +use App\Models\WebSetting\WebSetting; |
| 25 | use App\Services\ProjectServer; | 22 | use App\Services\ProjectServer; |
| 26 | use App\Utils\HttpUtils; | 23 | use App\Utils\HttpUtils; |
| 27 | use GuzzleHttp\Exception\GuzzleException; | 24 | use GuzzleHttp\Exception\GuzzleException; |
| @@ -61,46 +58,21 @@ class UpdateRoute extends Command | @@ -61,46 +58,21 @@ class UpdateRoute extends Command | ||
| 61 | * @time :2023/11/20 15:13 | 58 | * @time :2023/11/20 15:13 |
| 62 | */ | 59 | */ |
| 63 | public function handle(){ | 60 | public function handle(){ |
| 64 | - | ||
| 65 | - $data = $this->ceshi(); | ||
| 66 | - | ||
| 67 | - echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL; | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - /** | ||
| 71 | - * @remark :导入数据 | ||
| 72 | - * @name :importCustomModule | ||
| 73 | - * @author :lyh | ||
| 74 | - * @method :post | ||
| 75 | - * @time :2025/2/24 14:44 | ||
| 76 | - */ | ||
| 77 | - public function importCustomModule(){ | ||
| 78 | - | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - public function ceshi($api_no = null) | ||
| 82 | - { | ||
| 83 | - $key = 'extend_projects_list'; | ||
| 84 | - $data = Cache::get($key); | ||
| 85 | - if (!$data) { | ||
| 86 | - $api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php'; | ||
| 87 | - try { | ||
| 88 | - $data = HttpUtils::get($api_url, []); | ||
| 89 | - if ($data) { | ||
| 90 | - $data = Arr::s2a($data); | ||
| 91 | - Cache::put($key, $data, 4 * 3600); | ||
| 92 | - } | ||
| 93 | - } catch (\Exception | GuzzleException $e) { | ||
| 94 | - errorLog('复制站点项目获取失败', [], $e); | ||
| 95 | - return false; | 61 | + $projectModel = new Project(); |
| 62 | + $lists = $projectModel->list(['delete_status'=>0],'id',['id']); | ||
| 63 | + foreach ($lists as $v){ | ||
| 64 | + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | ||
| 65 | + ProjectServer::useProject($v['id']); | ||
| 66 | + $webSettingModel = new WebSetting(); | ||
| 67 | + $settingInfo = $webSettingModel->read(['project_id'=>$v['id']]); | ||
| 68 | + if($settingInfo !== false && ($settingInfo['anchor_num'] > 3)){ | ||
| 69 | + $webSettingModel->edit(['anchor_num'=>3],['project_id'=>$v['id']]); | ||
| 96 | } | 70 | } |
| 71 | + DB::disconnect('custom_mysql'); | ||
| 97 | } | 72 | } |
| 98 | - if ($api_no !== null) { | ||
| 99 | - $data = collect($data)->where('apino', $api_no)->first(); | ||
| 100 | - return $data ?: []; | ||
| 101 | - } | ||
| 102 | - return $data; | 73 | + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| 103 | } | 74 | } |
| 75 | + | ||
| 104 | /** | 76 | /** |
| 105 | * @remark :更新产品 | 77 | * @remark :更新产品 |
| 106 | * @name :updateProduct | 78 | * @name :updateProduct |
| @@ -9,9 +9,69 @@ | @@ -9,9 +9,69 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Http\Controllers\Bside\Ai; | 10 | namespace App\Http\Controllers\Bside\Ai; |
| 11 | 11 | ||
| 12 | +use App\Enums\Common\Code; | ||
| 12 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | +use App\Http\Logic\Bside\Ai\AiVideoLogic; | ||
| 15 | +use App\Models\Ai\AiVideo; | ||
| 13 | 16 | ||
| 14 | class AiVideoController extends BaseController | 17 | class AiVideoController extends BaseController |
| 15 | { | 18 | { |
| 19 | + /** | ||
| 20 | + * @remark :获取aiVideo列表 | ||
| 21 | + * @name :lists | ||
| 22 | + * @author :lyh | ||
| 23 | + * @method :post | ||
| 24 | + * @time :2025/3/5 14:12 | ||
| 25 | + */ | ||
| 26 | + public function lists(AiVideo $aiVideo){ | ||
| 27 | + $lists = $aiVideo->lists($this->map,$this->page,$this->row,'id',['id','keyword','new_title','route','image','task_id','status','created_at','updated_at']); | ||
| 28 | + if(!empty($lists) && !empty($lists['list'])){ | ||
| 29 | + foreach ($lists['list'] as $k => $v){ | ||
| 30 | + $v['image'] = getImageUrl($v['image']); | ||
| 31 | + if(!empty($v['route'])){ | ||
| 32 | + $v['route'] = $this->user['test_domain'] . 'video/' . $v['route']; | ||
| 33 | + } | ||
| 34 | + $lists['list'][$k] = $v; | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 38 | + } | ||
| 16 | 39 | ||
| 40 | + /** | ||
| 41 | + * @remark :获取详情 | ||
| 42 | + * @name :getInfo | ||
| 43 | + * @author :lyh | ||
| 44 | + * @method :post | ||
| 45 | + * @time :2025/3/5 14:22 | ||
| 46 | + */ | ||
| 47 | + public function getInfo(AiVideo $aiVideo){ | ||
| 48 | + $this->request->validate([ | ||
| 49 | + 'id'=>['required'], | ||
| 50 | + ],[ | ||
| 51 | + 'id.required' => '主键不能为空', | ||
| 52 | + ]); | ||
| 53 | + $info = $aiVideo->read(['id'=>$this->param['id']]); | ||
| 54 | + $info['image'] = getImageUrl($info['image']); | ||
| 55 | + $this->response('success',Code::SUCCESS,$info); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @remark :发布任务 | ||
| 60 | + * @name :sendTask | ||
| 61 | + * @author :lyh | ||
| 62 | + * @method :post | ||
| 63 | + * @time :2025/3/5 14:29 | ||
| 64 | + */ | ||
| 65 | + public function sendTask(AiVideoLogic $aiVideoLogic){ | ||
| 66 | + $this->request->validate([ | ||
| 67 | + 'keyword'=>['required'], | ||
| 68 | + 'type'=>['required'], | ||
| 69 | + ],[ | ||
| 70 | + 'keyword.required' => '关键字不能为空', | ||
| 71 | + 'type.required' => '场景不能为空', | ||
| 72 | + ]); | ||
| 73 | + //获取当前项目的ai_blog设置 | ||
| 74 | + $result = $aiVideoLogic->sendTask(); | ||
| 75 | + $this->response('success',Code::SUCCESS,$result); | ||
| 76 | + } | ||
| 17 | } | 77 | } |
app/Http/Logic/Bside/Ai/AiVideoLogic.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Http\Logic\Bside\Ai; | ||
| 4 | + | ||
| 5 | +use App\Helper\Translate; | ||
| 6 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 7 | +use App\Models\Ai\AiBlogAuthor; | ||
| 8 | +use App\Models\Ai\AiVideo; | ||
| 9 | +use App\Models\Project\AiBlogTask; | ||
| 10 | +use App\Models\Project\ProjectAiSetting; | ||
| 11 | +use App\Models\RouteMap\RouteMap; | ||
| 12 | +use App\Services\AiBlogService; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * @remark :视频模块 | ||
| 16 | + * @name :AiVideoLogic | ||
| 17 | + * @author :lyh | ||
| 18 | + * @method :post | ||
| 19 | + * @time :2025/3/5 14:11 | ||
| 20 | + */ | ||
| 21 | +class AiVideoLogic extends BaseLogic | ||
| 22 | +{ | ||
| 23 | + public function __construct() | ||
| 24 | + { | ||
| 25 | + parent::__construct(); | ||
| 26 | + $this->param = $this->requestAll; | ||
| 27 | + $this->model = new AiVideo(); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * @remark :获取配置信息 | ||
| 32 | + * @name :getProjectAiSetting | ||
| 33 | + * @author :lyh | ||
| 34 | + * @method :post | ||
| 35 | + * @time :2025/2/21 14:51 | ||
| 36 | + */ | ||
| 37 | + public function getProjectAiSetting(){ | ||
| 38 | + $projectAiSettingModel = new ProjectAiSetting(); | ||
| 39 | + $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 40 | + if($aiSettingInfo === false){ | ||
| 41 | + $this->fail('请先联系管理员开启Ai配置'); | ||
| 42 | + } | ||
| 43 | + return $aiSettingInfo; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * @remark :ai发布博客 | ||
| 48 | + * @name :blogSave | ||
| 49 | + * @author :lyh | ||
| 50 | + * @method :post | ||
| 51 | + * @time :2023/7/5 14:46 | ||
| 52 | + */ | ||
| 53 | + public function blogSave(){ | ||
| 54 | + try { | ||
| 55 | + if(!empty($this->param['image'])){ | ||
| 56 | + $this->param['image'] = str_replace_url($this->param['image']); | ||
| 57 | + } | ||
| 58 | + $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG, $this->param['id'], $this->user['project_id']); | ||
| 59 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 60 | + $aiSettingInfo = $this->getProjectAiSetting(); | ||
| 61 | + $aiBlogService = new AiBlogService(); | ||
| 62 | + $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 63 | + $aiBlogService->key = $aiSettingInfo['key']; | ||
| 64 | + $aiBlogService->updateDetail(['title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]); | ||
| 65 | + }catch (\Exception $e){ | ||
| 66 | + $this->fail('保存失败,请联系管理员'); | ||
| 67 | + } | ||
| 68 | + return $this->success(); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * @remark :编辑作者 | ||
| 73 | + * @name :saveAuthor | ||
| 74 | + * @author :lyh | ||
| 75 | + * @method :post | ||
| 76 | + * @time :2025/2/21 14:46 | ||
| 77 | + */ | ||
| 78 | + public function saveBlogAuthor(){ | ||
| 79 | + try { | ||
| 80 | + $aiAuthorModel = new AiBlogAuthor(); | ||
| 81 | + if(!empty($this->param['image'])){ | ||
| 82 | + $this->param['image'] = str_replace_url($this->param['image']); | ||
| 83 | + } | ||
| 84 | + $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']); | ||
| 85 | + $aiAuthorModel->edit($this->param,['id'=>$this->param['id']]); | ||
| 86 | + $aiBlogService = new AiBlogService(); | ||
| 87 | + $aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]); | ||
| 88 | + }catch (\Exception $e){ | ||
| 89 | + $this->fail('保存失败,请联系管理员'); | ||
| 90 | + } | ||
| 91 | + return $this->success(); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * @remark :发布任务 | ||
| 96 | + * @name :sendTask | ||
| 97 | + * @author :lyh | ||
| 98 | + * @method :post | ||
| 99 | + * @time :2025/2/14 10:28 | ||
| 100 | + * @detail :type=2/生成文章 type=3/更新列表页记录 | ||
| 101 | + * @detail :status=1/待执行 | ||
| 102 | + */ | ||
| 103 | + public function sendTask(){ | ||
| 104 | + $aiSettingInfo = $this->getProjectAiSetting(); | ||
| 105 | + $aiBlogService = new AiBlogService(); | ||
| 106 | + $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 107 | + $aiBlogService->key = $aiSettingInfo['key']; | ||
| 108 | + $aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en')); | ||
| 109 | + $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type'],'video'); | ||
| 110 | + if($result['status'] == 200){ | ||
| 111 | + $aiBlogTaskModel = new AiBlogTask(); | ||
| 112 | + $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>3,'task_id'=>$result['data']['task_id'],'status'=>1]); | ||
| 113 | + $this->model->addReturnId(['keyword'=>$this->param['keyword'],'status'=>1,'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id']]); | ||
| 114 | + } | ||
| 115 | + return $this->success(); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + /** | ||
| 119 | + * @remark :删除 | ||
| 120 | + * @name :blogDelete | ||
| 121 | + * @author :lyh | ||
| 122 | + * @method :post | ||
| 123 | + * @time :2025/2/20 18:21 | ||
| 124 | + */ | ||
| 125 | + public function blogDelete(){ | ||
| 126 | + try { | ||
| 127 | + $aiSettingInfo = $this->getProjectAiSetting(); | ||
| 128 | + $aiBlogService = new AiBlogService(); | ||
| 129 | + foreach ($this->param['ids'] as $id) { | ||
| 130 | + $info = $this->model->read(['id'=>$id],['task_id']); | ||
| 131 | + $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 132 | + $aiBlogService->key = $aiSettingInfo['key']; | ||
| 133 | + $aiBlogService->delDetail($info['task_id']); | ||
| 134 | + //删除路由映射 | ||
| 135 | + RouteMap::delRoute(RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']); | ||
| 136 | + $this->model->del(['id'=>$id]); | ||
| 137 | + } | ||
| 138 | + shell_exec('php artisan save_ai_blog_list '.$this->user['project_id'].' > /dev/null 2>&1 &'); | ||
| 139 | + }catch (\Exception $e){ | ||
| 140 | + $this->fail('删除失败'); | ||
| 141 | + } | ||
| 142 | + return $this->success(); | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + | ||
| 146 | +} |
-
请 注册 或 登录 后发表评论