Browse Source

自拟药方接口

pull/1/head
pengda 8 months ago
parent
commit
30c06f6908
  1. 19
      control/index.php

19
control/index.php

@ -34,29 +34,38 @@ class index extends publicBase {
} }
public function ajax_save_formula() { public function ajax_save_formula() {
$uinfo = $this->_check_login();
$name = trim($this->post('name')); $name = trim($this->post('name'));
$source = trim($this->post('source')); $source = trim($this->post('source'));
$method = trim($this->post('method')); $method = trim($this->post('method'));
$herbs = $this->post('herbs'); $herbs = $this->post('herbs');
//新增药方
$mformula = new mFormula(); $mformula = new mFormula();
$id = $mformula->createCase($name, $source, $method, $herbs);
//生成唯一id 防止重复请求
$request_id = md5($uinfo['uid'] . $name . $source . $herbs);
$request_times = $mformula->requestLimit(sprintf(_QR_REQUEST_LIMIT, $request_id), 1, 60);
if (!$request_times) $this->ajax_json(false, $mformula->getError());
//新增药方
$id = $mformula->createFormula($uinfo['uid'], $name, $source, $method, $herbs);
if (!$id) $this->ajax_json(false, $mformula->getError()); if (!$id) $this->ajax_json(false, $mformula->getError());
$this->ajax_json(true, '添加成功'); $this->ajax_json(true, '添加成功', array('id' => $id));
} }
public function ajax_update_formula() { public function ajax_update_formula() {
$uinfo = $this->_check_login();
$id = $this->post('id') + 0; $id = $this->post('id') + 0;
$name = trim($this->post('name')); $name = trim($this->post('name'));
$source = trim($this->post('source')); $source = trim($this->post('source'));
$original = trim($this->post('original'));
$method = trim($this->post('method')); $method = trim($this->post('method'));
$herbs = $this->post('herbs'); $herbs = $this->post('herbs');
$mformula = new mFormula(); $mformula = new mFormula();
$res = $mformula->updateCase($id, $name, $source, $method, $herbs); $res = $mformula->saveFormula($uinfo['uid'], $id, $name, $source, $method, $herbs);
if (!$res) $this->ajax_json(false, $mformula->getError()); if (!$res) $this->ajax_json(false, $mformula->getError());
$this->ajax_json(true, '保存成功'); $this->ajax_json(true, '保存成功');

Loading…
Cancel
Save