This commit is contained in:
wangjinlei
2022-07-15 09:53:07 +08:00
parent 809170fed6
commit 37ecfb7fc0
3 changed files with 148 additions and 3 deletions

View File

@@ -85,13 +85,18 @@ class Medicament extends Controller
public function delMedicament(){
$data = $this->request->post();
$rule = new Validate([
'article_id'=>'require',
'med_id'=>'require'
'article_id'=>'require'
]);
if(!$rule->check($data)){
return jsonError($rule->getError());
}
$this->article_to_medicament_obj->where('article_id',$data['article_id'])->where('med_id',$data['med_id'])->update(['med_state'=>1]);
$atm_info = $this->article_to_medicament_obj->where('article_id',$data['article_id'])->where('atm_state',0)->find();
//确定此关联的药剂话题项目是否有其他关联文章,决定是否删除连带的药剂话题
$check = $this->article_to_medicament_obj->where('med_id',$atm_info['med_id'])->where('atm_id','<>',$atm_info['atm_id'])->where('atm_state',0)->find();
if($check==null){
$this->medicament_obj->where('med_id',$atm_info['med_id'])->update(['med_state'=>1]);
}
$this->article_to_medicament_obj->where('article_id',$data['article_id'])->where('atm_state',0)->update(['atm_state'=>1]);
return jsonSuccess([]);
}