checkIsCanVisit($ip); if( ! $checkIsCanVisit) { return $this->_json_error('非法请求!'); } $params = Request::only( [ 'tag' , 'name' ] ); $tag = $params['tag'] ?? ''; $name = $params['name'] ?? ''; if( ! $tag || ! $name) { return $this->_json_error('请求参数有误!'); } $tags = ['medicine' , 'disease']; if( ! in_array($tag, $tags)) { return $this->_json_error('请求标识错误!'); } /** * 药品 */ if('medicine' === $tag) { $model = '\app\model\CdssMedicine'; $field = 'name'; } /** * 疾病 */ if('disease' === $tag) { $model = '\app\model\CdssDisease'; $field = 'name'; } $detail = $model::where($field , $name)->find(); unset($detail['id']); return $this->_json_succ( $detail ); } /** * 检测访问 */ protected function checkIsCanVisit($ip) { $visit = VisitLimit::where('ip' , $ip)->find(); if( ! $visit ) return false; if(0 >= $visit->already_visit_count) { return false; } return true; } }