作者 邓超

自定义页面

@@ -60,8 +60,11 @@ class CustomController extends BaseController @@ -60,8 +60,11 @@ class CustomController extends BaseController
60 */ 60 */
61 public function index(){ 61 public function index(){
62 62
  63 + // 每页数量
  64 + $limit = intval($this->param['limit']??20);
63 65
64 - $lists = BCustom::_all($this->user['project_id'])->toArray(); 66 +
  67 + $lists = BCustom::_all($this->user['project_id'],$limit)->toArray();
65 68
66 69
67 return $this->success($lists); 70 return $this->success($lists);
@@ -4,16 +4,14 @@ namespace App\Http\Controllers\Bside; @@ -4,16 +4,14 @@ namespace App\Http\Controllers\Bside;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Exceptions\BsideGlobalException; 6 use App\Exceptions\BsideGlobalException;
7 -use App\Models\Template\AHeadFoot;  
8 -use App\Models\Template\BCustom;  
9 -use App\Models\Template\BHeadFoot; 7 +use App\Models\Template\ATemplate;
10 use App\Models\Template\BTemplate; 8 use App\Models\Template\BTemplate;
11 use Illuminate\Support\Facades\DB; 9 use Illuminate\Support\Facades\DB;
12 10
13 /** 11 /**
14 - * 自定义 页面 12 + * 模板
15 * @author:dc 13 * @author:dc
16 - * @time 2023/5/4 15:59 14 + * @time 2023/5/9 14:00
17 * Class TemplateController 15 * Class TemplateController
18 * @package App\Http\Controllers\Bside 16 * @package App\Http\Controllers\Bside
19 */ 17 */
@@ -22,141 +20,26 @@ class TemplateController extends BaseController @@ -22,141 +20,26 @@ class TemplateController extends BaseController
22 20
23 21
24 /** 22 /**
25 - * 头部底部的 html 23 + * 列表
26 * @return \Illuminate\Http\JsonResponse 24 * @return \Illuminate\Http\JsonResponse
27 - * @throws \Psr\Container\ContainerExceptionInterface  
28 - * @throws \Psr\Container\NotFoundExceptionInterface  
29 * @author:dc 25 * @author:dc
30 - * @time 2023/5/4 16:15 26 + * @time 2023/5/9 14:20
31 */ 27 */
32 public function index(){ 28 public function index(){
33 29
34 - $data = BTemplate::_get($this->user['project_id']); 30 + $limit = intval($this->param['limit']??20);
35 31
36 - // todo::这里要进行html的替换  
37 32
  33 + $data = ATemplate::_bAll($limit);
38 34
39 35
40 - return $this->success($data);  
41 - }  
42 -  
43 -  
44 - /**  
45 - * 读取编辑的html  
46 - * @author:dc  
47 - * @time 2023/5/4 16:19  
48 - */  
49 - public function edit_html(){  
50 - $data = BHeadFoot::_get($this->user['project_id']);  
51 -  
52 - if(!$data){  
53 - $data = AHeadFoot::_bDefault();  
54 - }  
55 -  
56 - return $this->success([  
57 - 'header' => $data[BHeadFoot::TYPE_HEADER]??'',  
58 - 'footer' => $data[BHeadFoot::TYPE_FOOTER]??'',  
59 - ]);  
60 - }  
61 -  
62 - /**  
63 - * 保存  
64 - * @author:dc  
65 - * @time 2023/5/4 17:42  
66 - */  
67 - public function edit_save(){  
68 -  
69 - $header = $this->param['header']??'';  
70 -  
71 - $footer = $this->param['footer']??'';  
72 -  
73 - if(!$header && !$footer){  
74 - throw new BsideGlobalException('B01024','不能为空');  
75 - }  
76 -  
77 - DB::beginTransaction();  
78 -  
79 - try {  
80 - if($header){  
81 - BHeadFoot::_save($this->user['project_id'],BHeadFoot::TYPE_HEADER,$header);  
82 - }  
83 -  
84 - if($footer){  
85 - BHeadFoot::_save($this->user['project_id'],BHeadFoot::TYPE_FOOTER,$footer);  
86 - }  
87 - }catch (\Throwable $e){  
88 - DB::rollBack();  
89 -  
90 - throw new BsideGlobalException('B01024','保存失败');  
91 - }  
92 -  
93 - DB::commit();  
94 -  
95 -  
96 - $this->success([]);  
97 -  
98 - }  
99 -  
100 -  
101 - /**  
102 - * 获取系统的模板  
103 - * @author:dc  
104 - * @time 2023/5/4 16:21  
105 - */  
106 - public function system_all_html(){  
107 36
108 - $data = AHeadFoot::_ball();  
109 -  
110 - $lists = [];  
111 - // 以名字为单位区分  
112 - foreach ($data as $datum){  
113 - if(empty($lists[$datum['name']])) $lists[$datum['name']] = [];  
114 - $lists[$datum['name']]['name'] = $datum['name'];  
115 - $lists[$datum['name']]['default'] = $datum['is_default'];  
116 - $lists[$datum['name']][$datum['type']==AHeadFoot::TYPE_HEADER?'header':'footer'] = $datum['html'];  
117 - }  
118 -  
119 -  
120 - return $this->success(array_values($lists));  
121 -  
122 - }  
123 -  
124 -  
125 -  
126 -  
127 -  
128 -  
129 -  
130 -  
131 - /**  
132 - * 自定义 列表  
133 - * @author:dc  
134 - * @time 2023/5/4 17:13  
135 - */  
136 - public function custom(){  
137 -  
138 - $data = BCustom::_all($this->user['project_id']);  
139 -  
140 -  
141 - return $this->success($data->toArray());  
142 - }  
143 -  
144 -  
145 - public function custom_create(){  
146 -  
147 - }  
148 -  
149 - public function custom_edit($id){  
150 -  
151 - }  
152 -  
153 - public function custom_delete($id){  
154 37
  38 + return $this->success($data);
155 } 39 }
156 40
157 41
158 42
159 43
160 44
161 -  
162 } 45 }
@@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; @@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
14 class BCustom extends Base 14 class BCustom extends Base
15 { 15 {
16 16
17 - protected $table = 'gl_bside_template_custom'; 17 + protected $table = 'gl_web_custom';
18 18
19 use SoftDeletes; 19 use SoftDeletes;
20 20
@@ -87,13 +87,14 @@ class BCustom extends Base @@ -87,13 +87,14 @@ class BCustom extends Base
87 * @author:dc 87 * @author:dc
88 * @time 2023/5/8 16:29 88 * @time 2023/5/8 16:29
89 */ 89 */
90 - public static function _all(int $project_id) 90 + public static function _all(int $project_id, int $limit = 20)
91 { 91 {
92 return static::where(function ($query) use ($project_id){ 92 return static::where(function ($query) use ($project_id){
93 // 那个公司 93 // 那个公司
94 $query->where('project_id',$project_id); 94 $query->where('project_id',$project_id);
95 }) 95 })
96 - ->get(['id','name','title','status','url','keywords','description','created_at','updated_at']); 96 + ->select(['id','name','title','status','url','keywords','description','created_at','updated_at'])
  97 + ->paginate($limit);
97 } 98 }
98 99
99 /** 100 /**
@@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; @@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
14 class BNav extends Base 14 class BNav extends Base
15 { 15 {
16 16
17 - protected $table = 'gl_bside_nav'; 17 + protected $table = 'gl_web_nav';
18 18
19 use SoftDeletes; 19 use SoftDeletes;
20 20
1 -<?php  
2 -  
3 -namespace App\Models\Template;  
4 -  
5 -/**  
6 - * 头部底部  
7 - * @author:dc  
8 - * @time 2023/5/4 15:52  
9 - * Class AHeadFoot  
10 - * @package App\Models\Template  
11 - */  
12 -class AHeadFoot extends \App\Models\Base{  
13 -  
14 - protected $table = 'gl_aside_template_header_footer';  
15 -  
16 -// 分开存 头底 为了方便后期可能会 改版为 随意搭配 头底部  
17 - const TYPE_HEADER = 'H';  
18 - const TYPE_FOOTER = 'F';  
19 -  
20 - const STATUS_ACTIVE = 1;  
21 - const STATUS_DISABLED = 0;  
22 -  
23 - const IS_DEFAULT = 1;  
24 -  
25 -  
26 - /**  
27 - * b 端 查询  
28 - * @return mixed  
29 - * @author:dc  
30 - * @time 2023/5/4 16:24  
31 - */  
32 - public static function _ball(){  
33 - return static::where('status',static::STATUS_ACTIVE)->orderBy('sort')->get(['id','name','type','html','is_default']);  
34 - }  
35 -  
36 - /**  
37 - * b 端 读取默认的一个头部底部  
38 - * @return mixed  
39 - * @author:dc  
40 - * @time 2023/5/4 16:51  
41 - */  
42 - public static function _bDefault(){  
43 - return static::where(['status'=>static::STATUS_ACTIVE,'is_default'=>static::IS_DEFAULT])  
44 - ->get(['type','html'])  
45 - ->pluck('html','type')  
46 - ->toArray();  
47 - }  
48 -  
49 -  
50 -  
51 -  
52 -}  
  1 +<?php
  2 +
  3 +namespace App\Models\Template;
  4 +
  5 +use Illuminate\Database\Eloquent\SoftDeletes;
  6 +
  7 +/**
  8 + * 由 A端增删改
  9 + * 模板
  10 + * @author:dc
  11 + * @time 2023/5/9 13:56
  12 + * Class ATemplate
  13 + * @package App\Models\Template
  14 + */
  15 +class ATemplate extends \App\Models\Base{
  16 +
  17 +
  18 + protected $table = 'gl_aside_template';
  19 +
  20 +
  21 + protected $hidden = ['deleted_at'];
  22 +
  23 +
  24 + use SoftDeletes;
  25 +
  26 + /**
  27 + * 显示
  28 + */
  29 + const STATUS_ACTIVE = 1;
  30 +
  31 + /**
  32 + * 隐藏
  33 + */
  34 + const STATUS_DISABLED = 0;
  35 +
  36 +
  37 + /**
  38 + * b 端调用
  39 + * @param int $limit
  40 + * @return mixed
  41 + * @author:dc
  42 + * @time 2023/5/9 14:14
  43 + */
  44 + public static function _bAll(int $limit = 20)
  45 + {
  46 + return static::where(function ($query){
  47 +
  48 + $query->where('status',static::STATUS_ACTIVE);
  49 +
  50 + })
  51 + ->select(['id','name','url','thumb','created_at','updated_at'])
  52 + ->orderBy('sort')
  53 + ->paginate($limit);
  54 + }
  55 +
  56 +
  57 +
  58 +
  59 +}
@@ -11,7 +11,7 @@ namespace App\Models\Template; @@ -11,7 +11,7 @@ namespace App\Models\Template;
11 */ 11 */
12 class BTemplate extends \App\Models\Base{ 12 class BTemplate extends \App\Models\Base{
13 13
14 - protected $table = 'gl_bside_template_html'; 14 + protected $table = 'gl_web_template_html';
15 15
16 16
17 17