合并分支 'master-server' 到 'master'
Master server 查看合并请求 !1188
正在显示
6 个修改的文件
包含
98 行增加
和
19 行删除
| @@ -114,7 +114,7 @@ class AiBlogAuthorTask extends Command | @@ -114,7 +114,7 @@ class AiBlogAuthorTask extends Command | ||
| 114 | $param = [ | 114 | $param = [ |
| 115 | 'author_id'=>$v['id'], | 115 | 'author_id'=>$v['id'], |
| 116 | 'title'=>$v['title'], | 116 | 'title'=>$v['title'], |
| 117 | - 'image'=>$v['picture'], | 117 | + 'image'=>str_replace_url($v['picture']), |
| 118 | 'description'=>$v['description'], | 118 | 'description'=>$v['description'], |
| 119 | ]; | 119 | ]; |
| 120 | $id = $aiBlogAuthorModel->addReturnId($param); | 120 | $id = $aiBlogAuthorModel->addReturnId($param); |
| @@ -63,7 +63,7 @@ class AiBlogTask extends Command | @@ -63,7 +63,7 @@ class AiBlogTask extends Command | ||
| 63 | //保存当前项目ai_blog数据 | 63 | //保存当前项目ai_blog数据 |
| 64 | ProjectServer::useProject($info['project_id']); | 64 | ProjectServer::useProject($info['project_id']); |
| 65 | $aiBlogModel = new AiBlog(); | 65 | $aiBlogModel = new AiBlog(); |
| 66 | - $aiBlogModel->edit(['new_title'=>$result['data']['title'],'image'=>$result['data']['thumb'],'text'=>$result['data']['section'],'status'=>2],['task_id'=>$info['task_id']]); | 66 | + $aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'], 'status'=>2], ['task_id'=>$info['task_id']]); |
| 67 | $this->updateAiBlogAuthor($aiSettingInfo,$result['data']['author_id']); | 67 | $this->updateAiBlogAuthor($aiSettingInfo,$result['data']['author_id']); |
| 68 | DB::disconnect('custom_mysql'); | 68 | DB::disconnect('custom_mysql'); |
| 69 | //修改任务状态 | 69 | //修改任务状态 |
| @@ -41,6 +41,7 @@ class AiBlogController extends BaseController | @@ -41,6 +41,7 @@ class AiBlogController extends BaseController | ||
| 41 | 'id.required' => '主键不能为空', | 41 | 'id.required' => '主键不能为空', |
| 42 | ]); | 42 | ]); |
| 43 | $info = $aiBlog->read(['id'=>$this->param['id']]); | 43 | $info = $aiBlog->read(['id'=>$this->param['id']]); |
| 44 | + $info['image'] = getImageUrl($info['image']); | ||
| 44 | $this->response('success',Code::SUCCESS,$info); | 45 | $this->response('success',Code::SUCCESS,$info); |
| 45 | } | 46 | } |
| 46 | 47 | ||
| @@ -73,7 +74,7 @@ class AiBlogController extends BaseController | @@ -73,7 +74,7 @@ class AiBlogController extends BaseController | ||
| 73 | $lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','new_title','image','task_id','status','created_at','updated_at']); | 74 | $lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','new_title','image','task_id','status','created_at','updated_at']); |
| 74 | if(!empty($lists) && !empty($lists['list'])){ | 75 | if(!empty($lists) && !empty($lists['list'])){ |
| 75 | foreach ($lists['list'] as $k => $v){ | 76 | foreach ($lists['list'] as $k => $v){ |
| 76 | - $v['image'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']); | 77 | + $v['image'] = getImageUrl($v['image']); |
| 77 | $lists['list'][$k] = $v; | 78 | $lists['list'][$k] = $v; |
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| @@ -129,6 +130,24 @@ class AiBlogController extends BaseController | @@ -129,6 +130,24 @@ class AiBlogController extends BaseController | ||
| 129 | 'id.required' => '主键不能为空', | 130 | 'id.required' => '主键不能为空', |
| 130 | ]); | 131 | ]); |
| 131 | $info = $aiBlogAuthor->read($this->map); | 132 | $info = $aiBlogAuthor->read($this->map); |
| 133 | + $info['image'] = getImageUrl($info['image']); | ||
| 134 | + $this->response('success',Code::SUCCESS,$info); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * @remark :获取详情数据 | ||
| 139 | + * @name :getAuthorInfo | ||
| 140 | + * @author :lyh | ||
| 141 | + * @method :post | ||
| 142 | + * @time :2025/2/21 13:54 | ||
| 143 | + */ | ||
| 144 | + public function saveBlogAuthor(AiBlogLogic $aiBlogLogic){ | ||
| 145 | + $this->request->validate([ | ||
| 146 | + 'id'=>['required'], | ||
| 147 | + ],[ | ||
| 148 | + 'id.required' => '主键不能为空', | ||
| 149 | + ]); | ||
| 150 | + $info = $aiBlogLogic->saveBlogAuthor(); | ||
| 132 | $this->response('success',Code::SUCCESS,$info); | 151 | $this->response('success',Code::SUCCESS,$info); |
| 133 | } | 152 | } |
| 134 | } | 153 | } |
| @@ -28,30 +28,70 @@ class AiBlogLogic extends BaseLogic | @@ -28,30 +28,70 @@ class AiBlogLogic extends BaseLogic | ||
| 28 | * @time :2023/7/5 14:46 | 28 | * @time :2023/7/5 14:46 |
| 29 | */ | 29 | */ |
| 30 | public function blogSave(){ | 30 | public function blogSave(){ |
| 31 | - if(!empty($this->param['image'])){ | ||
| 32 | - $this->param['image'] = str_replace_url($this->param['image']); | ||
| 33 | - } | ||
| 34 | - $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']); | ||
| 35 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 36 | - if($rs === false){ | ||
| 37 | - $this->fail('error'); | 31 | + try { |
| 32 | + if(!empty($this->param['image'])){ | ||
| 33 | + $this->param['image'] = str_replace_url($this->param['image']); | ||
| 34 | + } | ||
| 35 | + $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG, $this->param['id'], $this->user['project_id']); | ||
| 36 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 37 | + $aiSettingInfo = $this->getProjectAiSetting(); | ||
| 38 | + $aiBlogService = new AiBlogService(); | ||
| 39 | + $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 40 | + $aiBlogService->key = $aiSettingInfo['key']; | ||
| 41 | + $aiBlogService->route = $this->param['route']; | ||
| 42 | + $aiBlogService->author_id = $this->param['author_id']; | ||
| 43 | + $aiBlogService->updateDetail($this->param['title'],$this->param['image']); | ||
| 44 | + }catch (\Exception $e){ | ||
| 45 | + $this->fail('保存失败,请联系管理员'); | ||
| 38 | } | 46 | } |
| 39 | return $this->success(); | 47 | return $this->success(); |
| 40 | } | 48 | } |
| 41 | 49 | ||
| 42 | /** | 50 | /** |
| 43 | - * @remark :发布任务 | ||
| 44 | - * @name :sendTask | 51 | + * @remark :获取配置信息 |
| 52 | + * @name :getProjectAiSetting | ||
| 45 | * @author :lyh | 53 | * @author :lyh |
| 46 | * @method :post | 54 | * @method :post |
| 47 | - * @time :2025/2/14 10:28 | 55 | + * @time :2025/2/21 14:51 |
| 48 | */ | 56 | */ |
| 49 | - public function sendTask(){ | 57 | + public function getProjectAiSetting(){ |
| 50 | $projectAiSettingModel = new ProjectAiSetting(); | 58 | $projectAiSettingModel = new ProjectAiSetting(); |
| 51 | $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]); | 59 | $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]); |
| 52 | if($aiSettingInfo === false){ | 60 | if($aiSettingInfo === false){ |
| 53 | $this->fail('请先联系管理员开启Ai博客'); | 61 | $this->fail('请先联系管理员开启Ai博客'); |
| 54 | } | 62 | } |
| 63 | + return $aiSettingInfo; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * @remark :编辑作者 | ||
| 68 | + * @name :saveAuthor | ||
| 69 | + * @author :lyh | ||
| 70 | + * @method :post | ||
| 71 | + * @time :2025/2/21 14:46 | ||
| 72 | + */ | ||
| 73 | + public function saveBlogAuthor(){ | ||
| 74 | + try { | ||
| 75 | + if(!empty($this->param['image'])){ | ||
| 76 | + $this->param['image'] = str_replace_url($this->param['image']); | ||
| 77 | + } | ||
| 78 | + $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']); | ||
| 79 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 80 | + }catch (\Exception $e){ | ||
| 81 | + $this->fail('保存失败,请联系管理员'); | ||
| 82 | + } | ||
| 83 | + return $this->success(); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * @remark :发布任务 | ||
| 88 | + * @name :sendTask | ||
| 89 | + * @author :lyh | ||
| 90 | + * @method :post | ||
| 91 | + * @time :2025/2/14 10:28 | ||
| 92 | + */ | ||
| 93 | + public function sendTask(){ | ||
| 94 | + $aiSettingInfo = $this->getProjectAiSetting(); | ||
| 55 | $aiBlogService = new AiBlogService(); | 95 | $aiBlogService = new AiBlogService(); |
| 56 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 96 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 57 | $aiBlogService->key = $aiSettingInfo['key']; | 97 | $aiBlogService->key = $aiSettingInfo['key']; |
| @@ -77,11 +117,7 @@ class AiBlogLogic extends BaseLogic | @@ -77,11 +117,7 @@ class AiBlogLogic extends BaseLogic | ||
| 77 | * @time :2025/2/20 10:46 | 117 | * @time :2025/2/20 10:46 |
| 78 | */ | 118 | */ |
| 79 | public function createAuthor(){ | 119 | public function createAuthor(){ |
| 80 | - $projectAiSettingModel = new ProjectAiSetting(); | ||
| 81 | - $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 82 | - if($aiSettingInfo === false){ | ||
| 83 | - $this->fail('请先联系管理员开启Ai博客'); | ||
| 84 | - } | 120 | + $aiSettingInfo = $this->getProjectAiSetting(); |
| 85 | $aiBlogService = new AiBlogService(); | 121 | $aiBlogService = new AiBlogService(); |
| 86 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 122 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 87 | $aiBlogService->key = $aiSettingInfo['key']; | 123 | $aiBlogService->key = $aiSettingInfo['key']; |
| @@ -182,4 +182,27 @@ class AiBlogService | @@ -182,4 +182,27 @@ class AiBlogService | ||
| 182 | $result = http_post($request_url,json_encode($param,true)); | 182 | $result = http_post($request_url,json_encode($param,true)); |
| 183 | return $result; | 183 | return $result; |
| 184 | } | 184 | } |
| 185 | + | ||
| 186 | + /** | ||
| 187 | + * @remark :更新文章 | ||
| 188 | + * @name :updateDetail | ||
| 189 | + * @author :lyh | ||
| 190 | + * @method :post | ||
| 191 | + * @time :2025/2/21 14:38 | ||
| 192 | + */ | ||
| 193 | + public function updateDetail($title,$image){ | ||
| 194 | + $request_url = $this->url.'api/result/save'; | ||
| 195 | + $param = [ | ||
| 196 | + 'mch_id'=>$this->mch_id, | ||
| 197 | + 'author_id'=>$this->author_id, | ||
| 198 | + 'route'=>$this->route, | ||
| 199 | + 'author_id'=>$this->author_id, | ||
| 200 | + 'title'=>$title, | ||
| 201 | + 'thumb'=>$image, | ||
| 202 | + ]; | ||
| 203 | + $this->sign = $this->generateSign($param,$this->key); | ||
| 204 | + $param['sign'] = $this->sign; | ||
| 205 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 206 | + return $result; | ||
| 207 | + } | ||
| 185 | } | 208 | } |
| @@ -159,6 +159,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -159,6 +159,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 159 | Route::any('/blog/del', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'delete'])->name('ai_blog_delete'); | 159 | Route::any('/blog/del', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'delete'])->name('ai_blog_delete'); |
| 160 | Route::any('/blog/getAiBlogAuthor', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getAiBlogAuthor'])->name('ai_blog_getAiBlogAuthor'); | 160 | Route::any('/blog/getAiBlogAuthor', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getAiBlogAuthor'])->name('ai_blog_getAiBlogAuthor'); |
| 161 | Route::any('/blog/getAuthorInfo', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getAuthorInfo'])->name('ai_blog_getAuthorInfo'); | 161 | Route::any('/blog/getAuthorInfo', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getAuthorInfo'])->name('ai_blog_getAuthorInfo'); |
| 162 | + Route::any('/blog/saveBlogAuthor', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'saveBlogAuthor'])->name('ai_blog_saveBlogAuthor'); | ||
| 162 | Route::any('/blog/getInfo', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getInfo'])->name('ai_blog_getInfo'); | 163 | Route::any('/blog/getInfo', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getInfo'])->name('ai_blog_getInfo'); |
| 163 | Route::any('/product/', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'save'])->name('ai_product_save'); | 164 | Route::any('/product/', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'save'])->name('ai_product_save'); |
| 164 | Route::any('/product/productList', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'productList'])->name('ai_product_productList'); | 165 | Route::any('/product/productList', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'productList'])->name('ai_product_productList'); |
-
请 注册 或 登录 后发表评论