|
@@ -1,6 +1,7 @@
|
|
|
package com.rf.kjb.chat.rest;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.auth0.jwt.interfaces.DecodedJWT;
|
|
|
import com.rf.kjb.base.rest.BaseController;
|
|
|
import com.rf.kjb.chat.dao.domain.*;
|
|
|
import com.rf.kjb.chat.service.ChatAnswerService;
|
|
@@ -11,6 +12,7 @@ import com.rf.kjb.excel.ExcelUtil;
|
|
|
import com.rf.kjb.exception.ErrorCode;
|
|
|
import com.rf.kjb.scale.util.DateUtil;
|
|
|
import com.rf.kjb.utils.FileUtils;
|
|
|
+import com.rf.kjb.utils.JWTUtil;
|
|
|
import com.rf.kjb.utils.Result;
|
|
|
import com.rf.kjb.utils.ZipUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -30,6 +32,7 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.net.URLEncoder;
|
|
@@ -64,12 +67,20 @@ public class ChatController extends BaseController {
|
|
|
|
|
|
@GetMapping("/getQuestion/{label}")
|
|
|
@ApiOperation("查询问题信息:首次查询时,id传空字符串即可查询出第一道题目;questionType=0表示选择题,questionType=1表示填空题;当改问题的nextQuestionNo 不为空是,则表示改题为陈述,没有答案,直接在显示此问题之后再次请求该接口显示questionNo对应的题目信息即可")
|
|
|
- public Result getQuestion(String id, @PathVariable String label) {
|
|
|
+ public Result getQuestion(String id, @PathVariable String label, HttpServletRequest request) {
|
|
|
|
|
|
if (StringUtils.isBlank(id)) {
|
|
|
id = "1";
|
|
|
}
|
|
|
ChatQuestionEntity questionEntity = this.questionService.findByIdAndLabel(id, label);
|
|
|
+ if (questionEntity.getId().equals("1")){
|
|
|
+ String token = request.getHeader("Authorization");
|
|
|
+ token = token.split(" ")[1];//以空格划分Bearer token,获取token
|
|
|
+ //从请求头中获取token
|
|
|
+ DecodedJWT verify = JWTUtil.verify(token);
|
|
|
+ String userName = verify.getClaim("userName").asString();
|
|
|
+ questionEntity.setQuestion(userName+questionEntity.getQuestion());
|
|
|
+ }
|
|
|
return success(questionEntity);
|
|
|
}
|
|
|
|
|
@@ -114,6 +125,7 @@ public class ChatController extends BaseController {
|
|
|
chatAnswerEntity.setNextQuestionNo((String) item.get(1));
|
|
|
chatAnswerEntity.setAnswer((String) item.get(2));
|
|
|
chatAnswerEntity.setLabel(label);
|
|
|
+ chatAnswerEntity.setQuestionType("0");
|
|
|
chatAnswerEntityList.add(chatAnswerEntity);
|
|
|
});
|
|
|
} catch (Exception e) {
|