This commit is contained in:
wangjinlei
2025-03-07 16:19:31 +08:00
parent 7800d15390
commit eefa89d00d

View File

@@ -567,6 +567,61 @@ class Preaccept extends Base
return jsonSuccess([]);
}
/**上调文章main位置
* @return \think\response\Json|void
*/
public function upArticleMain(){
$data = $this->request->post();
$rule = new Validate([
"am_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$main_info = $this->article_main_obj->where("am_id",$data['am_id'])->find();
$list = $this->article_main_obj->where("article_id",$main_info['article_id'])->where("sort","<",$main_info['sort'])->order("sort desc")->limit(1)->select();
if(!$list){
return jsonError("error");
}
$main1 = $list[0];
$cache_sort = $main1['sort'];
$this->article_main_obj->where("am_id",$main1['am_id'])->update(['sort'=>$main_info['sort']]);
$this->article_main_obj->where("am_id",$main_info['am_id'])->update(['sort'=>$cache_sort]);
return jsonSuccess([]);
}
/**下调文章main位置
* @return \think\response\Json
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function downArticleMain(){
$data = $this->request->post();
$rule = new Validate([
"am_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$main_info = $this->article_main_obj->where("am_id",$data['am_id'])->find();
$list = $this->article_main_obj->where("article_id",$main_info['article_id'])->where("sort",">",$main_info['sort'])->order("sort asc")->limit(1)->select();
if(!$list){
return jsonError("error");
}
$main1 = $list[0];
$cache_sort = $main1['sort'];
$this->article_main_obj->where("am_id",$main1['am_id'])->update(['sort'=>$main_info['sort']]);
$this->article_main_obj->where("am_id",$main_info['am_id'])->update(['sort'=>$cache_sort]);
return jsonSuccess([]);
}
/**删除文章全文校对
* @return \think\response\Json
* @throws \think\Exception
@@ -837,6 +892,44 @@ class Preaccept extends Base
}
/**添加批量主体内容
* @return \think\response\Json
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function addMoreRow(){
$data = $this->request->post();
$rule = new Validate([
"article_id"=>"require",
"am_id" => "require",
"rows"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
if($data['am_id']==0){//顶级
$this->article_main_obj->where("article_id",$data['article_id'])->inc("sort",count($data['rows']))->update();
$sort = 1;
}else{
$r = $this->article_main_obj->where("am_id",$data['am_id'])->find();
$this->article_main_obj->where("article_id",$data['article_id'])->where("sort",">",$r['sort'])->inc("sort",count($data['rows']))->update();
$sort = $r['sort']+1;
}
foreach ($data['rows'] as $v){
$insert['article_id'] = $data['article_id'];
$insert['content'] = $v;
$insert['sort'] = $sort;
$insert['ctime'] = time();
$this->article_main_obj->insert($insert);
$sort++;
}
return jsonSuccess([]);
}
private function addBRow($article_id,$am_id){
if($am_id==0){//顶行
$this->article_main_obj->where("article_id",$article_id)->inc("sort",1)->update();
@@ -942,8 +1035,7 @@ class Preaccept extends Base
public function editArticleMainsForAuthor(){
$data = $this->request->post();
$rule = new Validate([
"am_id"=>"require",
"content"=>"require"
"am_id"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());