Merge remote-tracking branch 'origin/master' into akun
正在显示
8 个修改的文件
包含
265 行增加
和
47 行删除
| @@ -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,37 @@ class UpdateRoute extends Command | @@ -61,46 +58,37 @@ 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 | - | 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){ | ||
| 69 | + echo date('Y-m-d H:i:s') . '当前项目的设置数据不存在:'.$v['id'] . PHP_EOL; | ||
| 70 | + continue; | ||
| 79 | } | 71 | } |
| 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); | 72 | + if($settingInfo !== false){ |
| 73 | + if(empty($settingInfo['anchor_setting'])){ | ||
| 74 | + $settingInfo['anchor_setting'] = '["3","4","5"]'; | ||
| 92 | } | 75 | } |
| 93 | - } catch (\Exception | GuzzleException $e) { | ||
| 94 | - errorLog('复制站点项目获取失败', [], $e); | ||
| 95 | - return false; | 76 | + if(empty($settingInfo['anchor_page_num'])){ |
| 77 | + $settingInfo['anchor_page_num'] = 1; | ||
| 96 | } | 78 | } |
| 79 | + $data = [ | ||
| 80 | + 'anchor_setting'=>$settingInfo['anchor_setting'], | ||
| 81 | + 'anchor_is_enable'=>1, | ||
| 82 | + 'anchor_page_num'=>$settingInfo['anchor_page_num'], | ||
| 83 | + 'anchor_keyword_is_enable'=>1 | ||
| 84 | + ]; | ||
| 85 | + $webSettingModel->edit($data,['project_id'=>$v['id']]); | ||
| 97 | } | 86 | } |
| 98 | - if ($api_no !== null) { | ||
| 99 | - $data = collect($data)->where('apino', $api_no)->first(); | ||
| 100 | - return $data ?: []; | 87 | + DB::disconnect('custom_mysql'); |
| 101 | } | 88 | } |
| 102 | - return $data; | 89 | + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| 103 | } | 90 | } |
| 91 | + | ||
| 104 | /** | 92 | /** |
| 105 | * @remark :更新产品 | 93 | * @remark :更新产品 |
| 106 | * @name :updateProduct | 94 | * @name :updateProduct |
| @@ -97,11 +97,11 @@ class UpdateSeoTdk extends Command | @@ -97,11 +97,11 @@ class UpdateSeoTdk extends Command | ||
| 97 | 'ai_blog_meta_keywords' => 'seo_keyword', | 97 | 'ai_blog_meta_keywords' => 'seo_keyword', |
| 98 | 'ai_blog_meta_description' => 'seo_description', | 98 | 'ai_blog_meta_description' => 'seo_description', |
| 99 | ], | 99 | ], |
| 100 | - 'gl_ai_blog_list' => [ | ||
| 101 | - 'ai_blog_cat_title' => 'seo_title', | ||
| 102 | - 'ai_blog_cat_meta_keywords' => 'seo_keyword', | ||
| 103 | - 'ai_blog_cat_meta_description' => 'seo_description', | ||
| 104 | - ], | 100 | +// 'gl_ai_blog_list' => [ |
| 101 | +// 'ai_blog_cat_title' => 'seo_title', | ||
| 102 | +// 'ai_blog_cat_meta_keywords' => 'seo_keyword', | ||
| 103 | +// 'ai_blog_cat_meta_description' => 'seo_description', | ||
| 104 | +// ], | ||
| 105 | 'gl_ai_blog_author' => [ | 105 | 'gl_ai_blog_author' => [ |
| 106 | 'ai_blog_author_title' => 'seo_title', | 106 | 'ai_blog_author_title' => 'seo_title', |
| 107 | 'ai_blog_author_meta_keywords' => 'seo_keyword', | 107 | 'ai_blog_author_meta_keywords' => 'seo_keyword', |
| @@ -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 | + } | ||
| 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 | + } | ||
| 16 | 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 | } |
| @@ -50,7 +50,7 @@ class ProductController extends BaseController | @@ -50,7 +50,7 @@ class ProductController extends BaseController | ||
| 50 | { | 50 | { |
| 51 | $filed = ['id', 'project_id', 'title', 'sort' ,'thumb' ,'product_type' , 'route' , | 51 | $filed = ['id', 'project_id', 'title', 'sort' ,'thumb' ,'product_type' , 'route' , |
| 52 | 'category_id', 'keyword_id', 'status', 'created_uid', 'is_upgrade' ,'created_at', 'updated_at','six_read']; | 52 | 'category_id', 'keyword_id', 'status', 'created_uid', 'is_upgrade' ,'created_at', 'updated_at','six_read']; |
| 53 | - $this->order = $this->order ?? 'sort'; | 53 | + $this->order = $this->param['order'] ?? 'sort'; |
| 54 | $query = $product->orderBy($this->order ,$this->order_type)->orderBy('id','desc'); | 54 | $query = $product->orderBy($this->order ,$this->order_type)->orderBy('id','desc'); |
| 55 | $query = $this->searchParam($query); | 55 | $query = $this->searchParam($query); |
| 56 | $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); | 56 | $lists = $query->select($filed)->paginate($this->row, ['*'], 'page', $this->page); |
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 | +} |
| @@ -64,7 +64,7 @@ class WebSettingTextLogic extends BaseLogic | @@ -64,7 +64,7 @@ class WebSettingTextLogic extends BaseLogic | ||
| 64 | $this->param['anchor_keyword_is_enable'] = 0; | 64 | $this->param['anchor_keyword_is_enable'] = 0; |
| 65 | } | 65 | } |
| 66 | $data = [ | 66 | $data = [ |
| 67 | - 'anchor_setting'=>$this->param['anchor_setting'], | 67 | + 'anchor_setting'=>$this->param['anchor_setting'] ?? [], |
| 68 | 'anchor_is_enable'=>$this->param['anchor_is_enable'], | 68 | 'anchor_is_enable'=>$this->param['anchor_is_enable'], |
| 69 | 'anchor_num'=>$this->param['anchor_num'] ?? 0, | 69 | 'anchor_num'=>$this->param['anchor_num'] ?? 0, |
| 70 | 'anchor_page_num'=>$this->param['anchor_page_num'] ?? 0, | 70 | 'anchor_page_num'=>$this->param['anchor_page_num'] ?? 0, |
| @@ -37,7 +37,7 @@ class UserLoginLogic | @@ -37,7 +37,7 @@ class UserLoginLogic | ||
| 37 | */ | 37 | */ |
| 38 | public function login(){ | 38 | public function login(){ |
| 39 | //先验证手机号是否在项目中存在 | 39 | //先验证手机号是否在项目中存在 |
| 40 | - $info = $this->model->list(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','is_password']); | 40 | + $info = $this->model->read(['mobile'=>$this->param['mobile'],'status'=>$this->model::STATUS_ZERO],['id','is_password','project_id']); |
| 41 | if($info === false){ | 41 | if($info === false){ |
| 42 | $this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE); | 42 | $this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE); |
| 43 | } | 43 | } |
app/Models/Ai/AiVideo.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AiVideo.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/3/5 14:03 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Ai; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * @remark :ai视频 | ||
| 16 | + * @name :AiVideo | ||
| 17 | + * @author :lyh | ||
| 18 | + * @method :post | ||
| 19 | + * @time :2025/3/5 14:04 | ||
| 20 | + */ | ||
| 21 | +class AiVideo extends Base | ||
| 22 | +{ | ||
| 23 | + protected $table = 'gl_ai_video'; | ||
| 24 | +} |
-
请 注册 或 登录 后发表评论