1
This commit is contained in:
@@ -1135,6 +1135,16 @@ class Article extends Controller
|
||||
$main_info = $this->article_main_obj->where('article_main_id',$data['article_main_id'])->find();
|
||||
$next = $this->article_main_obj->where('pre_id',$data['article_main_id'])->where('state',0)->find();
|
||||
if($next){
|
||||
if($main_info['pre_id']>0){
|
||||
$pre_id = $main_info['pre_id'];
|
||||
}else{
|
||||
$pre = $this->article_main_obj
|
||||
->where('article_main_id','<',$main_info['article_main_id'])
|
||||
->where("state",0)
|
||||
->order("article_main_id desc")
|
||||
->limit(1)->select();
|
||||
$pre_id = $pre[0]['article_main_id'];
|
||||
}
|
||||
//找到目标删除点的上位节点
|
||||
$pre = $this->article_main_obj
|
||||
->where('article_main_id','<',$main_info['article_main_id'])
|
||||
@@ -1200,12 +1210,10 @@ class Article extends Controller
|
||||
$insert['note'] = trim($data['note']);
|
||||
}
|
||||
$now_id = $this->article_main_obj->insertGetId($insert);
|
||||
if($pre_info['is_add']==1){//如果原节点的下级存在,那么要变换下个节点的父节点
|
||||
$next_info = $this->article_main_obj->where('pre_id',$pre_info['article_main_id'])->where('state',0)->find();
|
||||
if($next_info){
|
||||
if($next_info){//如果原节点的下级存在,那么要变换下个节点的父节点
|
||||
$this->article_main_obj->where('article_main_id',$next_info['article_main_id'])->update(['pre_id'=>$now_id]);
|
||||
}
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
@@ -1214,21 +1222,25 @@ class Article extends Controller
|
||||
$rule = new Validate([
|
||||
"article_id"=>'require',
|
||||
"pre_id"=>"require",
|
||||
"contents"=>"require|array"
|
||||
"contents"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$pre_id = $data['pre_id'];
|
||||
$next_info = $this->article_main_obj->where('pre_id',$pre_id)->where('state',0)->find();
|
||||
$contents = json_decode($data['contents']);
|
||||
foreach ($contents as $k => $v){
|
||||
$insert['article_id'] = $data['article_id'];
|
||||
$insert['pre_id'] = $pre_id;
|
||||
$insert['is_add'] = 1;
|
||||
$insert['content'] = trim($data['content']);
|
||||
$insert['content'] = trim($v);
|
||||
$pre_id=$this->article_main_obj->insertGetId($insert);
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
if ($next_info){
|
||||
$this->article_main_obj->where('article_main_id',$next_info['article_main_id'])->update(['pre_id'=>$pre_id]);
|
||||
}
|
||||
return jsonSuccess($contents);
|
||||
}
|
||||
|
||||
public function addArticleMainAddEmptyForSubmission(){
|
||||
@@ -1239,11 +1251,17 @@ class Article extends Controller
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}$insert['article_id'] = $data['article_id'];
|
||||
}
|
||||
$pre_info = $this->article_main_obj->where('article_main_id',$data['pre_id'])->find();
|
||||
$insert['article_id'] = $data['article_id'];
|
||||
$insert['pre_id'] = $data['pre_id'];
|
||||
$insert['is_add'] = 1;
|
||||
$insert['content'] = "";
|
||||
$this->article_main_obj->insert($insert);
|
||||
$now_id = $this->article_main_obj->insertGetId($insert);
|
||||
$next_info = $this->article_main_obj->where('pre_id',$pre_info['article_main_id'])->where('state',0)->find();
|
||||
if($next_info){//如果原节点的下级存在,那么要变换下个节点的父节点
|
||||
$this->article_main_obj->where('article_main_id',$next_info['article_main_id'])->update(['pre_id'=>$now_id]);
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user