作者 李宇航

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

Lyh server



查看合并请求 !1556
@@ -556,7 +556,7 @@ class OptimizeController extends BaseController @@ -556,7 +556,7 @@ class OptimizeController extends BaseController
556 ]); 556 ]);
557 ProjectServer::useProject($this->param['project_id']); 557 ProjectServer::useProject($this->param['project_id']);
558 $aiBlogModel = new AiBlog(); 558 $aiBlogModel = new AiBlog();
559 - $list = $aiBlogModel->formatQuery(['anchor'=>['!=',null]])->pluck('route')->toArray(); 559 + $list = $aiBlogModel->formatQuery(['route'=>['!=',null]])->pluck('route')->toArray();
560 if(!empty($list)){ 560 if(!empty($list)){
561 $domainModel = new DomainInfo(); 561 $domainModel = new DomainInfo();
562 $DomainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]); 562 $DomainInfo = $domainModel->read(['project_id'=>$this->param['project_id']]);
@@ -12,41 +12,6 @@ use App\Models\Ai\AiBlogList; @@ -12,41 +12,6 @@ use App\Models\Ai\AiBlogList;
12 12
13 class AiBlogController extends BaseController 13 class AiBlogController extends BaseController
14 { 14 {
15 - /**  
16 - * @remark :获取详情  
17 - * @name :getInfo  
18 - * @author :lyh  
19 - * @method :post  
20 - * @time :2025/2/20 18:17  
21 - */  
22 - public function getInfo(AiBlog $aiBlog){  
23 - $this->request->validate([  
24 - 'id'=>['required'],  
25 - ],[  
26 - 'id.required' => '主键不能为空',  
27 - ]);  
28 - $info = $aiBlog->read(['id'=>$this->param['id']]);  
29 - $info['image'] = getImageUrl($info['image']);  
30 - $this->response('success',Code::SUCCESS,$info);  
31 - }  
32 -  
33 - /**  
34 - * @remark :获取详情数据  
35 - * @name :getAuthorInfo  
36 - * @author :lyh  
37 - * @method :post  
38 - * @time :2025/2/21 13:54  
39 - */  
40 - public function getAuthorInfo(AiBlogAuthor $aiBlogAuthor){  
41 - $this->request->validate([  
42 - 'id'=>['required'],  
43 - ],[  
44 - 'id.required' => '主键不能为空',  
45 - ]);  
46 - $info = $aiBlogAuthor->read($this->map);  
47 - $info['image'] = getImageUrl($info['image']);  
48 - $this->response('success',Code::SUCCESS,$info);  
49 - }  
50 15
51 /** 16 /**
52 * @remark :获取ai博客列表 17 * @remark :获取ai博客列表
@@ -70,6 +35,24 @@ class AiBlogController extends BaseController @@ -70,6 +35,24 @@ class AiBlogController extends BaseController
70 } 35 }
71 36
72 /** 37 /**
  38 + * @remark :获取详情
  39 + * @name :getInfo
  40 + * @author :lyh
  41 + * @method :post
  42 + * @time :2025/2/20 18:17
  43 + */
  44 + public function getInfo(AiBlog $aiBlog){
  45 + $this->request->validate([
  46 + 'id'=>['required'],
  47 + ],[
  48 + 'id.required' => '主键不能为空',
  49 + ]);
  50 + $info = $aiBlog->read(['id'=>$this->param['id']]);
  51 + $info['image'] = getImageUrl($info['image']);
  52 + $this->response('success',Code::SUCCESS,$info);
  53 + }
  54 +
  55 + /**
73 * @remark :发布任务 56 * @remark :发布任务
74 * @name :sendTask 57 * @name :sendTask
75 * @author :lyh 58 * @author :lyh
@@ -90,6 +73,19 @@ class AiBlogController extends BaseController @@ -90,6 +73,19 @@ class AiBlogController extends BaseController
90 } 73 }
91 74
92 /** 75 /**
  76 + * @remark :编辑Ai博客发布
  77 + * @name :save
  78 + * @author :lyh
  79 + * @method :post
  80 + * @time :2023/7/5 14:33
  81 + */
  82 + public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){
  83 + $aiBlogRequest->validated();
  84 + $aiBlogLogic->blogSave();
  85 + $this->response('success');
  86 + }
  87 +
  88 + /**
93 * @remark :获取作者列表 89 * @remark :获取作者列表
94 * @name :getAiBlogAuthor 90 * @name :getAiBlogAuthor
95 * @author :lyh 91 * @author :lyh
@@ -110,20 +106,6 @@ class AiBlogController extends BaseController @@ -110,20 +106,6 @@ class AiBlogController extends BaseController
110 } 106 }
111 107
112 /** 108 /**
113 - * @remark :编辑Ai博客发布  
114 - * @name :save  
115 - * @author :lyh  
116 - * @method :post  
117 - * @time :2023/7/5 14:33  
118 - */  
119 - public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){  
120 - $aiBlogRequest->validated();  
121 - $aiBlogLogic->blogSave();  
122 - $this->response('success');  
123 - }  
124 -  
125 -  
126 - /**  
127 * @remark :编辑作者详情数据 109 * @remark :编辑作者详情数据
128 * @name :saveBlogAuthor 110 * @name :saveBlogAuthor
129 * @author :lyh 111 * @author :lyh
@@ -192,4 +174,22 @@ class AiBlogController extends BaseController @@ -192,4 +174,22 @@ class AiBlogController extends BaseController
192 $info = $aiBlogList->read($this->map); 174 $info = $aiBlogList->read($this->map);
193 $this->response('success',Code::SUCCESS,$info); 175 $this->response('success',Code::SUCCESS,$info);
194 } 176 }
  177 +
  178 + /**
  179 + * @remark :获取详情数据
  180 + * @name :getAuthorInfo
  181 + * @author :lyh
  182 + * @method :post
  183 + * @time :2025/2/21 13:54
  184 + */
  185 + public function getAuthorInfo(AiBlogAuthor $aiBlogAuthor){
  186 + $this->request->validate([
  187 + 'id'=>['required'],
  188 + ],[
  189 + 'id.required' => '主键不能为空',
  190 + ]);
  191 + $info = $aiBlogAuthor->read($this->map);
  192 + $info['image'] = getImageUrl($info['image']);
  193 + $this->response('success',Code::SUCCESS,$info);
  194 + }
