作者 李宇航

合并分支 'master-server' 到 'master'

Master server



查看合并请求 !1188
... ... @@ -114,7 +114,7 @@ class AiBlogAuthorTask extends Command
$param = [
'author_id'=>$v['id'],
'title'=>$v['title'],
'image'=>$v['picture'],
'image'=>str_replace_url($v['picture']),
'description'=>$v['description'],
];
$id = $aiBlogAuthorModel->addReturnId($param);
... ...
... ... @@ -63,7 +63,7 @@ class AiBlogTask extends Command
//保存当前项目ai_blog数据
ProjectServer::useProject($info['project_id']);
$aiBlogModel = new AiBlog();
$aiBlogModel->edit(['new_title'=>$result['data']['title'],'image'=>$result['data']['thumb'],'text'=>$result['data']['section'],'status'=>2],['task_id'=>$info['task_id']]);
$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']]);
$this->updateAiBlogAuthor($aiSettingInfo,$result['data']['author_id']);
DB::disconnect('custom_mysql');
//修改任务状态
... ...
... ... @@ -41,6 +41,7 @@ class AiBlogController extends BaseController
'id.required' => '主键不能为空',
]);
$info = $aiBlog->read(['id'=>$this->param['id']]);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
... ... @@ -73,7 +74,7 @@ class AiBlogController extends BaseController
$lists = $aiBlog->lists($this->map,$this->page,$this->row,'id',['id','new_title','image','task_id','status','created_at','updated_at']);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['image'] = getImageUrl($v['image']);
$lists['list'][$k] = $v;
}
}
... ... @@ -129,6 +130,24 @@ class AiBlogController extends BaseController
'id.required' => '主键不能为空',
]);
$info = $aiBlogAuthor->read($this->map);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :获取详情数据
* @name :getAuthorInfo
* @author :lyh
* @method :post
* @time :2025/2/21 13:54
*/
public function saveBlogAuthor(AiBlogLogic $aiBlogLogic){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiBlogLogic->saveBlogAuthor();
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -28,30 +28,70 @@ class AiBlogLogic extends BaseLogic
* @time :2023/7/5 14:46
*/
public function blogSave(){
if(!empty($this->param['image'])){
$this->param['image'] = str_replace_url($this->param['image']);
}
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('error');
try {
if(!empty($this->param['image'])){
$this->param['image'] = str_replace_url($this->param['image']);
}
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG, $this->param['id'], $this->user['project_id']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
$aiSettingInfo = $this->getProjectAiSetting();
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->route = $this->param['route'];
$aiBlogService->author_id = $this->param['author_id'];
$aiBlogService->updateDetail($this->param['title'],$this->param['image']);
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
return $this->success();
}
/**
* @remark :发布任务
* @name :sendTask
* @remark :获取配置信息
* @name :getProjectAiSetting
* @author :lyh
* @method :post
* @time :2025/2/14 10:28
* @time :2025/2/21 14:51
*/
public function sendTask(){
public function getProjectAiSetting(){
$projectAiSettingModel = new ProjectAiSetting();
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);
if($aiSettingInfo === false){
$this->fail('请先联系管理员开启Ai博客');
}
return $aiSettingInfo;
}
/**
* @remark :编辑作者
* @name :saveAuthor
* @author :lyh
* @method :post
* @time :2025/2/21 14:46
*/
public function saveBlogAuthor(){
try {
if(!empty($this->param['image'])){
$this->param['image'] = str_replace_url($this->param['image']);
}
$this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
return $this->success();
}
/**
* @remark :发布任务
* @name :sendTask
* @author :lyh
* @method :post
* @time :2025/2/14 10:28
*/
public function sendTask(){
$aiSettingInfo = $this->getProjectAiSetting();
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
... ... @@ -77,11 +117,7 @@ class AiBlogLogic extends BaseLogic
* @time :2025/2/20 10:46
*/
public function createAuthor(){
$projectAiSettingModel = new ProjectAiSetting();
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);
if($aiSettingInfo === false){
$this->fail('请先联系管理员开启Ai博客');
}
$aiSettingInfo = $this->getProjectAiSetting();
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
... ...
... ... @@ -182,4 +182,27 @@ class AiBlogService
$result = http_post($request_url,json_encode($param,true));
return $result;
}
/**
* @remark :更新文章
* @name :updateDetail
* @author :lyh
* @method :post
* @time :2025/2/21 14:38
*/
public function updateDetail($title,$image){
$request_url = $this->url.'api/result/save';
$param = [
'mch_id'=>$this->mch_id,
'author_id'=>$this->author_id,
'route'=>$this->route,
'author_id'=>$this->author_id,
'title'=>$title,
'thumb'=>$image,
];
$this->sign = $this->generateSign($param,$this->key);
$param['sign'] = $this->sign;
$result = http_post($request_url,json_encode($param,true));
return $result;
}
}
... ...
... ... @@ -159,6 +159,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/blog/del', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'delete'])->name('ai_blog_delete');
Route::any('/blog/getAiBlogAuthor', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getAiBlogAuthor'])->name('ai_blog_getAiBlogAuthor');
Route::any('/blog/getAuthorInfo', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getAuthorInfo'])->name('ai_blog_getAuthorInfo');
Route::any('/blog/saveBlogAuthor', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'saveBlogAuthor'])->name('ai_blog_saveBlogAuthor');
Route::any('/blog/getInfo', [\App\Http\Controllers\Bside\Ai\AiBlogController::class, 'getInfo'])->name('ai_blog_getInfo');
Route::any('/product/', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'save'])->name('ai_product_save');
Route::any('/product/productList', [\App\Http\Controllers\Bside\Ai\AiProductController::class, 'productList'])->name('ai_product_productList');
... ...