1
This commit is contained in:
@@ -1137,7 +1137,7 @@ class Article extends Controller
|
||||
if($next){
|
||||
//找到目标删除点的上位节点
|
||||
$pre = $this->article_main_obj
|
||||
->where('article_main_id','<',$main_info['article_main_id']-1)
|
||||
->where('article_main_id','<',$main_info['article_main_id'])
|
||||
->order("article_main_id desc")
|
||||
->limit(1)->select();
|
||||
$pre_id = $pre[0]['article_main_id'];
|
||||
@@ -1190,6 +1190,7 @@ class Article extends Controller
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$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;
|
||||
@@ -1198,6 +1199,50 @@ class Article extends Controller
|
||||
$insert['width'] = $data['width'];
|
||||
$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){
|
||||
$this->article_main_obj->where('article_main_id',$next_info['article_main_id'])->update(['pre_id'=>$now_id]);
|
||||
}
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
public function addArticleMainsAddForSubmission(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id"=>'require',
|
||||
"pre_id"=>"require",
|
||||
"contents"=>"require|array"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$pre_id = $data['pre_id'];
|
||||
$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']);
|
||||
$pre_id=$this->article_main_obj->insertGetId($insert);
|
||||
}
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
public function addArticleMainAddEmptyForSubmission(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
"article_id"=>'require',
|
||||
"pre_id"=>"require"
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}$insert['article_id'] = $data['article_id'];
|
||||
$insert['pre_id'] = $data['pre_id'];
|
||||
$insert['is_add'] = 1;
|
||||
$insert['content'] = "";
|
||||
$this->article_main_obj->insert($insert);
|
||||
return jsonSuccess([]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user