This commit is contained in:
wangjinlei
2023-05-25 18:29:38 +08:00
parent 72f58ae072
commit c803f2748b
6 changed files with 466 additions and 218 deletions

View File

@@ -122,7 +122,25 @@ class Production extends Base
}
$p_info = $this->production_article_obj->where('p_article_id',$data['p_article_id'])->find();
$mains = $this->production_article_main_obj->where('p_article_id',$data['p_article_id'])->where('state',0)->select();
$re['mains'] = $mains;
$frag = [];
foreach ($mains as $v){
$frag[] = $v;
$ca = $this->production_article_main_img_obj->where('p_main_id',$v['p_main_id'])->where("state",0)->find();
if($ca){
$frag[] = $ca;
$pre_id = $ca['p_main_img_id'];
while ($pre_id!=0){
$cac = $this->production_article_main_img_obj->where('pre_id',$pre_id)->where('state',0)->find();
if($cac){
$frag[] = $cac;
$pre_id = $cac['p_main_img_id'];
}else{
$pre_id = 0;
}
}
}
}
$re['mains'] = $frag;
$re['production'] = $p_info;
return jsonSuccess($re);
}
@@ -144,6 +162,80 @@ class Production extends Base
return jsonSuccess([]);
}
/**添加主体文章图片
* @return void
*/
public function addProductionMainImg(){
$data = $this->request->post();
$rule = new Validate([
'p_article_id'=>'require',
"pre_type"=>"require",
"body"=>"require",
"content"=>"require",
"width"=>"require",
"note"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$insert['p_article_id'] = $data['p_article_id'];
if($data['pre_type']=="main"){
$insert['p_main_id'] = $data['body'];
}else{
$insert['pre_id'] = $data['body'];
}
$insert['content'] = $data['content'];
$insert['width'] = $data['width'];
$insert['note'] = $data['note'];
$this->production_article_main_img_obj->insert($insert);
return jsonSuccess([]);
}
/**删除mainimg
* @return void
*/
public function delProductionMainImg(){
$data = $this->request->post();
$rule = new Validate([
'p_main_img_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$p_img_info = $this->production_article_main_img_obj->where('p_main_img_id',$data['p_main_img_id'])->find();
$next_info = $this->production_article_main_img_obj->where('pre_id',$p_img_info['p_main_img_id'])->find();
if($next_info){
if($p_img_info['p_main_id']==0){
$this->production_article_main_img_obj->where('p_main_img_id',$next_info['p_main_img_id'])->update(['pre_id'=>$p_img_info['pre_id']]);
}else{
$this->production_article_main_img_obj->where('p_main_img_id',$next_info['p_main_img_id'])->update(['p_main_id'=>$p_img_info['p_main_id']]);
}
}
$this->production_article_main_img_obj->where('p_main_img_id',$data['p_main_img_id'])->update(['state'=>1]);
return jsonSuccess([]);
}
/**编辑mainimg
* @return void
*/
public function editProductionMainImg(){
$data = $this->request->post();
$rule = new Validate([
'p_main_img_id'=>'require',
"width"=>"require",
"content"=>"require",
"note"=>"require"
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$update['width']=$data['width'];
$update['content']=$data['content'];
$update['note'] = $data['note'];
$this->production_article_main_img_obj->where('p_main_img_id',$data['p_main_img_id'])->update($update);
return jsonSuccess([]);
}
/**
* 编辑main内容
* @return \think\response\Json|void
@@ -1614,4 +1706,21 @@ class Production extends Base
}
}
}
/**
* 上传pdf文件
*/
public function up_mainimg_file()
{
$file = request()->file('mainimg');
if ($file) {
$info = $file->move(ROOT_PATH . 'public' . DS . 'mainimg');
if ($info) {
return json(['code' => 0, 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
} else {
return json(['code' => 1, 'msg' => $file->getError()]);
}
}
}
}