From 1ceede29e4095d714261807ad978700921111576 Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Thu, 29 Aug 2024 11:41:19 +0800 Subject: [PATCH] api --- control/index.php | 99 +++++++++++++------------------------------------------ 1 file changed, 22 insertions(+), 77 deletions(-) diff --git a/control/index.php b/control/index.php index df89967..c38dc82 100644 --- a/control/index.php +++ b/control/index.php @@ -11,93 +11,41 @@ class index extends publicBase { } public function ajax_search() { - $content = $_POST['content']; + $content = $this->post('content'); if(empty($content))$this->ajax_json(false, '非法请求'); - $start = isset($_POST['start']) ? $_POST['start'] : 0; - $pagesize = isset($_POST['pagesize']) ? $_POST['pagesize'] : 20; + $start = $this->post('start') ? $this->post('start') : 0; + $pagesize = $this->post('pagesize') ? $this->post('pagesize') : 200; - $data = array( - array( - 'id'=>1, - 'name'=>"大陷胸丸方", - 'source'=>"仲景伤寒论卷第四", - 'search_num'=>100, - 'sort'=>1, - ), - array( - 'id'=>2, - 'name'=>"大陷胸汤方", - 'source'=>"仲景伤寒论卷第四", - 'search_num'=>88, - 'sort'=>1, - ) - ); + $mCase = new mCase(); + $data = $mCase->getCaseByName($content,$start,$pagesize); $this->ajax_json(true, '获取成功', $data); } public function ajax_case_detail() { - $id = $_GET['id']; + $id = $this->get('id'); if(empty($id))$this->ajax_json(false, '非法请求'); - $data = array( - array( - 'case'=>array( - 'id'=>1, - 'name'=>"大陷胸丸方", - 'source'=>"仲景伤寒论卷第四", - "method"=> "", - 'search_num'=>100, - 'sort'=>1, - ), - 'case_herb'=>array( - array( - "id"=> "3", - "case_id"=> "1", - "herb_id"=> "1", - "num"=> "3", - "sort"=> "1", - ), - array( - "id"=> "3", - "case_id"=> "1", - "herb_id"=> "2", - "num"=> "3", - "sort"=> "1", - ) - ), - 'herb'=>array( - '1'=>array( - "id"=> "1", - "name"=> "知母", - "desc"=> "", - ), - '2'=>array( - "id"=> "2", - "name"=> "石膏", - "desc"=> "", - ), - ) - ) - ); + $mCase = new mCase(); + $data = $mCase->getCaseInfo($id); $this->ajax_json(true, '获取成功', $data); } public function ajax_save_user_case() { - $uid = $_POST['uid']; - $token = $_POST['token']; + $uid = $this->post('uid'); + $token = $this->post('token'); if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); $this->ajax_json(true, '保存成功'); } public function ajax_user_case_list() { - $uid = $_POST['uid']; - $token = $_POST['token']; + $uid = $this->post('uid'); + $token = $this->post('token'); if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); - $id = $_POST['id']; + $id = $this->post('id'); if($id){ $data = array( 'user_case' =>array( @@ -210,8 +158,8 @@ class index extends publicBase { } public function ajax_collect_log() { - $start = isset($_GET['start']) ? $_GET['start'] : 0; - $pagesize = isset($_GET['pagesize']) ? $_GET['pagesize'] : 20; + $start = $this->get('start') ? $this->get('start') : 0; + $pagesize = $this->get('pagesize') ? $this->get('pagesize') : 200; $data = array( array( @@ -230,7 +178,7 @@ class index extends publicBase { } public function ajax_login(){ - $code = $_GET['code']; + $code = $this->get('code'); if(!$code)$this->ajax_json(false, '非法请求'); $data = array( @@ -246,20 +194,17 @@ class index extends publicBase { } public function ajax_pdf_url(){ - $id = $_POST['id']; - $uid = $_POST['uid']; - $token = $_POST['token']; - if(empty($id) || empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); + $uid = $this->post('uid'); + $token = $this->post('token'); + if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); $this->ajax_json(true, '获取成功',array('pdf_url'=>'')); } public function ajax_mail(){ - $email = $_POST['email']; - $id = $_POST['id']; - $uid = $_POST['uid']; - $token = $_POST['token']; - if(empty($email) || empty($id) || empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); + $uid = $this->post('uid'); + $token = $this->post('token'); + if(empty($uid) || empty($token))$this->ajax_json(false, '非法请求'); $this->ajax_json(true, '发送成功'); }