|
...
|
...
|
@@ -4,6 +4,10 @@ namespace App\Http\Logic\Bside\Ai; |
|
|
|
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Ai\AiBlog;
|
|
|
|
use App\Models\Project\AiBlogTask;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\Project\ProjectAiSetting;
|
|
|
|
use App\Services\AiBlogService;
|
|
|
|
|
|
|
|
class AiBlogLogic extends BaseLogic
|
|
|
|
{
|
|
...
|
...
|
@@ -29,4 +33,35 @@ class AiBlogLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :发布任务
|
|
|
|
* @name :sendTask
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/14 10:28
|
|
|
|
*/
|
|
|
|
public function sendTask(){
|
|
|
|
$projectAiSettingModel = new ProjectAiSetting();
|
|
|
|
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($aiSettingInfo === false){
|
|
|
|
$this->fail('请先联系管理员开启Ai博客');
|
|
|
|
}
|
|
|
|
$aiBlogService = new AiBlogService();
|
|
|
|
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
|
|
|
|
$aiBlogService->key = $aiSettingInfo['key'];
|
|
|
|
$result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']);
|
|
|
|
if($result['status'] == 200){
|
|
|
|
try {
|
|
|
|
$aiBlogTaskModel = new AiBlogTask();
|
|
|
|
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'task_id'=>$result['data']['task_id'],'status'=>$result['data']['status']]);
|
|
|
|
$aiBlogModel = new AiBlog();
|
|
|
|
$aiBlogModel->addReturnId(['keywords'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],
|
|
|
|
]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('请求ai_blog失败,请联系管理员');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|