作者 李宇航

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

Lyh server



查看合并请求 !1556
... ... @@ -556,7 +556,7 @@ class OptimizeController extends BaseController
]);
ProjectServer::useProject($this->param['project_id']);
$aiBlogModel = new AiBlog();
$list = $aiBlogModel->formatQuery(['anchor'=>['!=',null]])->pluck('route')->toArray();
$list = $aiBlogModel->formatQuery(['route'=>['!=',null]])->pluck('route')->toArray();
if(!empty($list)){
$domainModel = new DomainInfo();
$DomainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]);
... ...
... ... @@ -12,41 +12,6 @@ use App\Models\Ai\AiBlogList;
class AiBlogController extends BaseController
{
/**
* @remark :获取详情
* @name :getInfo
* @author :lyh
* @method :post
* @time :2025/2/20 18:17
*/
public function getInfo(AiBlog $aiBlog){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiBlog->read(['id'=>$this->param['id']]);
$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 getAuthorInfo(AiBlogAuthor $aiBlogAuthor){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiBlogAuthor->read($this->map);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :获取ai博客列表
... ... @@ -70,6 +35,24 @@ class AiBlogController extends BaseController
}
/**
* @remark :获取详情
* @name :getInfo
* @author :lyh
* @method :post
* @time :2025/2/20 18:17
*/
public function getInfo(AiBlog $aiBlog){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiBlog->read(['id'=>$this->param['id']]);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :发布任务
* @name :sendTask
* @author :lyh
... ... @@ -90,6 +73,19 @@ class AiBlogController extends BaseController
}
/**
* @remark :编辑Ai博客发布
* @name :save
* @author :lyh
* @method :post
* @time :2023/7/5 14:33
*/
public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){
$aiBlogRequest->validated();
$aiBlogLogic->blogSave();
$this->response('success');
}
/**
* @remark :获取作者列表
* @name :getAiBlogAuthor
* @author :lyh
... ... @@ -110,20 +106,6 @@ class AiBlogController extends BaseController
}
/**
* @remark :编辑Ai博客发布
* @name :save
* @author :lyh
* @method :post
* @time :2023/7/5 14:33
*/
public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){
$aiBlogRequest->validated();
$aiBlogLogic->blogSave();
$this->response('success');
}
/**
* @remark :编辑作者详情数据
* @name :saveBlogAuthor
* @author :lyh
... ... @@ -192,4 +174,22 @@ class AiBlogController extends BaseController
$info = $aiBlogList->read($this->map);
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :获取详情数据
* @name :getAuthorInfo
* @author :lyh
* @method :post
* @time :2025/2/21 13:54
*/
public function getAuthorInfo(AiBlogAuthor $aiBlogAuthor){
$this->request->validate([
'id'=>['required'],
],[
'id.required' => '主键不能为空',
]);
$info = $aiBlogAuthor->read($this->map);
$info['image'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
}
... ...
... ... @@ -61,7 +61,7 @@ class AiBlogLogic extends BaseLogic
$aiBlogService = new AiBlogService();
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$res = $aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
$aiBlogService->updateDetail(['task_id'=>$this->param['task_id'],'title'=>$this->param['new_title'],'thumb'=>$this->param['image'],'route'=>$this->param['route'],'author_id'=>$this->param['author_id']]);
}catch (\Exception $e){
$this->fail('保存失败,请联系管理员');
}
... ... @@ -109,7 +109,7 @@ class AiBlogLogic extends BaseLogic
$aiBlogService->mch_id = $aiSettingInfo['mch_id'];
$aiBlogService->key = $aiSettingInfo['key'];
$aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en'));
$result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? []);
$result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? [],$this->param['title'] ?? '');
if($result['status'] == 200){
$aiBlogTaskModel = new AiBlogTask();
$aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]);
... ...
... ... @@ -12,6 +12,7 @@ namespace App\Services;
use App\Helper\Translate;
use App\Models\Project\ProjectAiSetting;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class AiBlogService
{
... ... @@ -36,6 +37,13 @@ class AiBlogService
}
}
/**
* @remark :设置路由
* @name :setRoute
* @author :lyh
* @method :post
* @time :2025/3/25 9:45
*/
public function setRoute($keyword)
{
$this->route = generateRoute(Translate::tran($keyword, 'en'));
... ... @@ -52,11 +60,7 @@ class AiBlogService
public function createProject($project_name,$language,$profile,$company){
$request_url = $this->url.'api/project/create';
$param = [
'mch_id'=>$this->mch_id,
'title'=>$project_name,
'language'=>$language,
'profile'=>$profile,
'company'=>$company,
'mch_id'=>$this->mch_id, 'title'=>$project_name, 'language'=>$language, 'profile'=>$profile, 'company'=>$company,
];
$this->sign = $this->generateSign($param,$this->key);
$param['sign'] = $this->sign;
... ... @@ -73,13 +77,7 @@ class AiBlogService
*/
public function updatedProject($project_name,$language,$profile,$company){
$request_url = $this->url.'api/project/save';
$param = [
'mch_id'=>$this->mch_id,
'title'=>$project_name,
'language'=>$language,
'profile'=>$profile,
'company'=>$company,
];
$param = ['mch_id'=>$this->mch_id, 'title'=>$project_name, 'language'=>$language, 'profile'=>$profile, 'company'=>$company];
$this->sign = $this->generateSign($param,$this->key);
$param['sign'] = $this->sign;
$result = http_post($request_url,json_encode($param,true));
... ... @@ -92,19 +90,11 @@ class AiBlogService
* @author :lyh
* @method :post
* @time :2025/2/13 14:39
* @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url
* @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url , title=标题
*/
public function createTask($keyword,$type = 2,$subtype = 'Blog',$anchor = []){
public function createTask($keyword,$type = 2,$subtype = 'Blog',$anchor = [],$title = ''){
$request_url = $this->url.'api/task/create';
$param = [
'keyword'=>$keyword,
'type'=>$type,
'subtype'=>$subtype,
];
$param['anchor'] = $anchor;
$param['url'] = $this->route;
$param['mch_id'] = $this->mch_id;
$param['template_id'] = 1;
$param = ['keyword'=>$keyword, 'type'=>$type, 'subtype'=>$subtype,'anchor'=>$anchor,'title'=>$title,'url'=>$this->route,'mch_id'=>$this->mch_id,'template_id'=>1];
$this->sign = $this->generateSign($param,$this->key);
$param['sign'] = $this->sign;
$result = http_post($request_url,json_encode($param,true));
... ... @@ -120,9 +110,7 @@ class AiBlogService
*/
public function createAuthor(){
$request_url = $this->url.'api/author/create';
$param = [
'mch_id'=>$this->mch_id,
];
$param = ['mch_id'=>$this->mch_id];
$this->sign = $this->generateSign($param,$this->key);
$param['sign'] = $this->sign;
$result = http_post($request_url,json_encode($param,true));
... ...