Browse Source

删除自拟药方

pull/1/head
pengda 8 months ago
parent
commit
e7696a588a
  1. 18
      control/index.php
  2. 1
      data/dFormula.php
  3. 25
      model/mFormula.php

18
control/index.php

@ -10,6 +10,7 @@ include_once(SERVER_ROOT . "/model/mPage.php");
class index extends publicBase {
private function _check_login() {
// return array('uid'=>$this->post('uid'));
$uid = $this->post('uid');
$token = $this->post('token');
if ($uid < 0 || !$token) $this->ajax_json(false, '参数错误', array('code' => CODE_LOGIN_EXIPRE));
@ -98,6 +99,7 @@ class index extends publicBase {
$uinfo = $this->_check_login();
$id = $this->post('id') + 0;
$is_delete = $this->post('is_delete') + 0;
$name = trim($this->post('name'));
$source = trim($this->post('source'));
$method = trim($this->post('method'));
@ -111,10 +113,22 @@ class index extends publicBase {
if (!$request_times) $this->ajax_json(false, $mformula->getError());
//新增药方
$id = $mformula->formula($uinfo['uid'], $id, $name, $source, $method, $herbs);
$id = $mformula->formula($uinfo['uid'], $id, $name, $source, $method, $herbs, $is_delete);
if (!$id) $this->ajax_json(false, $mformula->getError());
$this->ajax_json(true, '成功', array('id' => $id));
$this->ajax_json(true, '请求成功', array('id' => $id));
}
public function ajax_delete_formula() {
$uinfo = $this->_check_login();
$id = $this->post('id') + 0;
$mformula = new mFormula();
$id = $mformula->deleteFormula($uinfo['uid'], $id);
if (!$id) $this->ajax_json(false, $mformula->getError());
$this->ajax_json(true, '请求成功');
}
// public function ajax_update_formula() {

1
data/dFormula.php

@ -17,6 +17,7 @@ class dFormula extends dBase {
'original',
'method',
'sort',
'is_delete',
'create_time',
),
'tcm_formula_herb' => array(

25
model/mFormula.php

@ -25,7 +25,7 @@ class mFormula extends mBase {
public function getFormulaByCondition($condition, $page_num, $page_size) {
$offset = ($page_num - 1) * $page_size;
$where = "1=1";
$where = "is_delete=0";
$use_limit = "";
if (!empty($condition)) {
foreach ($condition as $key => $val) {
@ -82,7 +82,7 @@ class mFormula extends mBase {
}
public function getFormulaTotal($condition) {
$where = "1=1";
$where = "is_delete=0";
if (!empty($condition)) {
foreach ($condition as $key => $val) {
if ($key == 'name') {
@ -511,7 +511,7 @@ class mFormula extends mBase {
$this->setError('查询不到此药方');
return false;
}
if ($formula['uid'] > 0 && $formula['uid'] != $uid) {
if ($formula['uid'] != $uid) {
$this->setError('这不是你的药方');
return false;
}
@ -585,6 +585,25 @@ class mFormula extends mBase {
return $id;
}
public function deleteFormula($uid, $id) {
$formula = $this->getFormulaById($id);
if (empty($formula)) {
$this->setError('查询不到此药方');
return false;
}
if ($formula['uid'] != $uid) {
$this->setError('这不是你的药方');
return false;
}
$res = $this->updateFormula($id, array('is_delete' => 1));
if (!$res) {
$this->writeLog('formula', 'update_error_log', '更新药方失败|' . $uid . '|' . json_encode($data, JSON_UNESCAPED_UNICODE));
return false;
}
return true;
}
public function getHerbById($id) {
return $this->obj->select($this->herb_tbl, array('sql' => '`id`=?', 'vals' => array($id)));

Loading…
Cancel
Save