作者 赵彬吉

update

... ... @@ -63,6 +63,9 @@ class CustomTemplateLogic extends BaseLogic
$id = $this->editCustomRoute($this->param['id'],$this->param['url']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
$this->fail('404页面已存在');
}
$this->param['project_id'] = $this->user['project_id'];
$id = $this->model->addReturnId($this->param);
}
... ... @@ -105,6 +108,9 @@ class CustomTemplateLogic extends BaseLogic
*/
public function editCustomRoute($id,$route){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info['url'] == $this->model::NOT_FOUND_PAGE_URL && $route['url'] != '404'){
$this->fail('404页面链接不可修改');
}
if($info['url'] != $route){
//生成一条删除路由记录
$data = [
... ... @@ -128,6 +134,9 @@ class CustomTemplateLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或者已被删除');
}
if($info['url'] == $this->model::NOT_FOUND_PAGE_URL){
$this->fail('404页面不可删除');
}
try {
if($info['status'] != 2){
$this->model->edit(['status'=>2],['id'=>$this->param['id']]);
... ...
... ... @@ -9,4 +9,6 @@ class BCustomTemplate extends Base
protected $table = 'gl_web_custom_template';
//连接数据库
protected $connection = 'custom_mysql';
const NOT_FOUND_PAGE_URL = '404';
}
... ...
... ... @@ -10,6 +10,7 @@ namespace App\Services;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
... ... @@ -129,7 +130,7 @@ class ProjectServer extends BaseService
//初始化单页
$info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();
if(empty($info)) {
$data = ['project_id' => $project_id, 'name' => '404', 'status' => 1, 'url' => '404', 'html' => '<main>
$data = ['project_id' => $project_id, 'name' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'status' => 1, 'url' => BCustomTemplate::NOT_FOUND_PAGE_URL, 'html' => '<main>
<section data-section="section" data-screen="screen-large" class="section-404-wrap-block section-block-error404"
id="sectionIdyxqu938">
<div class="layout" data-unable="demo01-error404">
... ... @@ -159,7 +160,7 @@ class ProjectServer extends BaseService
//路由
$info = DB::connection('custom_mysql')->table('gl_route_map')->first();
if(empty($info)) {
$data = ['project_id' => $project_id, 'source' => RouteMap::SOURCE_PAGE, 'source_id' => $id, 'route' => '404', 'created_at' => $created_at, 'updated_at' => $created_at];
$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];
DB::connection('custom_mysql')->table('gl_route_map')->insert($data);
}
}
... ...