|
@@ -71,12 +71,12 @@ public class ChatController extends BaseController {
|
|
|
|
|
|
@GetMapping("/getQuestion/{label}")
|
|
|
@ApiOperation("查询问题信息:首次查询时,id传空字符串即可查询出第一道题目;questionType=0表示选择题,questionType=1表示填空题;当改问题的nextQuestionNo 不为空是,则表示改题为陈述,没有答案,直接在显示此问题之后再次请求该接口显示questionNo对应的题目信息即可")
|
|
|
- public Result getQuestion(String id, @PathVariable String label, HttpServletRequest request) {
|
|
|
+ public Result getQuestion(String id, String num, @PathVariable String label, HttpServletRequest request) {
|
|
|
|
|
|
if (StringUtils.isBlank(id)) {
|
|
|
id = "1";
|
|
|
}
|
|
|
- ChatQuestionEntity questionEntity = this.questionService.findByIdAndLabel(id, label);
|
|
|
+ ChatQuestionEntity questionEntity = this.questionService.findByIdAndLabelAndNum(id, label, num);
|
|
|
if (questionEntity.getLabel().equals("5") && questionEntity.getId().equals("3")){
|
|
|
String token = request.getHeader("Authorization");
|
|
|
token = token.split(" ")[1];//以空格划分Bearer token,获取token
|
|
@@ -98,9 +98,9 @@ public class ChatController extends BaseController {
|
|
|
return success(questionEntity);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/import/{label}/faq")
|
|
|
+ @PostMapping("/import/{label}/{num}/faq")
|
|
|
@ApiOperation("智能问答导入")
|
|
|
- public Result importQuestionAndAnswer(@RequestPart("file") MultipartFile file, @PathVariable String label) {
|
|
|
+ public Result importQuestionAndAnswer(@RequestPart("file") MultipartFile file, @PathVariable String label, @PathVariable String num) {
|
|
|
// FileInputStream fileInputStream = new FileInputStream(file);
|
|
|
String[] fileNames = Objects.requireNonNull(file.getOriginalFilename()).split("\\.");
|
|
|
File targetFile = null;
|
|
@@ -131,6 +131,7 @@ public class ChatController extends BaseController {
|
|
|
}
|
|
|
//chatQuestionEntity.setScaleFlag((String) item.get(4));
|
|
|
chatQuestionEntity.setLabel(label);
|
|
|
+ chatQuestionEntity.setNum(num);
|
|
|
chatQuestionEntityList.add(chatQuestionEntity);
|
|
|
});
|
|
|
answerList.forEach(item -> {
|
|
@@ -140,6 +141,7 @@ public class ChatController extends BaseController {
|
|
|
chatAnswerEntity.setAnswer((String) item.get(2));
|
|
|
chatAnswerEntity.setLabel(label);
|
|
|
chatAnswerEntity.setQuestionType("0");
|
|
|
+ chatAnswerEntity.setNum(num);
|
|
|
chatAnswerEntityList.add(chatAnswerEntity);
|
|
|
});
|
|
|
} catch (Exception e) {
|
|
@@ -159,10 +161,10 @@ public class ChatController extends BaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @GetMapping("/getAnswer/{questionNo}/{label}")
|
|
|
+ @GetMapping("/getAnswer/{questionNo}/{label}/{num}")
|
|
|
@ApiOperation("查询答案列表,questionNo为问题的id字段,nextQuestionNo 为此答案被选中后的下一个应该呈现的问题")
|
|
|
- public Result getAnswer(@PathVariable String questionNo, @PathVariable String label) {
|
|
|
- List<ChatAnswerEntity> answerEntities = this.answerService.findByQuestionNoAndLabel(questionNo, label);
|
|
|
+ public Result getAnswer(@PathVariable String questionNo, @PathVariable String label, @PathVariable String num) {
|
|
|
+ List<ChatAnswerEntity> answerEntities = this.answerService.findByQuestionNoAndLabelAndNum(questionNo, label, num);
|
|
|
return success(answerEntities);
|
|
|
}
|
|
|
|
|
@@ -174,7 +176,7 @@ public class ChatController extends BaseController {
|
|
|
if (resultQuestionEntity == null) {
|
|
|
return fail(ErrorCode.NEXT_QUESTION_NO_NOT_FOUND);
|
|
|
}
|
|
|
- ChatQuestionEntity byIdAndLabel = this.questionService.findByIdAndLabel(resultQuestionEntity.getNextQuestionNo(), label);
|
|
|
+ ChatQuestionEntity byIdAndLabel = this.questionService.findByIdAndLabelAndNum(resultQuestionEntity.getNextQuestionNo(), label, resultQuestionEntity.getNum());
|
|
|
if (byIdAndLabel == null) {
|
|
|
return fail(ErrorCode.NEXT_QUESTION_NO_ERROR);
|
|
|
}
|