作者 lyh

gx

@@ -121,4 +121,24 @@ class BTemplateController extends BaseController @@ -121,4 +121,24 @@ class BTemplateController extends BaseController
121 $this->response('success',Code::SUCCESS,$info); 121 $this->response('success',Code::SUCCESS,$info);
122 } 122 }
123 123
  124 + /**
  125 + * @remark :根据项目保存公共模板
  126 + * @name :savePublicTemplate
  127 + * @author :lyh
  128 + * @method :post
  129 + * @time :2023/9/18 10:58
  130 + */
  131 + public function savePublicTemplate(BTemplateLogic $BTemplateLogic){
  132 + $this->request->validate([
  133 + 'name'=>'required',
  134 + 'html'=>'required',
  135 + 'image'=>'required',
  136 + ],[
  137 + 'name.required' => '模板名称不能为空',
  138 + 'html.required' => 'html不能为空',
  139 + 'image.required' => '模板图片不能为空'
  140 + ]);
  141 + $BTemplateLogic->savePublicTemplateHtml();
  142 + $this->response('模板保存成功');
  143 + }
124 } 144 }
@@ -368,67 +368,10 @@ class BTemplateLogic extends BaseLogic @@ -368,67 +368,10 @@ class BTemplateLogic extends BaseLogic
368 */ 368 */
369 public function getModuleType(): array 369 public function getModuleType(): array
370 { 370 {
371 - //前端会回传:products:1,news:2,blogs:3,productCategory:4  
372 //定义数据结构 371 //定义数据结构
373 - $data = [  
374 - "products"=>[  
375 - "category"=>[  
376 - [  
377 - "id"=>"all",  
378 - "title"=>"全部",  
379 - ],  
380 - [  
381 - "id"=>"hot",  
382 - "title"=>"热销产品",  
383 - ],  
384 - [  
385 - "id"=>"recommend",  
386 - "title"=>"推荐产品",  
387 - ],  
388 - ],  
389 - "imageType"=>[  
390 - [  
391 - "id"=>1,  
392 - "title"=>"产品图片",  
393 - ],[  
394 - "id"=>2,  
395 - "title"=>"产品分类图片",  
396 - ],[  
397 - "id"=>3,  
398 - "title"=>"产品图标",  
399 - ]  
400 - ],  
401 - ],  
402 - "news"=>[  
403 - "category"=>[  
404 - [  
405 - "id"=>"all",  
406 - "name"=>"全部",  
407 - ],  
408 - [  
409 - "id"=>"new",  
410 - "name"=>"最新",  
411 - ],  
412 - ],  
413 - ],  
414 - "blogs"=>[  
415 - "category"=>[  
416 - [  
417 - "id"=>"all",  
418 - "name"=>"全部",  
419 - ],  
420 - [  
421 - "id"=>"new",  
422 - "name"=>"最新",  
423 - ],  
424 - ],  
425 - ]  
426 - ]; 372 + $data = $this->model->product_type;
427 //产品,新闻,博客,一级分类数据 373 //产品,新闻,博客,一级分类数据
428 - $map = [  
429 - 'pid'=>0,  
430 - 'project_id'=>$this->user['project_id']  
431 - ]; 374 + $map = ['pid'=>0, 'project_id'=>$this->user['project_id']];
432 $productCategory = Category::where($map)->get(); 375 $productCategory = Category::where($map)->get();
433 $newCategory = NewsCategory::where($map)->get(); 376 $newCategory = NewsCategory::where($map)->get();
434 $blogCategory = BlogCategory::where($map)->get(); 377 $blogCategory = BlogCategory::where($map)->get();
@@ -451,4 +394,22 @@ class BTemplateLogic extends BaseLogic @@ -451,4 +394,22 @@ class BTemplateLogic extends BaseLogic
451 return $this->success($data); 394 return $this->success($data);
452 } 395 }
453 396
  397 + /**
  398 + * @remark :保存html
  399 + * @name :savePublicTemplateHtml
  400 + * @author :lyh
  401 + * @method :post
  402 + * @time :2023/9/18 11:19
  403 + */
  404 + public function savePublicTemplateHtml(){
  405 + $this->param['project_id'] = $this->user['project_id'];
  406 + $this->param['operator_id'] = $this->user['manager_id'] ?? 0;
  407 + $this->param = $this->stringProcessing($this->param);
  408 + $publicTemplateModel = new Template();
  409 + $rs = $publicTemplateModel->add($this->param);
  410 + if($rs === false){
  411 + $this->fail('系统错误,请联系管理员');
  412 + }
  413 + return $this->success();
  414 + }
