正在显示
7 个修改的文件
包含
94 行增加
和
23 行删除
| @@ -161,4 +161,20 @@ class NewsCategoryController extends BaseController | @@ -161,4 +161,20 @@ class NewsCategoryController extends BaseController | ||
| 161 | $this->response('success'); | 161 | $this->response('success'); |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | + /** | ||
| 165 | + * @remark :复制新闻分类 | ||
| 166 | + * @name :copyCategory | ||
| 167 | + * @author :lyh | ||
| 168 | + * @method :post | ||
| 169 | + * @time :2024/5/9 9:14 | ||
| 170 | + */ | ||
| 171 | + public function copyCategory(NewsCategoryLogic $newsLogic){ | ||
| 172 | + $this->request->validate([ | ||
| 173 | + 'id'=>'required', | ||
| 174 | + ],[ | ||
| 175 | + 'id.required' => 'id不能为空', | ||
| 176 | + ]); | ||
| 177 | + $data = $newsLogic->copyCategory(); | ||
| 178 | + $this->response('success',Code::SUCCESS,$data); | ||
| 179 | + } | ||
| 164 | } | 180 | } |
| @@ -459,7 +459,7 @@ class BlogLogic extends BaseLogic | @@ -459,7 +459,7 @@ class BlogLogic extends BaseLogic | ||
| 459 | foreach ($list as $v){ | 459 | foreach ($list as $v){ |
| 460 | $data[] = [ | 460 | $data[] = [ |
| 461 | 'html'=>$v['html'], | 461 | 'html'=>$v['html'], |
| 462 | - 'project_id'=>$project_id, | 462 | + 'project_id'=>$v['project_id'], |
| 463 | 'source'=>$v['source'], | 463 | 'source'=>$v['source'], |
| 464 | 'source_id'=>$save_id, | 464 | 'source_id'=>$save_id, |
| 465 | 'template_id'=>$v['template_id'], | 465 | 'template_id'=>$v['template_id'], |
| @@ -9,6 +9,7 @@ use App\Models\News\News as NewsModel; | @@ -9,6 +9,7 @@ use App\Models\News\News as NewsModel; | ||
| 9 | use App\Models\News\NewsCategory as NewsCategoryModel; | 9 | use App\Models\News\NewsCategory as NewsCategoryModel; |
| 10 | use App\Models\Product\Product; | 10 | use App\Models\Product\Product; |
| 11 | use App\Models\RouteMap\RouteMap; | 11 | use App\Models\RouteMap\RouteMap; |
| 12 | +use App\Models\Template\BTemplate; | ||
| 12 | use Illuminate\Support\Facades\DB; | 13 | use Illuminate\Support\Facades\DB; |
| 13 | 14 | ||
| 14 | class NewsCategoryLogic extends BaseLogic | 15 | class NewsCategoryLogic extends BaseLogic |
| @@ -268,4 +269,70 @@ class NewsCategoryLogic extends BaseLogic | @@ -268,4 +269,70 @@ class NewsCategoryLogic extends BaseLogic | ||
| 268 | } | 269 | } |
| 269 | return $this->success(); | 270 | return $this->success(); |
| 270 | } | 271 | } |
| 272 | + | ||
| 273 | + /** | ||
| 274 | + * @remark :复制新闻分类 | ||
| 275 | + * @name :copyCategory | ||
| 276 | + * @author :lyh | ||
| 277 | + * @method :post | ||
| 278 | + * @time :2024/5/9 9:16 | ||
| 279 | + */ | ||
| 280 | + public function copyCategory(){ | ||
| 281 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 282 | + $param = [ | ||
| 283 | + 'name'=>$info['name']."-copy", | ||
| 284 | + 'status'=>0, | ||
| 285 | + 'sort'=>$info['sort'], | ||
| 286 | + 'pid'=>0, | ||
| 287 | + 'remark'=>$info['remark'], | ||
| 288 | + 'alias'=>$info['alias'], | ||
| 289 | + 'project_id'=>$info['project_id'], | ||
| 290 | + 'operator_id'=>$this->user['id'], | ||
| 291 | + 'create_id'=>$this->user['id'], | ||
| 292 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 293 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 294 | + ]; | ||
| 295 | + $save_id = $this->model->insertGetId($param); | ||
| 296 | + $route = RouteMap::setRoute($param['alias'], RouteMap::SOURCE_NEWS_CATE, $save_id, $this->user['project_id']); | ||
| 297 | + $this->model->edit(['alias'=>$route],['id'=>$save_id]); | ||
| 298 | + //同步可视化装修数据 | ||
| 299 | + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); | ||
| 300 | + return $this->success(['id'=>$save_id]); | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + /** | ||
| 304 | + * @remark :同步模版数据 | ||
| 305 | + * @name :copyTemplate | ||
| 306 | + * @author :lyh | ||
| 307 | + * @method :post | ||
| 308 | + * @time :2023/7/29 15:53 | ||
| 309 | + */ | ||
| 310 | + public function copyTemplate($id,$project_id,$save_id){ | ||
| 311 | + $BTemplateModel = new BTemplate(); | ||
| 312 | + $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_NEWS,'is_list'=>BTemplate::IS_LIST,'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]); | ||
| 313 | + if(!empty($list)){ | ||
| 314 | + $data = []; | ||
| 315 | + foreach ($list as $v){ | ||
| 316 | + $data[] = [ | ||
| 317 | + 'html'=>$v['html'], | ||
| 318 | + 'project_id'=>$v['project_id'], | ||
| 319 | + 'source'=>$v['source'], | ||
| 320 | + 'source_id'=>$save_id, | ||
| 321 | + 'template_id'=>$v['template_id'], | ||
| 322 | + 'section_list_id'=>$v['section_list_id'], | ||
| 323 | + 'main_html'=>$v['main_html'], | ||
| 324 | + 'main_css'=>$v['main_css'], | ||
| 325 | + 'is_list'=>$v['is_list'], | ||
| 326 | + 'type'=>$v['type'], | ||
| 327 | + 'created_at'=>date('Y-m-d H:i:s'), | ||
| 328 | + 'updated_at'=>date('Y-m-d H:i:s'), | ||
| 329 | + ]; | ||
| 330 | + } | ||
| 331 | + $rs = $BTemplateModel->insert($data); | ||
| 332 | + if($rs === false){ | ||
| 333 | + $this->fail('error'); | ||
| 334 | + } | ||
| 335 | + } | ||
| 336 | + return $this->success(); | ||
| 337 | + } | ||
| 271 | } | 338 | } |
| @@ -503,7 +503,7 @@ class NewsLogic extends BaseLogic | @@ -503,7 +503,7 @@ class NewsLogic extends BaseLogic | ||
| 503 | foreach ($list as $v){ | 503 | foreach ($list as $v){ |
| 504 | $data[] = [ | 504 | $data[] = [ |
| 505 | 'html'=>$v['html'], | 505 | 'html'=>$v['html'], |
| 506 | - 'project_id'=>$project_id, | 506 | + 'project_id'=>$v['project_id'], |
| 507 | 'source'=>$v['source'], | 507 | 'source'=>$v['source'], |
| 508 | 'source_id'=>$save_id, | 508 | 'source_id'=>$save_id, |
| 509 | 'template_id'=>$v['template_id'], | 509 | 'template_id'=>$v['template_id'], |
| @@ -299,23 +299,6 @@ class CategoryLogic extends BaseLogic | @@ -299,23 +299,6 @@ class CategoryLogic extends BaseLogic | ||
| 299 | if($info === false){ | 299 | if($info === false){ |
| 300 | $this->fail('当前数据不存在或者已被删除'); | 300 | $this->fail('当前数据不存在或者已被删除'); |
| 301 | } | 301 | } |
| 302 | - $param = $this->setCateParams($info); | ||
| 303 | - $save_id = $this->model->addReturnId($param); | ||
| 304 | - $route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT_CATE, $save_id, $this->user['project_id']); | ||
| 305 | - $this->model->edit(['route'=>$route],['id'=>$route]); | ||
| 306 | - //同步可视化装修数据 | ||
| 307 | - $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); | ||
| 308 | - return $this->success(); | ||
| 309 | - } | ||
| 310 | - | ||
| 311 | - /** | ||
| 312 | - * @remark :组装数据 | ||
| 313 | - * @name :setParams | ||
| 314 | - * @author :lyh | ||
| 315 | - * @method :post | ||
| 316 | - * @time :2023/7/29 15:45 | ||
| 317 | - */ | ||
| 318 | - public function setCateParams($info){ | ||
| 319 | $param = [ | 302 | $param = [ |
| 320 | 'project_id'=>$info['project_id'], | 303 | 'project_id'=>$info['project_id'], |
| 321 | 'title'=>$info['title']."-copy", | 304 | 'title'=>$info['title']."-copy", |
| @@ -327,7 +310,12 @@ class CategoryLogic extends BaseLogic | @@ -327,7 +310,12 @@ class CategoryLogic extends BaseLogic | ||
| 327 | 'describe'=>$info['describe'], | 310 | 'describe'=>$info['describe'], |
| 328 | 'describe_image'=>$info['describe_image'], | 311 | 'describe_image'=>$info['describe_image'], |
| 329 | ]; | 312 | ]; |
| 330 | - return $param; | 313 | + $save_id = $this->model->addReturnId($param); |
| 314 | + $route = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT_CATE, $save_id, $this->user['project_id']); | ||
| 315 | + $this->model->edit(['route'=>$route],['id'=>$route]); | ||
| 316 | + //同步可视化装修数据 | ||
| 317 | + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); | ||
| 318 | + return $this->success(); | ||
| 331 | } | 319 | } |
| 332 | 320 | ||
| 333 | /** | 321 | /** |
| @@ -342,7 +330,7 @@ class CategoryLogic extends BaseLogic | @@ -342,7 +330,7 @@ class CategoryLogic extends BaseLogic | ||
| 342 | $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_PRODUCT,'is_list'=>BTemplate::IS_LIST,'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]); | 330 | $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_PRODUCT,'is_list'=>BTemplate::IS_LIST,'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]); |
| 343 | if(!empty($list)){ | 331 | if(!empty($list)){ |
| 344 | $data = []; | 332 | $data = []; |
| 345 | - foreach ($list as $k => $v){ | 333 | + foreach ($list as $v){ |
| 346 | $data[] = $this->setTemplateParams($v,$save_id); | 334 | $data[] = $this->setTemplateParams($v,$save_id); |
| 347 | } | 335 | } |
| 348 | $rs = $BTemplateModel->insert($data); | 336 | $rs = $BTemplateModel->insert($data); |
| @@ -371,7 +359,6 @@ class CategoryLogic extends BaseLogic | @@ -371,7 +359,6 @@ class CategoryLogic extends BaseLogic | ||
| 371 | 'main_html'=>$v['main_html'], | 359 | 'main_html'=>$v['main_html'], |
| 372 | 'main_css'=>$v['main_css'], | 360 | 'main_css'=>$v['main_css'], |
| 373 | 'is_list'=>$v['is_list'], | 361 | 'is_list'=>$v['is_list'], |
| 374 | - 'is_custom'=>$v['is_custom'], | ||
| 375 | 'type'=>$v['type'], | 362 | 'type'=>$v['type'], |
| 376 | 'created_at'=>$v['created_at'], | 363 | 'created_at'=>$v['created_at'], |
| 377 | 'updated_at'=>$v['updated_at'] | 364 | 'updated_at'=>$v['updated_at'] |
| @@ -449,7 +449,7 @@ class ProductLogic extends BaseLogic | @@ -449,7 +449,7 @@ class ProductLogic extends BaseLogic | ||
| 449 | $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_PRODUCT,'is_list'=>BTemplate::IS_DETAIL,'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]); | 449 | $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_PRODUCT,'is_list'=>BTemplate::IS_DETAIL,'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]); |
| 450 | if(!empty($list)){ | 450 | if(!empty($list)){ |
| 451 | $data = []; | 451 | $data = []; |
| 452 | - foreach ($list as $k => $v){ | 452 | + foreach ($list as $v){ |
| 453 | $data[] = $this->setTemplateParams($v,$project_id,$save_id); | 453 | $data[] = $this->setTemplateParams($v,$project_id,$save_id); |
| 454 | } | 454 | } |
| 455 | $rs = $BTemplateModel->insert($data); | 455 | $rs = $BTemplateModel->insert($data); |
| @@ -78,6 +78,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -78,6 +78,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 78 | Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'save'])->name('news_category_edit'); | 78 | Route::any('/category/edit', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'save'])->name('news_category_edit'); |
| 79 | Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del'); | 79 | Route::any('/category/del', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'del'])->name('news_category_del'); |
| 80 | Route::any('/category/allSort', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'allSort'])->name('news_category_allSort'); | 80 | Route::any('/category/allSort', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'allSort'])->name('news_category_allSort'); |
| 81 | + Route::any('/category/copyCategory', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'copyCategory'])->name('news_category_copyCategory'); | ||
| 81 | Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('news_category_status'); | 82 | Route::any('/category/status', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'status'])->name('news_category_status'); |
| 82 | Route::any('/category/sort', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'sort'])->name('news_category_sort'); | 83 | Route::any('/category/sort', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'sort'])->name('news_category_sort'); |
| 83 | Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'categoryTopList'])->name('news_category_categoryTopList'); | 84 | Route::any('/category/categoryTopList', [\App\Http\Controllers\Bside\News\NewsCategoryController::class, 'categoryTopList'])->name('news_category_categoryTopList'); |
-
请 注册 或 登录 后发表评论