|
...
|
...
|
@@ -47,7 +47,7 @@ class BlogCategoryLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function add_blog_category(){
|
|
|
|
//验证名称是否存在
|
|
|
|
$this->verifyParamName();
|
|
|
|
$this->verifyParamName($this->param['name']);
|
|
|
|
//拼接参数
|
|
|
|
$this->param = $this->addParamProcessing($this->param);
|
|
|
|
DB::beginTransaction();
|
|
...
|
...
|
@@ -61,13 +61,8 @@ class BlogCategoryLogic extends BaseLogic |
|
|
|
DB::rollBack();
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
//TODO::通知网站更新
|
|
|
|
$data = [
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'type'=>RouteMap::SOURCE_BLOG_CATE,
|
|
|
|
'route'=>$route,
|
|
|
|
];
|
|
|
|
updateNotify($this->user['domain'],$data);
|
|
|
|
//通知更新
|
|
|
|
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -79,33 +74,41 @@ class BlogCategoryLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function edit_blog_category(){
|
|
|
|
//验证名称是否存在
|
|
|
|
$this->verifyParamName();
|
|
|
|
$info = $this->model->read(['id'=>$this->param['id']]);
|
|
|
|
if($info['id'] == $this->param['pid']){
|
|
|
|
$this->verifyParamName($this->param['name'],$this->param['id']);
|
|
|
|
//验证参数是否可编辑
|
|
|
|
$this->verifyParamEdit($this->param['id'],$this->param['pid']);
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
|
|
$this->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
$route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']);
|
|
|
|
//通知更新
|
|
|
|
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :查看参数是否可编辑
|
|
|
|
* @name :verifyParamEdit
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/31 16:31
|
|
|
|
*/
|
|
|
|
public function verifyParamEdit($id,$pid){
|
|
|
|
$info = $this->model->read(['id'=>$id]);
|
|
|
|
if($info['id'] == $pid){
|
|
|
|
$this->fail('不能成为自己的上级');
|
|
|
|
}
|
|
|
|
if($info['pid'] != $this->param['pid']){
|
|
|
|
$info = $this->model->read(['pid'=>$this->param['id']]);
|
|
|
|
if($info['pid'] != $pid){
|
|
|
|
$info = $this->model->read(['pid'=>$id]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前分类拥有子分类不允许修改父级');
|
|
|
|
}
|
|
|
|
//查询当前分类下是否有商品
|
|
|
|
$blogModel = new BlogModel();
|
|
|
|
$info = $blogModel->read(['id'=>['like','%,'.$this->param['id'].',%']]);
|
|
|
|
$info = $blogModel->read(['id'=>['like','%,'.$id.',%']]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前分类下已存在博客,不允许修改上级');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->param['operator_id'] = $this->user['id'];
|
|
|
|
$this->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
$route = RouteMap::setRoute($this->param['alias'] ?: $this->param['name'], RouteMap::SOURCE_BLOG_CATE, $this->param['id'], $this->user['project_id']);
|
|
|
|
//TODO::通知网站更新
|
|
|
|
$data = [
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'type'=>RouteMap::SOURCE_BLOG_CATE,
|
|
|
|
'route'=>$route,
|
|
|
|
];
|
|
|
|
updateNotify($this->user['domain'],$data);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -198,15 +201,15 @@ class BlogCategoryLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/13 11:41
|
|
|
|
*/
|
|
|
|
public function verifyParamName(){
|
|
|
|
if(isset($this->param['id'])){
|
|
|
|
public function verifyParamName($name,$id = ''){
|
|
|
|
if(isset($id) && !empty($id)){
|
|
|
|
$condition = [
|
|
|
|
'id'=>['!=',$this->param['id']],
|
|
|
|
'name'=>$this->param['name'],
|
|
|
|
'id'=>['!=',$id],
|
|
|
|
'name'=>$name,
|
|
|
|
];
|
|
|
|
}else{
|
|
|
|
$condition = [
|
|
|
|
'name'=>$this->param['name']
|
|
|
|
'name'=>$name
|
|
|
|
];
|
|
|
|
}
|
|
|
|
$info = $this->model->read($condition);
|
...
|
...
|
|