454 } 415 }
@@ -35,8 +35,8 @@ class ProductLogic extends BaseLogic @@ -35,8 +35,8 @@ class ProductLogic extends BaseLogic
35 public function productSave(){ 35 public function productSave(){
36 //参数处理 36 //参数处理
37 $this->param = $this->handleSaveParam($this->param); 37 $this->param = $this->handleSaveParam($this->param);
38 -// DB::beginTransaction();  
39 -// try { 38 + DB::beginTransaction();
  39 + try {
40 if(isset($this->param['id']) && !empty($this->param['id'])){ 40 if(isset($this->param['id']) && !empty($this->param['id'])){
41 //查看路由是否更新 41 //查看路由是否更新
42 $id = $this->editProductRoute($this->param['id'],$this->param['route']); 42 $id = $this->editProductRoute($this->param['id'],$this->param['route']);
@@ -50,11 +50,11 @@ class ProductLogic extends BaseLogic @@ -50,11 +50,11 @@ class ProductLogic extends BaseLogic
50 //路由映射 50 //路由映射
51 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); 51 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
52 $this->model->edit(['route'=>$route],['id'=>$id]); 52 $this->model->edit(['route'=>$route],['id'=>$id]);
53 -// DB::commit();  
54 -// }catch (\Exception $e){  
55 -// DB::rollBack();  
56 -// $this->fail('保存失败');  
57 -// } 53 + DB::commit();
  54 + }catch (\Exception $e){
  55 + DB::rollBack();
  56 + $this->fail('保存失败');
  57 + }
58 //通知更新 58 //通知更新
59 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]); 59 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]);
60 return $this->success(); 60 return $this->success();
@@ -99,9 +99,11 @@ class UserLoginLogic @@ -99,9 +99,11 @@ class UserLoginLogic
99 99
100 100
101 /** 101 /**
102 - * 自动登录  
103 - * @author zbj  
104 - * @date 2023/7/25 102 + * @remark :自动登录
  103 + * @name :autologin
  104 + * @author :lyh
  105 + * @method :post
  106 + * @time :2023/9/18 11:00
105 */ 107 */
106 public function autologin($data) 108 public function autologin($data)
107 { 109 {
@@ -25,18 +25,18 @@ class LoginAuthMiddleware @@ -25,18 +25,18 @@ class LoginAuthMiddleware
25 { 25 {
26 $manage = LoginLogic::manage(); 26 $manage = LoginLogic::manage();
27 if (!$manage) { 27 if (!$manage) {
28 - return response(['code'=> Code::USER_LOGIN_ERROE,'msg'=>'当前用户未登录']); 28 + return response(['code'=> Code::USER_LOGIN_ERROE,'message'=>'当前用户未登录']);
29 } 29 }
30 //权限 30 //权限
31 if($manage['id'] != Manage::ADMINISTRATOR_ID){ //排除超级管理员 31 if($manage['id'] != Manage::ADMINISTRATOR_ID){ //排除超级管理员
32 if($manage['status'] != 1){ 32 if($manage['status'] != 1){
33 - return response(['code'=> Code::USER_LOGIN_ERROE,'msg'=>'当前用户被禁用']); 33 + return response(['code'=> Code::USER_LOGIN_ERROE,'message'=>'当前用户被禁用']);
34 } 34 }
35 } 35 }
36 if($manage['gid'] != 0){ 36 if($manage['gid'] != 0){
37 $groupInfo = $this->getGroup($manage); 37 $groupInfo = $this->getGroup($manage);
38 if($groupInfo['status'] != 1){ 38 if($groupInfo['status'] != 1){
39 - return response(['code'=> Code::USER_LOGIN_ERROE,'msg'=>'当前用户角色被禁用']); 39 + return response(['code'=> Code::USER_LOGIN_ERROE,'message'=>'当前用户角色被禁用']);
40 } 40 }
41 //获取当前操作的路由name 41 //获取当前操作的路由name
42 $action = Route::currentRouteName(); 42 $action = Route::currentRouteName();
@@ -45,7 +45,7 @@ class LoginAuthMiddleware @@ -45,7 +45,7 @@ class LoginAuthMiddleware
45 $menu_id = $menuModel->read(['route_name'=>$action],['id']); 45 $menu_id = $menuModel->read(['route_name'=>$action],['id']);
46 if($menu_id !== false){ 46 if($menu_id !== false){
47 if(in_array($menu_id['id'],$groupInfo['rights']) === false){ 47 if(in_array($menu_id['id'],$groupInfo['rights']) === false){
48 - return response(['code'=>Code::USER_PERMISSION_ERROE,'msg'=>'当前用户没有权限']); 48 + return response(['code'=>Code::USER_PERMISSION_ERROE,'message'=>'当前用户没有权限']);
49 } 49 }
50 } 50 }
51 } 51 }
@@ -25,7 +25,7 @@ class LoginAuthMiddleware @@ -25,7 +25,7 @@ class LoginAuthMiddleware
25 $token = $request->header('token'); 25 $token = $request->header('token');
26 $info = Cache::get($token); 26 $info = Cache::get($token);
27 if(empty($info) || empty($token)){ 27 if(empty($info) || empty($token)){
28 - return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'当前用户未登录']); 28 + return response(['code'=>Code::USER_LOGIN_ERROE,'message'=>'当前用户未登录']);
29 } 29 }
30 //0代表超级管理员 30 //0代表超级管理员
31 if($info['role_id'] != 0){ 31 if($info['role_id'] != 0){
@@ -38,7 +38,7 @@ class LoginAuthMiddleware @@ -38,7 +38,7 @@ class LoginAuthMiddleware
38 // 设置数据库 38 // 设置数据库
39 $project = ProjectServer::useProject($info['project_id']); 39 $project = ProjectServer::useProject($info['project_id']);
40 if(empty($project)){ 40 if(empty($project)){
41 - return response(['code'=>Code::USER_LOGIN_ERROE,'msg'=>'数据库未配置']); 41 + return response(['code'=>Code::USER_LOGIN_ERROE,'message'=>'数据库未配置']);
42 } 42 }
43 return $next($request); 43 return $next($request);
44 } 44 }
@@ -56,7 +56,7 @@ class LoginAuthMiddleware @@ -56,7 +56,7 @@ class LoginAuthMiddleware
56 $projectRoleModel = new ProjectRoleModel(); 56 $projectRoleModel = new ProjectRoleModel();
57 $role_info = $projectRoleModel->read(['id'=>$info['role_id']]); 57 $role_info = $projectRoleModel->read(['id'=>$info['role_id']]);
58 if($role_info['status'] != 0){ 58 if($role_info['status'] != 0){
59 - return response(['code'=>Code::USER_LOGIN_ERROE,'当前用户角色被禁用']); 59 + return response(['code'=>Code::USER_LOGIN_ERROE,'message'=>'当前用户角色被禁用']);
60 } 60 }
61 return $role_info; 61 return $role_info;
62 } 62 }
@@ -73,7 +73,7 @@ class LoginAuthMiddleware @@ -73,7 +73,7 @@ class LoginAuthMiddleware
73 $menu_id = $projectMenuModel->read(['action'=>$action],['id']); 73 $menu_id = $projectMenuModel->read(['action'=>$action],['id']);
74 if($menu_id !== false){ 74 if($menu_id !== false){
75 if(strpos($role_info['role_menu'], $menu_id['id']) === false){ 75 if(strpos($role_info['role_menu'], $menu_id['id']) === false){
76 - return response(['code'=>Code::USER_PERMISSION_ERROE,'msg'=>'当前用户没有权限']); 76 + return response(['code'=>Code::USER_PERMISSION_ERROE,'message'=>'当前用户没有权限']);
77 } 77 }
78 } 78 }
79 } 79 }
@@ -27,5 +27,61 @@ class BTemplate extends Base @@ -27,5 +27,61 @@ class BTemplate extends Base
27 '18008059100', 27 '18008059100',
28 '18583337995' 28 '18583337995'
29 ]; 29 ];
  30 +
  31 + //类型数据
  32 + public $product_type = [
  33 + "products"=>[
  34 + "category"=>[
  35 + [
  36 + "id"=>"all",
  37 + "title"=>"全部",
  38 + ],
  39 + [
  40 + "id"=>"hot",
  41 + "title"=>"热销产品",
  42 + ],
  43 + [
  44 + "id"=>"recommend",
  45 + "title"=>"推荐产品",
  46 + ],
  47 + ],
  48 + "imageType"=>[
  49 + [
  50 + "id"=>1,
  51 + "title"=>"产品图片",
  52 + ],[
  53 + "id"=>2,
  54 + "title"=>"产品分类图片",
  55 + ],[
  56 + "id"=>3,
  57 + "title"=>"产品图标",
  58 + ]
  59 + ],
  60 + ],
  61 + "news"=>[
  62 + "category"=>[
  63 + [
  64 + "id"=>"all",
  65 + "name"=>"全部",
  66 + ],
  67 + [
  68 + "id"=>"new",
  69 + "name"=>"最新",
  70 + ],
  71 + ],
  72 + ],
  73 + "blogs"=>[
  74 + "category"=>[
  75 + [
  76 + "id"=>"all",
  77 + "name"=>"全部",
  78 + ],
  79 + [
  80 + "id"=>"new",
  81 + "name"=>"最新",
  82 + ],
  83 + ],
  84 + ]
  85 + ];
30 } 86 }
31 87
@@ -278,6 +278,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -278,6 +278,7 @@ Route::middleware(['bloginauth'])->group(function () {
278 Route::any('/getTypeSetting', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getTypeSetting'])->name('template_getTypeSetting'); 278 Route::any('/getTypeSetting', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getTypeSetting'])->name('template_getTypeSetting');
279 Route::any('/getHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getHeadFooter'])->name('template_getHeadFooter'); 279 Route::any('/getHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getHeadFooter'])->name('template_getHeadFooter');
280 Route::any('/setHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setHeadFooter'])->name('template_setHeadFooter'); 280 Route::any('/setHeadFooter', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'setHeadFooter'])->name('template_setHeadFooter');
  281 + Route::any('/savePublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'savePublicTemplate'])->name('template_savePublicTemplate');
281 // 模板 282 // 模板
282 Route::prefix('module')->group(function () { 283 Route::prefix('module')->group(function () {
283 //获取所有左侧模版 284 //获取所有左侧模版