作者 lyh

gx

... ... @@ -155,6 +155,9 @@ class BlogCategoryLogic extends BaseLogic
'pid'=>0,
'status'=>0,
];
if(isset($this->param['id']) && !empty($this->param['id'])){
$map['id'] = ['!=',$this->param['id']];
}
$list = $this->model->list($map);
return $this->success($list);
}
... ...
... ... @@ -54,20 +54,9 @@ class BlogLogic extends BaseLogic
* @method
*/
public function blog_add(){
$condition = [
'name'=>$this->param['name']
];
//查看当前名称是否存在
$info = $this->model->read($condition);
if($info !== false){
$this->fail('当前名称已存在');
}
$this->param['create_id'] = $this->user['id'];
$this->param['operator_id'] = $this->user['id'];
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s',time());
$this->param['updated_at'] = date('Y-m-d H:i:s',time());
$this->param['category_id'] = ','.$this->param['category_id'].',';
//验证名称是否存在
$this->verifyParamName();
$this->param = $this->paramProcessing($this->param);
DB::beginTransaction();
try {
if(isset($this->param['image'])){
... ... @@ -92,16 +81,10 @@ class BlogLogic extends BaseLogic
* @method
*/
public function blog_edit(){
$condition = [
'id'=>['!=',$this->param['id']],
'name'=>$this->param['name']
];
$info = $this->model->read($condition);
if($info !== false){
$this->fail('当前名称已存在');
}
$this->param['operator_id'] = $this->user['id'];
$this->param['category_id'] = ','.trim($this->param['category_id'],',').',';
//验证名称是否存在
$this->verifyParamName();
//拼接参数
$this->param = $this->paramProcessing($this->param);
DB::beginTransaction();
try {
//是否有图片更新
... ... @@ -185,11 +168,9 @@ class BlogLogic extends BaseLogic
try {
$this->param['id'] = ['in',$this->param['id']];
$this->del($this->param,$ids);
foreach ($ids as $id){
RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
}
DB::commit();
}catch (Exception $e){
DB::rollBack();
... ... @@ -197,4 +178,49 @@ class BlogLogic extends BaseLogic
}
return $this->success();
}
/**
* @name :(验证名称是否存在)verifyParamName
* @author :lyh
* @method :post
* @time :2023/6/13 11:41
*/
public function verifyParamName(){
if(isset($this->param['id'])){
$condition = [
'id'=>['!=',$this->param['id']],
'name'=>$this->param['name'],
];
}else{
$condition = [
'name'=>$this->param['name']
];
}
$info = $this->model->read($condition);
if($info !== false){
$this->fail('当前分类名称已存在');
}
return $this->success();
}
/**
* @name :(参数处理)paramProcessing
* @author :lyh
* @method :post
* @time :2023/6/13 11:30
*/
public function paramProcessing($param){
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
$param['category_id'] = ','.trim($this->param['category_id'],',').',';
}else{
$this->param['create_id'] = $this->user['id'];
$this->param['operator_id'] = $this->user['id'];
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s',time());
$this->param['updated_at'] = date('Y-m-d H:i:s',time());
$this->param['category_id'] = ','.$this->param['category_id'].',';
}
return $this->success($param);
}
}
... ...
... ... @@ -152,6 +152,9 @@ class NewsCategoryLogic extends BaseLogic
'pid'=>0,
'status'=>0,
];
if(isset($this->param['id']) && !empty($this->param['id'])){
$map['id'] = ['!=',$this->param['id']];
}
$list = $this->model->list($map);
return $this->success($list);
}
... ...