update QuestionController

master
ziyonghong 5 years ago
parent eafebd2343
commit 7ad6bcad13

@ -2,7 +2,10 @@ package com.cmkg.cmkg.Controller;
import com.cmkg.cmkg.database.ReturnData;
import com.cmkg.cmkg.node.disease;
import com.cmkg.cmkg.node.medicine;
import com.cmkg.cmkg.repository.QuestionRespository;
import com.cmkg.cmkg.server.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -11,33 +14,61 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/rest/cmkg/question")
public class QuestionController {
@Autowired
QuestionService questionService;
//做个小测试
@Autowired
public QuestionRespository questionRespository;
public String Search_disease_Success="查找病症成功";
public String Search_medicine_Success="查找药品成功";
public String SearchFaile="查找信息失败";
public int code;
ReturnData rd=new ReturnData();
@RequestMapping("/hello")
public ReturnData JudgeAtrribute(@RequestParam("name") String name){
disease dis=new disease();
medicine med=new medicine();
//去每个表里做查找,找到了的话做查询
System.out.println(questionRespository);
System.out.println(name);
Long i = questionRespository.getDiseaseId(name);
System.out.println(i);
if(questionRespository.getDiseaseId(name)!=0){//说明输入的事病症
String symptom=questionRespository.getDiseaseSymptom(name);
String[] tomedicine=questionRespository.getDiseaseToMedicine(name);
rd.setDiseaseSymptom(name);
rd.setTomedicie(tomedicine);
return rd;
}else{//说明输入的是养生方法或药品名称
String operation=questionRespository.getMedicineOperation(name);
String syndromes=questionRespository.getMedicineSyndromes(name);
rd.setOperation(operation);
rd.setSyndromes(syndromes);
return rd;
}
@RequestMapping("/hello")
public String JudgeAtrribute(@RequestParam("name") String name){
String re = null;
try {
re = questionService.answer(name);
System.out.println(re);
} catch (Exception e) {
re = "有错误";
e.printStackTrace();
}
//去每个表里做查找,找到了的话做查询
// System.out.println(questionRespository);
// System.out.println(name);
// Long i = questionRespository.getDiseaseId(name);
// System.out.println(i);
// if(questionRespository.getDiseaseId(name)!=0){//说明输入的事病症
// String symptom=questionRespository.getDiseaseSymptom(name);
// String[] tomedicine=questionRespository.getDiseaseToMedicine(name);
// dis.setName(name);
// dis.setSyptom(symptom);
// dis.setTeammates(tomedicine);
// rd.setMessage(Search_disease_Success);
// rd.setCode(200);
// rd.setData(dis);
// return rd;
// }else if(questionRespository.getMedicineId(name)!=0){//说明输入的是养生方法或药品名称
// String operation=questionRespository.getMedicineOperation(name);
// String syndromes=questionRespository.getMedicineSyndromes(name);
// med.setName(name);
// med.setOperation(operation);
// med.setSyndromes(syndromes);
// rd.setCode(200);
// rd.setMessage(Search_medicine_Success);
// rd.setData(med);
// return rd;
// }else{
// rd.setMessage(SearchFaile);
// rd.setCode(502);
// return rd;
// }
return re;
}
}

Loading…
Cancel
Save