195 } 195 }
@@ -61,7 +61,7 @@ class AiBlogLogic extends BaseLogic @@ -61,7 +61,7 @@ class AiBlogLogic extends BaseLogic
61 $aiBlogService = new AiBlogService(); 61 $aiBlogService = new AiBlogService();
62 $aiBlogService->mch_id = $aiSettingInfo['mch_id']; 62 $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
63 $aiBlogService->key = $aiSettingInfo['key']; 63 $aiBlogService->key = $aiSettingInfo['key'];
64 - $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']]); 64 + $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']]);
65 }catch (\Exception $e){ 65 }catch (\Exception $e){
66 $this->fail('保存失败,请联系管理员'); 66 $this->fail('保存失败,请联系管理员');
67 } 67 }
@@ -109,7 +109,7 @@ class AiBlogLogic extends BaseLogic @@ -109,7 +109,7 @@ class AiBlogLogic extends BaseLogic
109 $aiBlogService->mch_id = $aiSettingInfo['mch_id']; 109 $aiBlogService->mch_id = $aiSettingInfo['mch_id'];
110 $aiBlogService->key = $aiSettingInfo['key']; 110 $aiBlogService->key = $aiSettingInfo['key'];
111 $aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en')); 111 $aiBlogService->route = generateRoute(Translate::tran($this->param['keyword'], 'en'));
112 - $result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? []); 112 + $result = $aiBlogService->createTask($this->param['keyword'],2,'blog',$this->param['anchor'] ?? [],$this->param['title'] ?? '');
113 if($result['status'] == 200){ 113 if($result['status'] == 200){
114 $aiBlogTaskModel = new AiBlogTask(); 114 $aiBlogTaskModel = new AiBlogTask();
115 $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]); 115 $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; @@ -12,6 +12,7 @@ namespace App\Services;
12 use App\Helper\Translate; 12 use App\Helper\Translate;
13 use App\Models\Project\ProjectAiSetting; 13 use App\Models\Project\ProjectAiSetting;
14 use Illuminate\Database\Eloquent\Model; 14 use Illuminate\Database\Eloquent\Model;
  15 +use Illuminate\Support\Facades\Cache;
15 16
16 class AiBlogService 17 class AiBlogService
17 { 18 {
@@ -36,6 +37,13 @@ class AiBlogService @@ -36,6 +37,13 @@ class AiBlogService
36 } 37 }
37 } 38 }
38 39
  40 + /**
  41 + * @remark :设置路由
  42 + * @name :setRoute
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2025/3/25 9:45
  46 + */
