作者 赵彬吉

update

@@ -63,6 +63,9 @@ class CustomTemplateLogic extends BaseLogic @@ -63,6 +63,9 @@ class CustomTemplateLogic extends BaseLogic
63 $id = $this->editCustomRoute($this->param['id'],$this->param['url']); 63 $id = $this->editCustomRoute($this->param['id'],$this->param['url']);
64 $this->model->edit($this->param,['id'=>$this->param['id']]); 64 $this->model->edit($this->param,['id'=>$this->param['id']]);
65 }else{ 65 }else{
  66 + if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
  67 + $this->fail('404页面已存在');
  68 + }
66 $this->param['project_id'] = $this->user['project_id']; 69 $this->param['project_id'] = $this->user['project_id'];
67 $id = $this->model->addReturnId($this->param); 70 $id = $this->model->addReturnId($this->param);
68 } 71 }
@@ -105,6 +108,9 @@ class CustomTemplateLogic extends BaseLogic @@ -105,6 +108,9 @@ class CustomTemplateLogic extends BaseLogic
105 */ 108 */
106 public function editCustomRoute($id,$route){ 109 public function editCustomRoute($id,$route){
107 $info = $this->model->read(['id'=>$this->param['id']]); 110 $info = $this->model->read(['id'=>$this->param['id']]);
  111 + if($info['url'] == $this->model::NOT_FOUND_PAGE_URL && $route['url'] != '404'){
  112 + $this->fail('404页面链接不可修改');
  113 + }
108 if($info['url'] != $route){ 114 if($info['url'] != $route){
109 //生成一条删除路由记录 115 //生成一条删除路由记录
110 $data = [ 116 $data = [
@@ -128,6 +134,9 @@ class CustomTemplateLogic extends BaseLogic @@ -128,6 +134,9 @@ class CustomTemplateLogic extends BaseLogic
128 if($info === false){ 134 if($info === false){
129 $this->fail('当前数据不存在或者已被删除'); 135 $this->fail('当前数据不存在或者已被删除');
130 } 136 }
  137 + if($info['url'] == $this->model::NOT_FOUND_PAGE_URL){
  138 + $this->fail('404页面不可删除');
  139 + }
131 try { 140 try {
132 if($info['status'] != 2){ 141 if($info['status'] != 2){
133 $this->model->edit(['status'=>2],['id'=>$this->param['id']]); 142 $this->model->edit(['status'=>2],['id'=>$this->param['id']]);
@@ -9,4 +9,6 @@ class BCustomTemplate extends Base @@ -9,4 +9,6 @@ class BCustomTemplate extends Base
9 protected $table = 'gl_web_custom_template'; 9 protected $table = 'gl_web_custom_template';
10 //连接数据库 10 //连接数据库
11 protected $connection = 'custom_mysql'; 11 protected $connection = 'custom_mysql';
  12 +
  13 + const NOT_FOUND_PAGE_URL = '404';
12 } 14 }
@@ -10,6 +10,7 @@ namespace App\Services; @@ -10,6 +10,7 @@ namespace App\Services;
10 10
11 use App\Models\Project\Project; 11 use App\Models\Project\Project;
12 use App\Models\RouteMap\RouteMap; 12 use App\Models\RouteMap\RouteMap;
  13 +use App\Models\Template\BCustomTemplate;
13 use Illuminate\Support\Facades\DB; 14 use Illuminate\Support\Facades\DB;
14 use Illuminate\Support\Facades\Schema; 15 use Illuminate\Support\Facades\Schema;
15 16
@@ -129,7 +130,7 @@ class ProjectServer extends BaseService @@ -129,7 +130,7 @@ class ProjectServer extends BaseService
129 //初始化单页 130 //初始化单页
130 $info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first(); 131 $info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();
131 if(empty($info)) { 132 if(empty($info)) {
132 - $data = ['project_id' => $project_id, 'name' => '404', 'status' => 1, 'url' => '404', 'html' => '<main> 133 + $data = ['project_id' => $project_id, 'name' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'status' => 1, 'url' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'html' => '<main>
133 <section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404" 134 <section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
134 id="sectionIdyxqu938"> 135 id="sectionIdyxqu938">
135 <div class="layout" data-unable="demo01-error404"> 136 <div class="layout" data-unable="demo01-error404">
@@ -159,7 +160,7 @@ class ProjectServer extends BaseService @@ -159,7 +160,7 @@ class ProjectServer extends BaseService
159 //路由 160 //路由
160 $info = DB::connection('custom_mysql')->table('gl_route_map')->first(); 161 $info = DB::connection('custom_mysql')->table('gl_route_map')->first();
161 if(empty($info)) { 162 if(empty($info)) {
162 - $data = ['project_id' => $project_id, 'source' => RouteMap::SOURCE_PAGE, 'source_id' => $id, 'route' => '404', 'created_at' => $created_at, 'updated_at' => $created_at]; 163 + $data = ['project_id' => $project_id, 'source' => RouteMap::SOURCE_PAGE, 'source_id' => $id, 'route' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'created_at' => $created_at, 'updated_at' => $created_at];
163 DB::connection('custom_mysql')->table('gl_route_map')->insert($data); 164 DB::connection('custom_mysql')->table('gl_route_map')->insert($data);
164 } 165 }
165 } 166 }