1
This commit is contained in:
@@ -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([]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user