|
...
|
...
|
@@ -30,6 +30,9 @@ class GroupLogic extends BaseLogic |
|
|
|
if($rs === false){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
if(isset($this->param['pid']) && !empty($this->param['pid'])){
|
|
|
|
$this->add_update_parent($this->param);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -45,6 +48,8 @@ class GroupLogic extends BaseLogic |
|
|
|
if($rs === false){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
//更新父类
|
|
|
|
$this->update_parent($this->param,$this->param['id']);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -66,12 +71,44 @@ class GroupLogic extends BaseLogic |
|
|
|
* @method
|
|
|
|
*/
|
|
|
|
public function group_del(){
|
|
|
|
$ids = $this->param['id'];
|
|
|
|
$this->param['id'] = ['in',$this->param['id']];
|
|
|
|
$rs = $this->del($this->param,$ids);
|
|
|
|
//查看当前是否拥有父类
|
|
|
|
$info = $this->model->read(['pid'=>$this->param['id']]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前删除组织拥有下级组织,不允许删除');
|
|
|
|
}
|
|
|
|
$rs = $this->model->del($this->param);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(更新父类成员)update_parent
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/17 9:22
|
|
|
|
*/
|
|
|
|
public function update_parent($param,$id = ''){
|
|
|
|
if(!empty($id)){
|
|
|
|
$param = $this->model->read(['id'=>$id]);
|
|
|
|
}
|
|
|
|
//查询当前组是否拥有父类
|
|
|
|
if($param['pid'] != 0){
|
|
|
|
$parent_info = $this->model->read(['id'=>$param['pid']]);
|
|
|
|
//把添加成员合并到上级
|
|
|
|
$str = trim($param['user_list'].$parent_info['user_list'],',');
|
|
|
|
$mergedString = ','.implode(',', array_unique(explode(',', $str))).',';
|
|
|
|
$rs = $this->model->edit(['user_list'=>$mergedString],['id'=>$parent_info['id']]);
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('更新父级失败');
|
|
|
|
}
|
|
|
|
//查看当前父级是否还拥有父级
|
|
|
|
if($parent_info['pid'] != 0){
|
|
|
|
$rs = $this->update_parent($parent_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($rs);
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|