Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
16 个修改的文件
包含
477 行增加
和
8 行删除
app/Console/Commands/Ai/AiBlogAuthorId.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AiBlogAuthorId.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/5/26 15:57 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Ai; | ||
| 11 | + | ||
| 12 | +use App\Models\Domain\DomainInfo; | ||
| 13 | +use App\Models\Project\AiBlogTask as AiBlogTaskModel; | ||
| 14 | +use App\Models\Ai\AiBlogAuthor as AiBlogAuthorModel; | ||
| 15 | +use App\Services\AiBlogService; | ||
| 16 | +use App\Services\ProjectServer; | ||
| 17 | +use Illuminate\Console\Command; | ||
| 18 | +use Illuminate\Support\Facades\DB; | ||
| 19 | +use Illuminate\Support\Facades\Redis; | ||
| 20 | + | ||
| 21 | +class AiBlogAuthorId extends Command | ||
| 22 | +{ | ||
| 23 | + /** | ||
| 24 | + * The name and signature of the console command. | ||
| 25 | + * | ||
| 26 | + * @var string | ||
| 27 | + */ | ||
| 28 | + protected $signature = 'save_ai_blog_author_id'; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * The console command description. | ||
| 32 | + * | ||
| 33 | + * @var string | ||
| 34 | + */ | ||
| 35 | + protected $description = '拉取对应作者的页面'; | ||
| 36 | + | ||
| 37 | + public $route = []; | ||
| 38 | + | ||
| 39 | + public function handle(){ | ||
| 40 | + while (true){ | ||
| 41 | + //获取任务id | ||
| 42 | + $task_id = $this->getTaskId(); | ||
| 43 | + if(empty($task_id)){ | ||
| 44 | + sleep(300); | ||
| 45 | + continue; | ||
| 46 | + } | ||
| 47 | + $this->_action($task_id); | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public function getTaskId() | ||
| 52 | + { | ||
| 53 | + $task_id = Redis::rpop('ai_blog_author_id'); | ||
| 54 | + if (empty($task_id)) { | ||
| 55 | + $aiBlogTaskModel = new AiBlogTaskModel(); | ||
| 56 | + $ids = $aiBlogTaskModel->formatQuery(['status'=>$aiBlogTaskModel::STATUS_RUNNING, 'type'=>$aiBlogTaskModel::TYPE_AUTHOR_ID])->pluck('id'); | ||
| 57 | + if(!empty($ids)){ | ||
| 58 | + foreach ($ids as $id) { | ||
| 59 | + Redis::lpush('ai_blog_author_id', $id); | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + $task_id = Redis::rpop('ai_blog_author_id'); | ||
| 63 | + } | ||
| 64 | + return $task_id; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * @remark :执行方法 | ||
| 69 | + * @name :_action | ||
| 70 | + * @author :lyh | ||
| 71 | + * @method :post | ||
| 72 | + * @time :2025/5/26 16:06 | ||
| 73 | + */ | ||
| 74 | + public function _action($task_id){ | ||
| 75 | + $aiBlogTaskModel = new AiBlogTaskModel(); | ||
| 76 | + $item = $aiBlogTaskModel->read(['id'=>$task_id]); | ||
| 77 | + if($item === false){ | ||
| 78 | + echo '当前数据不存在.'.$item['id'].PHP_EOL; | ||
| 79 | + return true; | ||
| 80 | + } | ||
| 81 | + $aiBlogService = new AiBlogService($item['project_id']); | ||
| 82 | + ProjectServer::useProject($item['project_id']); | ||
| 83 | + $aiBlogService->author_id = $item['task_id']; | ||
| 84 | + $result = $aiBlogService->getAuthorDetail(); | ||
| 85 | + if(isset($result['status']) && $result['status'] == 200){ | ||
| 86 | + //当前作者的页面 | ||
| 87 | + $aiBlogAuthorModel = new AiBlogAuthorModel(); | ||
| 88 | + $authorInfo = $aiBlogAuthorModel->read(['author_id'=>$item['task_id']],['id','route']); | ||
| 89 | + if($authorInfo !== false && !empty($result['data']['section'])){ | ||
| 90 | + $this->route[] = $authorInfo['route']; | ||
| 91 | + $aiBlogAuthorModel->edit(['text'=>$result['data']['section']],['author_id'=>$item['task_id']]); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + DB::disconnect('custom_mysql'); | ||
| 95 | + $aiBlogTaskModel->edit(['status'=>2],['id'=>$task_id]); | ||
| 96 | + $this->sendCPost($item['project_id']); | ||
| 97 | + return true; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * @remark :通知C端 | ||
| 102 | + * @name :sendCPost | ||
| 103 | + * @author :lyh | ||
| 104 | + * @method :post | ||
| 105 | + * @time :2025/5/26 16:21 | ||
| 106 | + */ | ||
| 107 | + public function sendCPost($project_id){ | ||
| 108 | + $domainModel = new DomainInfo(); | ||
| 109 | + $domain = $domainModel->getProjectIdDomain($project_id); | ||
| 110 | + $c_url = $domain.'api/update_page/'; | ||
| 111 | + $param = [ | ||
| 112 | + 'project_id' => $project_id, | ||
| 113 | + 'type' => 1, | ||
| 114 | + 'route' => 3, | ||
| 115 | + 'url' => $this->route, | ||
| 116 | + 'language'=> [], | ||
| 117 | + 'is_sitemap' => 0 | ||
| 118 | + ]; | ||
| 119 | + $res = http_post($c_url, json_encode($param,true)); | ||
| 120 | + echo 'notify: project id: ' . $project_id . ', result: ' . json_encode($res,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | ||
| 121 | + } | ||
| 122 | +} |
| @@ -42,7 +42,8 @@ class RemainDay extends Command | @@ -42,7 +42,8 @@ class RemainDay extends Command | ||
| 42 | 1703, | 42 | 1703, |
| 43 | 1893, | 43 | 1893, |
| 44 | 2066, | 44 | 2066, |
| 45 | - 2250 | 45 | + 2250, |
| 46 | + 2193 | ||
| 46 | ];//需要单独处理的项目 | 47 | ];//需要单独处理的项目 |
| 47 | /** | 48 | /** |
| 48 | * The console command description. | 49 | * The console command description. |
| @@ -54,7 +54,6 @@ class lyhDemo extends Command | @@ -54,7 +54,6 @@ class lyhDemo extends Command | ||
| 54 | protected $description = '更新路由'; | 54 | protected $description = '更新路由'; |
| 55 | 55 | ||
| 56 | public function handle(){ | 56 | public function handle(){ |
| 57 | - $this->_actionTemplateMain(); | ||
| 58 | return true; | 57 | return true; |
| 59 | } | 58 | } |
| 60 | 59 | ||
| @@ -71,7 +70,7 @@ class lyhDemo extends Command | @@ -71,7 +70,7 @@ class lyhDemo extends Command | ||
| 71 | $count = $categoryModel->counts(['id'=>['>',0]]); | 70 | $count = $categoryModel->counts(['id'=>['>',0]]); |
| 72 | if(($info === false) && ($count > 0)){ | 71 | if(($info === false) && ($count > 0)){ |
| 73 | $mainModel = new TemplateTypeMain(); | 72 | $mainModel = new TemplateTypeMain(); |
| 74 | - $mainInfo = $mainModel->read(['type'=>2,'is_list'=>1,'is_custom'=>0]); | 73 | + $mainInfo = $mainModel->read(['type'=>2,'is_list'=>1]); |
| 75 | $main_html = $mainInfo['main_html']; | 74 | $main_html = $mainInfo['main_html']; |
| 76 | $main_css = "<style id='globalsojs-styles'></style>"; | 75 | $main_css = "<style id='globalsojs-styles'></style>"; |
| 77 | //写入一条初始数据 | 76 | //写入一条初始数据 |
| @@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
| 8 | namespace App\Console\Commands\Monitor; | 8 | namespace App\Console\Commands\Monitor; |
| 9 | 9 | ||
| 10 | use App\Models\Domain\DomainInfo; | 10 | use App\Models\Domain\DomainInfo; |
| 11 | +use App\Models\PackDir\SitePackTask; | ||
| 11 | use App\Models\Product\Keyword; | 12 | use App\Models\Product\Keyword; |
| 12 | use App\Models\Project\DeployOptimize; | 13 | use App\Models\Project\DeployOptimize; |
| 13 | use App\Models\Project\OnlineCheck; | 14 | use App\Models\Project\OnlineCheck; |
| @@ -183,7 +184,7 @@ class Supervisory extends Command | @@ -183,7 +184,7 @@ class Supervisory extends Command | ||
| 183 | $ids = Project::leftJoin('gl_project_deploy_optimize as b', 'gl_project.id', '=', 'b.project_id') | 184 | $ids = Project::leftJoin('gl_project_deploy_optimize as b', 'gl_project.id', '=', 'b.project_id') |
| 184 | ->leftJoin('gl_project_online_check as c', 'gl_project.id', '=', 'c.project_id') | 185 | ->leftJoin('gl_project_online_check as c', 'gl_project.id', '=', 'c.project_id') |
| 185 | ->leftJoin('gl_domain_info as d', 'gl_project.id', '=', 'd.project_id') | 186 | ->leftJoin('gl_domain_info as d', 'gl_project.id', '=', 'd.project_id') |
| 186 | - ->where('gl_project_deploy_optimize.domain','!=',0) | 187 | + ->where('b.domain','!=',0) |
| 187 | ->where('gl_project.type', Project::TYPE_TWO) | 188 | ->where('gl_project.type', Project::TYPE_TWO) |
| 188 | ->where('gl_project.extend_type', 0) // 是否续费是由extend_type字段控制 | 189 | ->where('gl_project.extend_type', 0) // 是否续费是由extend_type字段控制 |
| 189 | ->where('gl_project.delete_status', Project::IS_DEL_FALSE) | 190 | ->where('gl_project.delete_status', Project::IS_DEL_FALSE) |
| @@ -296,6 +297,14 @@ class Supervisory extends Command | @@ -296,6 +297,14 @@ class Supervisory extends Command | ||
| 296 | $message[] = '404页面链接: ' . implode(' 、 ', $page_404); | 297 | $message[] = '404页面链接: ' . implode(' 、 ', $page_404); |
| 297 | $message[] = 'TDK错误链接: ' . implode(' 、 ', $tdk_error); | 298 | $message[] = 'TDK错误链接: ' . implode(' 、 ', $tdk_error); |
| 298 | 299 | ||
| 300 | + //前一天页面生成失败白帽项目 | ||
| 301 | + $last_day = date('Y-m-d',strtotime('-1 day')); | ||
| 302 | + $white_project_ids = SitePackTask::where('status',SitePackTask::STATUS_FAL)->where('user_id',0)->whereBetween('created_at', [$last_day.' 00:00:00',$last_day.' 23:59:59'])->pluck('project_id')->toArray(); | ||
| 303 | + if($white_project_ids){ | ||
| 304 | + $white_domain_list = DomainInfo::whereIn('project_id',$white_project_ids)->pluck('domain')->toArray(); | ||
| 305 | + $message[] = '页面生成失败白帽项目: ' . implode(' 、 ', $white_domain_list); | ||
| 306 | + } | ||
| 307 | + | ||
| 299 | $msg = implode(PHP_EOL, $message); | 308 | $msg = implode(PHP_EOL, $message); |
| 300 | 309 | ||
| 301 | $link = 'https://oapi.dingtalk.com/robot/send?access_token=3927b42d072972fcf572e7b01728bf3e1390e08094d6f77c5f28bfd85b19f09f'; | 310 | $link = 'https://oapi.dingtalk.com/robot/send?access_token=3927b42d072972fcf572e7b01728bf3e1390e08094d6f77c5f28bfd85b19f09f'; |
| @@ -13,6 +13,7 @@ use App\Models\Ai\AiLog; | @@ -13,6 +13,7 @@ use App\Models\Ai\AiLog; | ||
| 13 | use App\Models\Project\DeployOptimize; | 13 | use App\Models\Project\DeployOptimize; |
| 14 | use App\Models\Project\Project; | 14 | use App\Models\Project\Project; |
| 15 | use App\Models\Project\ProjectKeyword; | 15 | use App\Models\Project\ProjectKeyword; |
| 16 | +use App\Services\AiCommandService; | ||
| 16 | use Illuminate\Support\Facades\Cache; | 17 | use Illuminate\Support\Facades\Cache; |
| 17 | 18 | ||
| 18 | class AiCommandController extends BaseController | 19 | class AiCommandController extends BaseController |
| @@ -70,4 +71,70 @@ class AiCommandController extends BaseController | @@ -70,4 +71,70 @@ class AiCommandController extends BaseController | ||
| 70 | return $aiLog->add($param); | 71 | return $aiLog->add($param); |
| 71 | } | 72 | } |
| 72 | 73 | ||
| 74 | + /** | ||
| 75 | + * @remark :获取排版指令 | ||
| 76 | + * @name :getAiTypesetting | ||
| 77 | + * @author :lyh | ||
| 78 | + * @method :post | ||
| 79 | + * @time :2025/5/26 17:11 | ||
| 80 | + */ | ||
| 81 | + public function getLayoutDesignInfo(){ | ||
| 82 | + $aiCommonModel = new AiCommand(); | ||
| 83 | + $data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']],['key','ai']); | ||
| 84 | + if($data === false){ | ||
| 85 | + $data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0],['key','ai']); | ||
| 86 | + } | ||
| 87 | + $this->response('success', Code::SUCCESS, $data); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * @remark :保存指令 | ||
| 92 | + * @name :saveAiCommand | ||
| 93 | + * @author :lyh | ||
| 94 | + * @method :post | ||
| 95 | + * @time :2025/5/26 17:15 | ||
| 96 | + */ | ||
| 97 | + public function saveLayoutDesign(){ | ||
| 98 | + $this->request->validate([ | ||
| 99 | + 'ai'=>['required'], | ||
| 100 | + ],[ | ||
| 101 | + 'ai.required' => '指令不能为空', | ||
| 102 | + ]); | ||
| 103 | + $aiCommonModel = new AiCommand(); | ||
| 104 | + $data = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']],['id']); | ||
| 105 | + if($data === false) { | ||
| 106 | + $param = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0],['name','key']); | ||
| 107 | + $param['project_id'] = $this->user['project_id']; | ||
| 108 | + $param['ai'] = $this->param['ai']; | ||
| 109 | + $id = $aiCommonModel->addReturnId($param); | ||
| 110 | + }else{ | ||
| 111 | + $id = $data['id']; | ||
| 112 | + $aiCommonModel->edit(['ai'=>$this->param['ai']],['id'=>$data['id']]); | ||
| 113 | + } | ||
| 114 | + $this->response('success', Code::SUCCESS, ['id'=>$id]); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * @remark :根据指令获取内容 | ||
| 119 | + * @name :sendLayoutDesign | ||
| 120 | + * @author :lyh | ||
| 121 | + * @method :post | ||
| 122 | + * @time :2025/5/26 17:39 | ||
| 123 | + */ | ||
| 124 | + public function sendLayoutDesign(){ | ||
| 125 | + $this->request->validate([ | ||
| 126 | + 'html'=>['required'] | ||
| 127 | + ],[ | ||
| 128 | + 'html.required' => 'html不能为空', | ||
| 129 | + ]); | ||
| 130 | + $aiCommonModel = new AiCommand(); | ||
| 131 | + $info = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']],['ai']); | ||
| 132 | + if($info === false){ | ||
| 133 | + $info = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0],['ai']); | ||
| 134 | + } | ||
| 135 | + $aiCommandService = new AiCommandService(); | ||
| 136 | + $ai = str_replace('{html}',$this->param['html'],$info['ai']); | ||
| 137 | + $result = $aiCommandService->send_layout_design($ai); | ||
| 138 | + $this->response('success', Code::SUCCESS, $result); | ||
| 139 | + } | ||
| 73 | } | 140 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :NewsExtendController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/5/26 15:05 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Bside\News; | ||
| 11 | + | ||
| 12 | +use App\Http\Controllers\Bside\BaseController; | ||
| 13 | +use App\Http\Logic\Bside\News\NewsExtendLogic; | ||
| 14 | +use App\Models\News\NewsExtend; | ||
| 15 | +use Illuminate\Http\Request; | ||
| 16 | + | ||
| 17 | +class NewsExtendController extends BaseController | ||
| 18 | +{ | ||
| 19 | + public function __construct(Request $request) | ||
| 20 | + { | ||
| 21 | + parent::__construct($request); | ||
| 22 | + $this->logic = new NewsExtendLogic(); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * @remark :获取所有扩展字段 | ||
| 27 | + * @name :lists | ||
| 28 | + * @author :lyh | ||
| 29 | + * @method :post | ||
| 30 | + * @time :2025/5/26 15:08 | ||
| 31 | + */ | ||
| 32 | + public function lists() | ||
| 33 | + { | ||
| 34 | + $lists = $this->logic->list($this->map); | ||
| 35 | + $this->response('success', Code::SUCCESS, $lists); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * @remark :保存扩展字段 | ||
| 40 | + * @name :save | ||
| 41 | + * @author :lyh | ||
| 42 | + * @method :post | ||
| 43 | + * @time :2025/5/26 15:09 | ||
| 44 | + */ | ||
| 45 | + public function save() | ||
| 46 | + { | ||
| 47 | + $this->request->validate([ | ||
| 48 | + 'title' => 'required', | ||
| 49 | + 'type' => 'required', | ||
| 50 | + ], [ | ||
| 51 | + 'title.required' => '字段名称不能为空', | ||
| 52 | + 'type.required' => '字段类型不能为空', | ||
| 53 | + ]); | ||
| 54 | + $data = $this->logic->extendSave(); | ||
| 55 | + $this->response('success', Code::SUCCESS, $data); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * @remark :删除扩展字段 | ||
| 60 | + * @name :del | ||
| 61 | + * @author :lyh | ||
| 62 | + * @method :post | ||
| 63 | + * @time :2025/5/26 15:43 | ||
| 64 | + */ | ||
| 65 | + public function del(){ | ||
| 66 | + $this->request->validate([ | ||
| 67 | + 'id' => 'required', | ||
| 68 | + ], [ | ||
| 69 | + 'id.required' => '主键不能为空', | ||
| 70 | + ]); | ||
| 71 | + $data = $this->logic->extendDel(); | ||
| 72 | + $this->response('success', Code::SUCCESS, $data); | ||
| 73 | + } | ||
| 74 | +} |
| @@ -92,6 +92,8 @@ class AiBlogLogic extends BaseLogic | @@ -92,6 +92,8 @@ class AiBlogLogic extends BaseLogic | ||
| 92 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 92 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 93 | $aiBlogService->key = $aiSettingInfo['key']; | 93 | $aiBlogService->key = $aiSettingInfo['key']; |
| 94 | $aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'route'=>$this->param['route'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]); | 94 | $aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'route'=>$this->param['route'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]); |
| 95 | + $aiBlogTask = new AiBlogTask(); | ||
| 96 | + $aiBlogTask->addReturnId(['type'=>$aiBlogTask::TYPE_AUTHOR_ID,'task_id'=>$this->param['author_id'],'status'=>1,'project_id'=>$this->user['project_id']]); | ||
| 95 | }catch (\Exception $e){ | 97 | }catch (\Exception $e){ |
| 96 | $this->fail('保存失败,请联系管理员'); | 98 | $this->fail('保存失败,请联系管理员'); |
| 97 | } | 99 | } |
| @@ -52,7 +52,7 @@ class CustomTemplateLogic extends BaseLogic | @@ -52,7 +52,7 @@ class CustomTemplateLogic extends BaseLogic | ||
| 52 | $info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']); | 52 | $info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']); |
| 53 | if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ | 53 | if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ |
| 54 | $template_id = $this->getTemplateId(); | 54 | $template_id = $this->getTemplateId(); |
| 55 | - $html = $this->getTemplateComHtml($info['html'],$info['html_style'],$template_id); | 55 | + $html = $this->getTemplateComHtml(empty($info['html']) ? $info['text'] : $info['html'],$info['html_style'],$template_id); |
| 56 | $info['html'] = $this->getHeadFooter($html); | 56 | $info['html'] = $this->getHeadFooter($html); |
| 57 | } | 57 | } |
| 58 | return $this->success($info); | 58 | return $this->success($info); |
| @@ -555,6 +555,7 @@ class CustomTemplateLogic extends BaseLogic | @@ -555,6 +555,7 @@ class CustomTemplateLogic extends BaseLogic | ||
| 555 | 'is_visualization' => $info['is_visualization'], | 555 | 'is_visualization' => $info['is_visualization'], |
| 556 | 'created_at' => date('Y-m-d H:i:s'), | 556 | 'created_at' => date('Y-m-d H:i:s'), |
| 557 | 'updated_at' => date('Y-m-d H:i:s'), | 557 | 'updated_at' => date('Y-m-d H:i:s'), |
| 558 | + 'text'=>$info['text'] ?? '', | ||
| 558 | ]; | 559 | ]; |
| 559 | } | 560 | } |
| 560 | } | 561 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :NewsExtendLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/5/26 15:11 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Bside\News; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Bside\BaseLogic; | ||
| 13 | +use App\Models\News\NewsExtend; | ||
| 14 | +use App\Models\Product\ExtendInfo; | ||
| 15 | + | ||
| 16 | +class NewsExtendLogic extends BaseLogic | ||
| 17 | +{ | ||
| 18 | + public function __construct() | ||
| 19 | + { | ||
| 20 | + parent::__construct(); | ||
| 21 | + $this->model = new NewsExtend(); | ||
| 22 | + $this->param = $this->requestAll; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * @remark :列表页 | ||
| 27 | + * @name :list | ||
| 28 | + * @author :lyh | ||
| 29 | + * @method :post | ||
| 30 | + * @time :2025/5/26 15:17 | ||
| 31 | + */ | ||
| 32 | + public function list($map){ | ||
| 33 | + $data = $this->model->list($map); | ||
| 34 | + return $this->success($data); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * @remark :保存扩展字段 | ||
| 39 | + * @name :extendSave | ||
| 40 | + * @author :lyh | ||
| 41 | + * @method :post | ||
| 42 | + * @time :2025/5/26 15:13 | ||
| 43 | + * @param :id->主键;title->名称 | ||
| 44 | + */ | ||
| 45 | + public function extendSave(){ | ||
| 46 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 47 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 48 | + }else{ | ||
| 49 | + $info = $this->model->read(['title'=>$this->param['title']]); | ||
| 50 | + if($info !== false){ | ||
| 51 | + $this->fail('当前扩展名称已存在'); | ||
| 52 | + } | ||
| 53 | + $this->param['key'] = $this->model->getKey(); | ||
| 54 | + $this->param['project_id'] = $this->user['project_id']; | ||
| 55 | + $rs = $this->model->add($this->param); | ||
| 56 | + } | ||
| 57 | + if($rs === false){ | ||
| 58 | + $this->fail('error'); | ||
| 59 | + } | ||
| 60 | + return $this->success($this->param); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * @remark :删除字段 | ||
| 65 | + * @name :extendDel | ||
| 66 | + * @author :lyh | ||
| 67 | + * @method :post | ||
| 68 | + * @time :2025/5/26 15:45 | ||
| 69 | + * @param :id->主键 | ||
| 70 | + */ | ||
| 71 | + public function extendDel(){ | ||
| 72 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 73 | + //查看当前扩展字段是否设置了值 | ||
| 74 | + $extendInfoModel = new ExtendInfo(); | ||
| 75 | + $extendInfo = $extendInfoModel->read(['key'=>$info['key']]); | ||
| 76 | + if($extendInfo !== false){ | ||
| 77 | + $this->fail('当前扩展字段已有产品在使用,不允许删除'); | ||
| 78 | + } | ||
| 79 | + $this->model->del(['id'=>$this->param['id']]); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | +} |
| @@ -549,7 +549,7 @@ class RankDataLogic extends BaseLogic | @@ -549,7 +549,7 @@ class RankDataLogic extends BaseLogic | ||
| 549 | $without_extension_project_ids = [658]; //是否达标只统计主词的 | 549 | $without_extension_project_ids = [658]; //是否达标只统计主词的 |
| 550 | $extension_project_ids = [354]; //扩展词也到达标的 | 550 | $extension_project_ids = [354]; //扩展词也到达标的 |
| 551 | $compliance_project_ids = [2163,257,823,1750,497]; //直接达标处理的 | 551 | $compliance_project_ids = [2163,257,823,1750,497]; //直接达标处理的 |
| 552 | - $ceaseProjectId = [354, 378, 649, 1226, 1283, 1703, 1893, 2066, 2250];//暂停的项目 | 552 | + $ceaseProjectId = [354, 378, 649, 1226, 1283, 1703, 1893, 2066, 2250,2193];//暂停的项目 |
| 553 | $uptimeProjectId = [1434,1812,276,2414,2974];//按上线时间统计的项目 | 553 | $uptimeProjectId = [1434,1812,276,2414,2974];//按上线时间统计的项目 |
| 554 | //一个项目多个api_no | 554 | //一个项目多个api_no |
| 555 | $multiple_api_no_project_ids = [ | 555 | $multiple_api_no_project_ids = [ |
app/Models/News/NewsExtend.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :NewsExtend.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/5/26 15:08 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\News; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class NewsExtend extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_news_extend'; | ||
| 17 | + protected $connection = 'custom_mysql'; | ||
| 18 | + | ||
| 19 | + const EXTEND_KEY = 'pd_extended_field_'; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * @remark :添加扩展字段 | ||
| 23 | + * @name :getKey | ||
| 24 | + * @author :lyh | ||
| 25 | + * @method :post | ||
| 26 | + * @time :2025/5/26 15:39 | ||
| 27 | + */ | ||
| 28 | + public function getKey($key = self::EXTEND_KEY,$i = 1){ | ||
| 29 | + $info = $this->model->read(['key'=>$key.$i]); | ||
| 30 | + if($info !== false){ | ||
| 31 | + return $this->getKey($key,$i+1); | ||
| 32 | + }else{ | ||
| 33 | + return $key.$i; | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | +} |
app/Models/News/NewsExtendInfo.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :NewsExtendInfo.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/5/26 15:49 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\News; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +class NewsExtendInfo extends Base | ||
| 15 | +{ | ||
| 16 | + protected $table = 'gl_news_extend_info'; | ||
| 17 | + protected $connection = 'custom_mysql'; | ||
| 18 | +} |
app/Services/AiCommandService.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AiCommandService.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/5/26 17:01 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Services; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * @remark :AI指令返回数据 | ||
| 14 | + * @name :AiCommandService | ||
| 15 | + * @author :lyh | ||
| 16 | + * @method :post | ||
| 17 | + * @time :2025/5/26 17:01 | ||
| 18 | + */ | ||
| 19 | +class AiCommandService | ||
| 20 | +{ | ||
| 21 | + public $url = 'https://api.cmer.com/v2/chat'; | ||
| 22 | + | ||
| 23 | + public $api_key = 'nnLsyr3IhPNsJt5OvTtD9SVCLEixMntg'; | ||
| 24 | + | ||
| 25 | + public $model = 'gemini-2.0-flash-lite'; | ||
| 26 | + | ||
| 27 | + public $supplier = 'google'; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * @remark :Ai一键排版 | ||
| 31 | + * @name :ai_click_layout | ||
| 32 | + * @author :lyh | ||
| 33 | + * @method :post | ||
| 34 | + * @time :2025/5/26 17:03 | ||
| 35 | + */ | ||
| 36 | + public function send_layout_design($content){ | ||
| 37 | + $param = [ | ||
| 38 | + 'messages'=>[ | ||
| 39 | + ['content'=>$content, 'role'=>'user'], | ||
| 40 | + ], | ||
| 41 | + 'model'=> $this->model, | ||
| 42 | + 'supplier'=> $this->supplier, | ||
| 43 | + 'security_check'=> false | ||
| 44 | + ]; | ||
| 45 | + $header = array( | ||
| 46 | + "Accept: application/json", | ||
| 47 | + "X-CmerApi-Host: llm-chat.p.cmer.com", | ||
| 48 | + "apikey: $this->api_key", | ||
| 49 | + "Content-Type:application/json;charset=utf-8", | ||
| 50 | + ); | ||
| 51 | + $result = http_post($this->url,json_encode($param,true),$header); | ||
| 52 | + return $result; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | +} |
| @@ -148,6 +148,9 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -148,6 +148,9 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 148 | Route::prefix('command')->group(function () { | 148 | Route::prefix('command')->group(function () { |
| 149 | //公用ai自动生成 | 149 | //公用ai自动生成 |
| 150 | Route::any('/ai_http_post', [\App\Http\Controllers\Bside\Ai\AiCommandController::class, 'ai_http_post'])->name('ai_http_post'); | 150 | Route::any('/ai_http_post', [\App\Http\Controllers\Bside\Ai\AiCommandController::class, 'ai_http_post'])->name('ai_http_post'); |
| 151 | + Route::any('/getLayoutDesignInfo', [\App\Http\Controllers\Bside\Ai\AiCommandController::class, 'getLayoutDesignInfo'])->name('ai_getLayoutDesignInfo'); | ||
| 152 | + Route::any('/saveLayoutDesign', [\App\Http\Controllers\Bside\Ai\AiCommandController::class, 'saveLayoutDesign'])->name('ai_saveLayoutDesign'); | ||
| 153 | + Route::any('/sendLayoutDesign', [\App\Http\Controllers\Bside\Ai\AiCommandController::class, 'sendLayoutDesign'])->name('ai_sendLayoutDesign'); | ||
| 151 | }); | 154 | }); |
| 152 | 155 | ||
| 153 | //ai生成相关接口 | 156 | //ai生成相关接口 |
-
请 注册 或 登录 后发表评论