|
...
|
...
|
@@ -63,23 +63,22 @@ class CustomTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/6/29 16:21
|
|
|
|
*/
|
|
|
|
public function customTemplateSave(){
|
|
|
|
try {
|
|
|
|
$this->param['url'] = str_replace_url($this->param['url']);
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $this->param['id'], $this->user['project_id']);
|
|
|
|
$this->editCustomRoute($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);
|
|
|
|
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
|
|
|
|
$this->model->edit(['url'=>$route],['id'=>$id]);
|
|
|
|
$this->param['url'] = str_replace_url($this->param['url']);
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$this->param['url'] = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $this->param['id'], $this->user['project_id']);
|
|
|
|
$this->editCustomRoute($this->param['url']);
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}else{
|
|
|
|
if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
|
|
|
|
$this->fail('404页面已存在');
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
$route = RouteMap::setRoute($this->param['url'], RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
|
|
|
|
$rs = $this->model->edit(['url'=>$route],['id'=>$id]);
|
|
|
|
}
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
...
|
...
|
@@ -208,13 +207,13 @@ class CustomTemplateLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function editCustomRoute($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){
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
|
|
|
|
$this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]);
|
|
|
|
if($info['url'] == $this->model::NOT_FOUND_PAGE_URL){
|
|
|
|
if($route != '404'){
|
|
|
|
$this->fail('不可删除, 只可以修改tdk');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
|
|
|
|
$this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|