正在显示
5 个修改的文件
包含
148 行增加
和
77 行删除
| @@ -8,6 +8,7 @@ use App\Http\Logic\Bside\Ai\AiBlogLogic; | @@ -8,6 +8,7 @@ use App\Http\Logic\Bside\Ai\AiBlogLogic; | ||
| 8 | use App\Http\Requests\Bside\Ai\AiBlogRequest; | 8 | use App\Http\Requests\Bside\Ai\AiBlogRequest; |
| 9 | use App\Models\Ai\AiBlog; | 9 | use App\Models\Ai\AiBlog; |
| 10 | use App\Models\Ai\AiBlogAuthor; | 10 | use App\Models\Ai\AiBlogAuthor; |
| 11 | +use App\Models\Ai\AiBlogList; | ||
| 11 | use App\Services\AiBlogService; | 12 | use App\Services\AiBlogService; |
| 12 | use App\Services\ProjectServer; | 13 | use App\Services\ProjectServer; |
| 13 | use Illuminate\Support\Facades\DB; | 14 | use Illuminate\Support\Facades\DB; |
| @@ -15,19 +16,6 @@ use Illuminate\Support\Facades\DB; | @@ -15,19 +16,6 @@ use Illuminate\Support\Facades\DB; | ||
| 15 | class AiBlogController extends BaseController | 16 | class AiBlogController extends BaseController |
| 16 | { | 17 | { |
| 17 | /** | 18 | /** |
| 18 | - * @remark :Ai博客发布 | ||
| 19 | - * @name :save | ||
| 20 | - * @author :lyh | ||
| 21 | - * @method :post | ||
| 22 | - * @time :2023/7/5 14:33 | ||
| 23 | - */ | ||
| 24 | - public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){ | ||
| 25 | - $aiBlogRequest->validated(); | ||
| 26 | - $aiBlogLogic->blogSave(); | ||
| 27 | - $this->response('success'); | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - /** | ||
| 31 | * @remark :获取详情 | 19 | * @remark :获取详情 |
| 32 | * @name :getInfo | 20 | * @name :getInfo |
| 33 | * @author :lyh | 21 | * @author :lyh |
| @@ -46,21 +34,21 @@ class AiBlogController extends BaseController | @@ -46,21 +34,21 @@ class AiBlogController extends BaseController | ||
| 46 | } | 34 | } |
| 47 | 35 | ||
| 48 | /** | 36 | /** |
| 49 | - * @remark :删除 | ||
| 50 | - * @name :delete | 37 | + * @remark :获取详情数据 |
| 38 | + * @name :getAuthorInfo | ||
| 51 | * @author :lyh | 39 | * @author :lyh |
| 52 | * @method :post | 40 | * @method :post |
| 53 | - * @time :2025/2/20 18:19 | 41 | + * @time :2025/2/21 13:54 |
| 54 | */ | 42 | */ |
| 55 | - public function delete(AiBlogLogic $aiBlogLogic) | ||
| 56 | - { | 43 | + public function getAuthorInfo(AiBlogAuthor $aiBlogAuthor){ |
| 57 | $this->request->validate([ | 44 | $this->request->validate([ |
| 58 | - 'ids'=>['required', new Ids()] | 45 | + 'id'=>['required'], |
| 59 | ],[ | 46 | ],[ |
| 60 | - 'ids.required' => 'ID不能为空' | 47 | + 'id.required' => '主键不能为空', |
| 61 | ]); | 48 | ]); |
| 62 | - $aiBlogLogic->blogDelete(); | ||
| 63 | - $this->response('success'); | 49 | + $info = $aiBlogAuthor->read($this->map); |
| 50 | + $info['image'] = getImageUrl($info['image']); | ||
| 51 | + $this->response('success',Code::SUCCESS,$info); | ||
| 64 | } | 52 | } |
| 65 | 53 | ||
| 66 | /** | 54 | /** |
| @@ -115,37 +103,80 @@ class AiBlogController extends BaseController | @@ -115,37 +103,80 @@ class AiBlogController extends BaseController | ||
| 115 | } | 103 | } |
| 116 | 104 | ||
| 117 | /** | 105 | /** |
| 118 | - * @remark :获取详情数据 | ||
| 119 | - * @name :getAuthorInfo | 106 | + * @remark :Ai博客发布 |
| 107 | + * @name :save | ||
| 108 | + * @author :lyh | ||
| 109 | + * @method :post | ||
| 110 | + * @time :2023/7/5 14:33 | ||
| 111 | + */ | ||
| 112 | + public function save(AiBlogRequest $aiBlogRequest,AiBlogLogic $aiBlogLogic){ | ||
| 113 | + $aiBlogRequest->validated(); | ||
| 114 | + $aiBlogLogic->blogSave(); | ||
| 115 | + $this->response('success'); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + | ||
| 119 | + /** | ||
| 120 | + * @remark :编辑作者详情数据 | ||
| 121 | + * @name :saveBlogAuthor | ||
| 120 | * @author :lyh | 122 | * @author :lyh |
| 121 | * @method :post | 123 | * @method :post |
| 122 | * @time :2025/2/21 13:54 | 124 | * @time :2025/2/21 13:54 |
| 123 | */ | 125 | */ |
| 124 | - public function getAuthorInfo(AiBlogAuthor $aiBlogAuthor){ | 126 | + public function saveBlogAuthor(AiBlogLogic $aiBlogLogic){ |
| 125 | $this->request->validate([ | 127 | $this->request->validate([ |
| 126 | 'id'=>['required'], | 128 | 'id'=>['required'], |
| 127 | ],[ | 129 | ],[ |
| 128 | 'id.required' => '主键不能为空', | 130 | 'id.required' => '主键不能为空', |
| 129 | ]); | 131 | ]); |
| 130 | - $info = $aiBlogAuthor->read($this->map); | ||
| 131 | - $info['image'] = getImageUrl($info['image']); | 132 | + $info = $aiBlogLogic->saveBlogAuthor(); |
| 132 | $this->response('success',Code::SUCCESS,$info); | 133 | $this->response('success',Code::SUCCESS,$info); |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 135 | /** | 136 | /** |
| 136 | - * @remark :编辑详情数据 | ||
| 137 | - * @name :saveBlogAuthor | 137 | + * @remark :删除 |
| 138 | + * @name :delete | ||
| 138 | * @author :lyh | 139 | * @author :lyh |
| 139 | * @method :post | 140 | * @method :post |
| 140 | - * @time :2025/2/21 13:54 | 141 | + * @time :2025/2/20 18:19 |
| 141 | */ | 142 | */ |
| 142 | - public function saveBlogAuthor(AiBlogLogic $aiBlogLogic){ | 143 | + public function delete(AiBlogLogic $aiBlogLogic) |
| 144 | + { | ||
| 145 | + $this->request->validate([ | ||
| 146 | + 'ids'=>['required', new Ids()] | ||
| 147 | + ],[ | ||
| 148 | + 'ids.required' => 'ID不能为空' | ||
| 149 | + ]); | ||
| 150 | + $aiBlogLogic->blogDelete(); | ||
| 151 | + $this->response('success'); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + /** | ||
| 155 | + * @remark :获取列表页数据 | ||
| 156 | + * @name :getAiBlogList | ||
| 157 | + * @author :lyh | ||
| 158 | + * @method :post | ||
| 159 | + * @time :2025/2/21 16:22 | ||
| 160 | + */ | ||
| 161 | + public function getAiBlogList(AiBlogList $aiBlogList){ | ||
| 162 | + $lists = $aiBlogList->lists($this->map,$this->page,$this->row,'id',['id','route','created_at','updated_at']); | ||
| 163 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + /** | ||
| 167 | + * @remark :获取列表页数据详情 | ||
| 168 | + * @name :getAiBlogListInfo | ||
| 169 | + * @author :lyh | ||
| 170 | + * @method :post | ||
| 171 | + * @time :2025/2/21 16:26 | ||
| 172 | + */ | ||
| 173 | + public function getAiBlogListInfo(AiBlogList $aiBlogList){ | ||
| 143 | $this->request->validate([ | 174 | $this->request->validate([ |
| 144 | 'id'=>['required'], | 175 | 'id'=>['required'], |
| 145 | ],[ | 176 | ],[ |
| 146 | 'id.required' => '主键不能为空', | 177 | 'id.required' => '主键不能为空', |
| 147 | ]); | 178 | ]); |
| 148 | - $info = $aiBlogLogic->saveBlogAuthor(); | 179 | + $info = $aiBlogList->read($this->map); |
| 149 | $this->response('success',Code::SUCCESS,$info); | 180 | $this->response('success',Code::SUCCESS,$info); |
| 150 | } | 181 | } |
| 151 | } | 182 | } |
| @@ -216,7 +216,7 @@ class ProjectLogic extends BaseLogic | @@ -216,7 +216,7 @@ class ProjectLogic extends BaseLogic | ||
| 216 | if($aiSettingInfo === false){ | 216 | if($aiSettingInfo === false){ |
| 217 | $aiBlogService = new AiBlogService(); | 217 | $aiBlogService = new AiBlogService(); |
| 218 | $result = $aiBlogService->createProject($title,$languageInfo['short'],$projectInfo['company']); | 218 | $result = $aiBlogService->createProject($title,$languageInfo['short'],$projectInfo['company']); |
| 219 | - if($result['status'] == 200){ | 219 | + if(isset($result['status']) && $result['status'] == 200){ |
| 220 | //查看当前项目是否已有记录 | 220 | //查看当前项目是否已有记录 |
| 221 | $resData = [ | 221 | $resData = [ |
| 222 | 'project_id'=>$project_id, | 222 | 'project_id'=>$project_id, |
| @@ -232,15 +232,7 @@ class ProjectLogic extends BaseLogic | @@ -232,15 +232,7 @@ class ProjectLogic extends BaseLogic | ||
| 232 | $aiBlogService = new AiBlogService(); | 232 | $aiBlogService = new AiBlogService(); |
| 233 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 233 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 234 | $aiBlogService->key = $aiSettingInfo['key']; | 234 | $aiBlogService->key = $aiSettingInfo['key']; |
| 235 | - $result = $aiBlogService->updatedProject($title,$languageInfo['short']); | ||
| 236 | - if($result['status'] == 200){ | ||
| 237 | - $resData = [ | ||
| 238 | - 'mch_id'=>$result['data']['mch_id'], | ||
| 239 | - 'key'=>$result['data']['key'], | ||
| 240 | - ]; | ||
| 241 | - $aiSettingModel = new ProjectAiSetting(); | ||
| 242 | - $aiSettingModel->edit($resData,['project_id'=>$project_id]); | ||
| 243 | - } | 235 | + $aiBlogService->updatedProject($title,$languageInfo['short']); |
| 244 | } | 236 | } |
| 245 | } | 237 | } |
| 246 | return true; | 238 | return true; |
| @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Ai; | @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Ai; | ||
| 5 | use App\Helper\Translate; | 5 | use App\Helper\Translate; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 6 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Ai\AiBlog; | 7 | use App\Models\Ai\AiBlog; |
| 8 | +use App\Models\Ai\AiBlogAuthor; | ||
| 8 | use App\Models\Project\AiBlogTask; | 9 | use App\Models\Project\AiBlogTask; |
| 9 | use App\Models\Project\Project; | 10 | use App\Models\Project\Project; |
| 10 | use App\Models\Project\ProjectAiSetting; | 11 | use App\Models\Project\ProjectAiSetting; |
| @@ -21,6 +22,22 @@ class AiBlogLogic extends BaseLogic | @@ -21,6 +22,22 @@ class AiBlogLogic extends BaseLogic | ||
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 25 | + * @remark :获取配置信息 | ||
| 26 | + * @name :getProjectAiSetting | ||
| 27 | + * @author :lyh | ||
| 28 | + * @method :post | ||
| 29 | + * @time :2025/2/21 14:51 | ||
| 30 | + */ | ||
| 31 | + public function getProjectAiSetting(){ | ||
| 32 | + $projectAiSettingModel = new ProjectAiSetting(); | ||
| 33 | + $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 34 | + if($aiSettingInfo === false){ | ||
| 35 | + $this->fail('请先联系管理员开启Ai博客'); | ||
| 36 | + } | ||
| 37 | + return $aiSettingInfo; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 24 | * @remark :ai发布博客 | 41 | * @remark :ai发布博客 |
| 25 | * @name :blogSave | 42 | * @name :blogSave |
| 26 | * @author :lyh | 43 | * @author :lyh |
| @@ -46,22 +63,6 @@ class AiBlogLogic extends BaseLogic | @@ -46,22 +63,6 @@ class AiBlogLogic extends BaseLogic | ||
| 46 | } | 63 | } |
| 47 | 64 | ||
| 48 | /** | 65 | /** |
| 49 | - * @remark :获取配置信息 | ||
| 50 | - * @name :getProjectAiSetting | ||
| 51 | - * @author :lyh | ||
| 52 | - * @method :post | ||
| 53 | - * @time :2025/2/21 14:51 | ||
| 54 | - */ | ||
| 55 | - public function getProjectAiSetting(){ | ||
| 56 | - $projectAiSettingModel = new ProjectAiSetting(); | ||
| 57 | - $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 58 | - if($aiSettingInfo === false){ | ||
| 59 | - $this->fail('请先联系管理员开启Ai博客'); | ||
| 60 | - } | ||
| 61 | - return $aiSettingInfo; | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - /** | ||
| 65 | * @remark :编辑作者 | 66 | * @remark :编辑作者 |
| 66 | * @name :saveAuthor | 67 | * @name :saveAuthor |
| 67 | * @author :lyh | 68 | * @author :lyh |
| @@ -70,11 +71,14 @@ class AiBlogLogic extends BaseLogic | @@ -70,11 +71,14 @@ class AiBlogLogic extends BaseLogic | ||
| 70 | */ | 71 | */ |
| 71 | public function saveBlogAuthor(){ | 72 | public function saveBlogAuthor(){ |
| 72 | try { | 73 | try { |
| 74 | + $aiAuthorModel = new AiBlogAuthor(); | ||
| 73 | if(!empty($this->param['image'])){ | 75 | if(!empty($this->param['image'])){ |
| 74 | $this->param['image'] = str_replace_url($this->param['image']); | 76 | $this->param['image'] = str_replace_url($this->param['image']); |
| 75 | } | 77 | } |
| 76 | $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']); | 78 | $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $this->param['id'], $this->user['project_id']); |
| 77 | - $this->model->edit($this->param,['id'=>$this->param['id']]); | 79 | + $aiAuthorModel->edit($this->param,['id'=>$this->param['id']]); |
| 80 | + $aiBlogService = new AiBlogService(); | ||
| 81 | + $aiBlogService->updateAuthorInfo(['author_id'=>$this->param['author_id'],'title'=>$this->param['title'],'picture'=>$this->param['image'],'description'=>$this->param['description']]); | ||
| 78 | }catch (\Exception $e){ | 82 | }catch (\Exception $e){ |
| 79 | $this->fail('保存失败,请联系管理员'); | 83 | $this->fail('保存失败,请联系管理员'); |
| 80 | } | 84 | } |
| @@ -87,6 +91,8 @@ class AiBlogLogic extends BaseLogic | @@ -87,6 +91,8 @@ class AiBlogLogic extends BaseLogic | ||
| 87 | * @author :lyh | 91 | * @author :lyh |
| 88 | * @method :post | 92 | * @method :post |
| 89 | * @time :2025/2/14 10:28 | 93 | * @time :2025/2/14 10:28 |
| 94 | + * @detail :type=2/生成文章 type=3/更新列表页记录 | ||
| 95 | + * @detail :status=1/待执行 | ||
| 90 | */ | 96 | */ |
| 91 | public function sendTask(){ | 97 | public function sendTask(){ |
| 92 | $aiSettingInfo = $this->getProjectAiSetting(); | 98 | $aiSettingInfo = $this->getProjectAiSetting(); |
| @@ -97,31 +103,20 @@ class AiBlogLogic extends BaseLogic | @@ -97,31 +103,20 @@ class AiBlogLogic extends BaseLogic | ||
| 97 | $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']); | 103 | $result = $aiBlogService->createTask($this->param['keyword'],$this->param['type']); |
| 98 | if($result['status'] == 200){ | 104 | if($result['status'] == 200){ |
| 99 | $aiBlogTaskModel = new AiBlogTask(); | 105 | $aiBlogTaskModel = new AiBlogTask(); |
| 100 | - $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'task_id'=>$result['data']['task_id'],'status'=>$result['data']['status']]); | 106 | + $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]); |
| 107 | + //增加一条更新列表页的记录 | ||
| 108 | + $aiThreeInfo = $aiBlogTaskModel->read(['project_id'=>$this->user['project_id'],'type'=>3,'status'=>1]); | ||
| 109 | + if($aiThreeInfo === false){ | ||
| 110 | + $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>3,'status'=>1]); | ||
| 111 | + } | ||
| 101 | $aiBlogModel = new AiBlog(); | 112 | $aiBlogModel = new AiBlog(); |
| 102 | - $aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>$result['data']['status'], 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'], | 113 | + $aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>1, 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'], |
| 103 | ]); | 114 | ]); |
| 104 | } | 115 | } |
| 105 | return $this->success(); | 116 | return $this->success(); |
| 106 | } | 117 | } |
| 107 | 118 | ||
| 108 | /** | 119 | /** |
| 109 | - * @remark :创建作者 | ||
| 110 | - * @name :createAuthor | ||
| 111 | - * @author :lyh | ||
| 112 | - * @method :post | ||
| 113 | - * @time :2025/2/20 10:46 | ||
| 114 | - */ | ||
| 115 | - public function createAuthor(){ | ||
| 116 | - $aiSettingInfo = $this->getProjectAiSetting(); | ||
| 117 | - $aiBlogService = new AiBlogService(); | ||
| 118 | - $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 119 | - $aiBlogService->key = $aiSettingInfo['key']; | ||
| 120 | - $result = $aiBlogService->createAuthor(); | ||
| 121 | - return $this->success($result); | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | - /** | ||
| 125 | * @remark :删除 | 120 | * @remark :删除 |
| 126 | * @name :blogDelete | 121 | * @name :blogDelete |
| 127 | * @author :lyh | 122 | * @author :lyh |
| @@ -140,4 +135,5 @@ class AiBlogLogic extends BaseLogic | @@ -140,4 +135,5 @@ class AiBlogLogic extends BaseLogic | ||
| 140 | } | 135 | } |
| 141 | return $this->success(); | 136 | return $this->success(); |
| 142 | } | 137 | } |
| 138 | + | ||
| 143 | } | 139 | } |
app/Models/Ai/AiBlogList.php
0 → 100644
| @@ -198,4 +198,39 @@ class AiBlogService | @@ -198,4 +198,39 @@ class AiBlogService | ||
| 198 | $result = http_post($request_url,json_encode($param,true)); | 198 | $result = http_post($request_url,json_encode($param,true)); |
| 199 | return $result; | 199 | return $result; |
| 200 | } | 200 | } |
| 201 | + | ||
| 202 | + /** | ||
| 203 | + * @remark :获取列表页数据 | ||
| 204 | + * @name :getAiBlogList | ||
| 205 | + * @author :lyh | ||
| 206 | + * @method :post | ||
| 207 | + * @time :2025/2/21 15:51 | ||
| 208 | + */ | ||
| 209 | + public function getAiBlogList($page,$page_size){ | ||
| 210 | + $request_url = $this->url.'api/result/list'; | ||
| 211 | + $param['mch_id'] = $this->mch_id; | ||
| 212 | + $param['page'] = $page; | ||
| 213 | + $param['page_size'] = $page_size; | ||
| 214 | + $this->sign = $this->generateSign($param,$this->key); | ||
| 215 | + $param['sign'] = $this->sign; | ||
| 216 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 217 | + return $result; | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + /** | ||
| 221 | + * @remark :修改作者信息 | ||
| 222 | + * @name :updateAuthorInfo | ||
| 223 | + * @author :lyh | ||
| 224 | + * @method :post | ||
| 225 | + * @time :2025/2/21 16:00 | ||
| 226 | + * @param :author_id ,title , picture, description | ||
| 227 | + */ | ||
| 228 | + public function updateAuthorInfo($param){ | ||
| 229 | + $request_url = $this->url.'api/author/update'; | ||
| 230 | + $param['mch_id'] = $this->mch_id; | ||
| 231 | + $this->sign = $this->generateSign($param,$this->key); | ||
| 232 | + $param['sign'] = $this->sign; | ||
| 233 | + $result = http_post($request_url,json_encode($param,true)); | ||
| 234 | + return $result; | ||
| 235 | + } | ||
| 201 | } | 236 | } |
-
请 注册 或 登录 后发表评论