package org.diagbot.graphWeb.controller;

import org.diagbot.common.push.bean.ResponseData;
import org.diagbot.common.push.bean.SearchData;
import org.diagbot.graph.javabean.GdbResponse;
import org.diagbot.graphWeb.work.DiseaseCalculate;
import org.diagbot.graphWeb.work.GraphCalculate;
import org.diagbot.graphWeb.work.HighRiskCalculate;
import org.diagbot.graphWeb.work.LisPacsCalculate;
import org.diagbot.pub.api.Response;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/graph")
public class GraphController {
    @RequestMapping(value = "/push", method = RequestMethod.POST)
    @ResponseBody
    public Response<ResponseData> bayesPageData(HttpServletRequest request, @RequestBody SearchData searchData) throws Exception {
        Response<ResponseData> response = new Response();
        GraphCalculate graphCalculate = new GraphCalculate();
        ResponseData responseData = graphCalculate.calculate(request, searchData);
        response.setData(responseData);
        return response;
    }

    @RequestMapping(value = "/highRisk", method = RequestMethod.POST)
    @ResponseBody
    public Response<GdbResponse> getHighRisk(HttpServletRequest request, @RequestBody SearchData searchData) throws Exception {
        HighRiskCalculate highRiskCalculate = new HighRiskCalculate();
        Response<GdbResponse> gdbResponseResponse = highRiskCalculate.calculateHighRisk(request, searchData);
        return gdbResponseResponse;
    }

    @RequestMapping(value = "/lisPacs", method = RequestMethod.POST)
    @ResponseBody
    public Response<ResponseData> lisPacsData(HttpServletRequest request, @RequestBody SearchData searchData) throws Exception {
        Response<ResponseData> response = new Response();
        LisPacsCalculate lisPacsCalculate = new LisPacsCalculate();
        ResponseData responseData = lisPacsCalculate.getLisPacs(request, searchData);
//        GraphCalculate graphCalculate = new GraphCalculate();
//        ResponseData responseData = graphCalculate.getLisPacs(request, searchData);
        response.setData(responseData);
        return response;
    }
    @RequestMapping(value = "/dis", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData getDisTreat(HttpServletRequest request, @RequestBody SearchData searchData)throws Exception{
        DiseaseCalculate graphCalculate = new DiseaseCalculate();
        ResponseData calculate = graphCalculate.getDisease(searchData);
        return calculate;
    }

}