39 public function setRoute($keyword) 47 public function setRoute($keyword)
40 { 48 {
41 $this->route = generateRoute(Translate::tran($keyword, 'en')); 49 $this->route = generateRoute(Translate::tran($keyword, 'en'));
@@ -52,11 +60,7 @@ class AiBlogService @@ -52,11 +60,7 @@ class AiBlogService
52 public function createProject($project_name,$language,$profile,$company){ 60 public function createProject($project_name,$language,$profile,$company){
53 $request_url = $this->url.'api/project/create'; 61 $request_url = $this->url.'api/project/create';
54 $param = [ 62 $param = [
55 - 'mch_id'=>$this->mch_id,  
56 - 'title'=>$project_name,  
57 - 'language'=>$language,  
58 - 'profile'=>$profile,  
59 - 'company'=>$company, 63 + 'mch_id'=>$this->mch_id, 'title'=>$project_name, 'language'=>$language, 'profile'=>$profile, 'company'=>$company,
60 ]; 64 ];
61 $this->sign = $this->generateSign($param,$this->key); 65 $this->sign = $this->generateSign($param,$this->key);
62 $param['sign'] = $this->sign; 66 $param['sign'] = $this->sign;
@@ -73,13 +77,7 @@ class AiBlogService @@ -73,13 +77,7 @@ class AiBlogService
73 */ 77 */
74 public function updatedProject($project_name,$language,$profile,$company){ 78 public function updatedProject($project_name,$language,$profile,$company){
75 $request_url = $this->url.'api/project/save'; 79 $request_url = $this->url.'api/project/save';
76 - $param = [  
77 - 'mch_id'=>$this->mch_id,  
78 - 'title'=>$project_name,  
79 - 'language'=>$language,  
80 - 'profile'=>$profile,  
81 - 'company'=>$company,  
82 - ]; 80 + $param = ['mch_id'=>$this->mch_id, 'title'=>$project_name, 'language'=>$language, 'profile'=>$profile, 'company'=>$company];
83 $this->sign = $this->generateSign($param,$this->key); 81 $this->sign = $this->generateSign($param,$this->key);
84 $param['sign'] = $this->sign; 82 $param['sign'] = $this->sign;
85 $result = http_post($request_url,json_encode($param,true)); 83 $result = http_post($request_url,json_encode($param,true));
@@ -92,19 +90,11 @@ class AiBlogService @@ -92,19 +90,11 @@ class AiBlogService
92 * @author :lyh 90 * @author :lyh
93 * @method :post 91 * @method :post
94 * @time :2025/2/13 14:39 92 * @time :2025/2/13 14:39
95 - * @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url 93 + * @param :type=(1作者2文章) keyword=关键词 subtype=blog url=回调url , title=标题
96 */ 94 */
97 - public function createTask($keyword,$type = 2,$subtype = 'Blog',$anchor = []){ 95 + public function createTask($keyword,$type = 2,$subtype = 'Blog',$anchor = [],$title = ''){
98 $request_url = $this->url.'api/task/create'; 96 $request_url = $this->url.'api/task/create';
99 - $param = [  
100 - 'keyword'=>$keyword,  
101 - 'type'=>$type,  
102 - 'subtype'=>$subtype,  
103 - ];  
104 - $param['anchor'] = $anchor;  
105 - $param['url'] = $this->route;  
106 - $param['mch_id'] = $this->mch_id;  
107 - $param['template_id'] = 1; 97 + $param = ['keyword'=>$keyword, 'type'=>$type, 'subtype'=>$subtype,'anchor'=>$anchor,'title'=>$title,'url'=>$this->route,'mch_id'=>$this->mch_id,'template_id'=>1];
108 $this->sign = $this->generateSign($param,$this->key); 98 $this->sign = $this->generateSign($param,$this->key);
109 $param['sign'] = $this->sign; 99 $param['sign'] = $this->sign;
110 $result = http_post($request_url,json_encode($param,true)); 100 $result = http_post($request_url,json_encode($param,true));
@@ -120,9 +110,7 @@ class AiBlogService @@ -120,9 +110,7 @@ class AiBlogService
120 */ 110 */
121 public function createAuthor(){ 111 public function createAuthor(){
122 $request_url = $this->url.'api/author/create'; 112 $request_url = $this->url.'api/author/create';
123 - $param = [  
124 - 'mch_id'=>$this->mch_id,  
125 - ]; 113 + $param = ['mch_id'=>$this->mch_id];
126 $this->sign = $this->generateSign($param,$this->key); 114 $this->sign = $this->generateSign($param,$this->key);
127 $param['sign'] = $this->sign; 115 $param['sign'] = $this->sign;
128 $result = http_post($request_url,json_encode($param,true)); 116 $result = http_post($request_url,json_encode($param,true));