$this->mall_id, 'user_id' => $this->user_id]); $this->success('success', $service->list(), ApiStatusEnum::CODE_SUCCESS, 0); } /** * @return void */ public function actionEdit() { $params = $this->request->post(); $rules = [ [['name', 'mobile', 'id_card'], 'required'], [['id', 'sex', 'age', 'is_allergy_history', 'is_medical_history', 'liver_function_status', 'kidney_function_status', 'pregnancy_breastfeeding_status'], 'integer'], [['name', 'mobile', 'id_card', 'allergy_history_details', 'sickness_detail'], 'string'], [['sex'], 'in', 'range' => [1, 2]], [['is_allergy_history', 'is_medical_history', 'liver_function_status', 'kidney_function_status'], 'in', 'range' => [0, 1]], [['pregnancy_breastfeeding_status'], 'in', 'range' => [0, 1, 2, 3]], ]; $res = Yii::$app->services->validate->validate($params, $rules); if ($res === false) { $this->error(Yii::$app->services->validate->getErrorMessage()); return; } $service = new MedicationRecipientService(['mall_id' => $this->mall_id, 'user_id' => $this->user_id]); if (!$service->edit($params)) { $this->error($service->getError()); return; } $this->success('success'); } /** * @return void */ public function actionDetail() { $id = $this->request->get('id', 0); if ($id <= 0) { $this->error('参数错误'); return; } $service = new MedicationRecipientService(['mall_id' => $this->mall_id, 'user_id' => $this->user_id]); $this->success('success', $service->detail($id), ApiStatusEnum::CODE_SUCCESS, 0); } /** * @return void */ public function actionDel() { $id = $this->request->post('id'); if ($id <= 0) { $this->error('参数错误'); return; } $service = new MedicationRecipientService(['mall_id' => $this->mall_id, 'user_id' => $this->user_id]); if (!$service->del($id)) { $this->error($service->getError() ?: '删除失败'); return; } $this->success('success'); } }