<?php
namespace app\controller;

use app\model\Category;
use app\model\CdssXyDisease;
use app\model\Illness;
use app\model\Symptom;
use app\model\ZskWords;
use think\facade\Db;
use think\facade\Request;
use Fukuball\Jieba\Jieba;
use Fukuball\Jieba\Finalseg;
//Jieba::init();
//Finalseg::init();


class Index extends CommonTwoController
{

    public function index( )
    {
        $question = Request::param('question') ?? '';
        $url = "http://3.15.12.98:5000/chat?content=".$question;
        $result = file_get_contents($url);
        return $this->_json_succ($result);
    }



	// Index Category
	public  function category()
	{
		if(!$this->checkIslogin()) return $this->_json_error('请登录' , 777);
		return $this->_json_succ(Category::make_tree(Category::select()));
	}


	// 某分类下all
	public function getAllIllnessByPid()
	{
		if(!$this->checkIslogin()) return $this->_json_error('请登录' , 777);
		$pid   = Request::param('id') ?? '';
		$field = 'id , clinical_manifestation , pathogeny , complication , auxiliary , diagnose , cure';
		$data  = Illness::field($field)->where(['category' => $pid])->select();
		return $this->_json_succ($data);
	}


	// 单个
	public function singleIllness()
	{
		if(!$this->checkIslogin()) return $this->_json_error('请登录' , 777);
		$id = Request::param('id') ?? '';
		$field = 'id , illness_name , illness_as_name , icd_number , medicinal , illness_desc , epidemiology';
		$data  = Illness::field($field)->where(['id' => $id])->find();
		return $this->_json_succ($data);
	}

}
