Browse Source

药方相关优化

pull/1/head
pengda 9 months ago
parent
commit
db77b3579b
  1. 16
      control/index.php
  2. 7
      model/mCase.php

16
control/index.php

@ -50,13 +50,13 @@ class index extends publicBase {
public function ajax_search() {
$content = $this->post('content');
if(empty($content))$this->ajax_json(false, '非法请求');
if(empty($content))$this->ajax_json(false, '请输入方名');
$start = $this->post('start') ? $this->post('start') : 0;
$pagesize = $this->post('pagesize') ? $this->post('pagesize') : 500;
$page_num = $this->post('page_num') ? $this->post('page_num') : 1;
$page_size = $this->post('page_size') ? $this->post('page_size') : 100;
$mCase = new mCase();
$data = $mCase->getCaseByName($content,$start,$pagesize);
$m_case = new mCase();
$data = $m_case->getCaseByName($content, $page_num, $page_size);
$this->ajax_json(true, '获取成功', $data);
}
@ -65,9 +65,9 @@ class index extends publicBase {
$id = $this->get('id');
if(empty($id))$this->ajax_json(false, '非法请求');
$mCase = new mCase();
$data = $mCase->getCaseInfo($id);
if (empty($data)) $this->ajax_json(false, $mCase->getError());
$m_case = new mCase();
$data = $m_case->getCaseInfo($id);
if (!$data) $this->ajax_json(false, $m_case->getError());
$this->ajax_json(true, '获取成功', $data);
}

7
model/mCase.php

@ -130,10 +130,11 @@ class mCase extends mBase {
return $this->obj->selectAll($this->case_herb_tbl, array('sql'=>'`case_id`=?','vals'=>array($case_id)), 'sort asc ');
}
public function getCaseByName($name,$start,$pagesize) {
public function getCaseByName($name, $page_num, $page_size) {
$sql = " `name` like '%{$name}%'";
$res = $this->obj->selectAll($this->tbl, array('sql'=>$sql, 'vals'=>array()), 'use_num desc,sort asc ', array($start, $pagesize));
$offset = ($page_num - 1) * $page_size;
$res = $this->obj->selectAll($this->tbl, array('sql'=>$sql, 'vals'=>array()), 'use_num desc,sort asc ', array($offset, $page_size));
if(empty($res)) return array();
return $res;
@ -143,9 +144,11 @@ class mCase extends mBase {
//药方信息
$case = $this->getCaseById($id);
if(empty($case)){$this->setError('查询不到此药方');return false;}
//药方药材信息
$case_herb = $this->getCaseHerbByCaseId($case['id']);
if(empty($case_herb)){$this->setError('药方药材查询失败');return false;}
//药材名称
$herb_ids = array_column($case_herb,'herb_id');
$herb = $this->getHerbByIds($herb_ids);

Loading…
Cancel
Save