Browse Source

修改对话记录功能提交

zsy 1 year ago
parent
commit
37fb51e44d

+ 3 - 0
src/main/java/com/rf/kjb/chat/dao/domain/ChatAnswerEntity.java

@@ -36,4 +36,7 @@ public class ChatAnswerEntity extends BaseEntry {
 
     @Column(name = "label",columnDefinition = "varchar(2) not null comment '分类:1-焦虑;2-抑郁;3-失眠;4-压力;5-开场白'")
     private String label;
+
+    @Column(name = "num",columnDefinition = "varchar(2) not null comment '对话轮次:1-第一次对话;2-第二次对话;3-第三次对话;4-第四次对话;5-第五次对话'")
+    private String num;
 }

+ 3 - 0
src/main/java/com/rf/kjb/chat/dao/domain/ChatQuestionEntity.java

@@ -37,4 +37,7 @@ public class ChatQuestionEntity   {
 
     @Column(name = "scale_flag",columnDefinition = "varchar(50) comment '量表标志,如果是量表的题目信息,此处为量表flag'")
     private String scaleFlag;
+
+    @Column(name = "num",columnDefinition = "varchar(2) not null comment '对话轮次:1-第一次对话;2-第二次对话;3-第三次对话;4-第四次对话;5-第五次对话'")
+    private String num;
 }

+ 3 - 0
src/main/java/com/rf/kjb/chat/dao/domain/ChatRecordEntity.java

@@ -35,4 +35,7 @@ public class ChatRecordEntity extends BaseEntry {
 
     @Column(name = "file_path",columnDefinition = "varchar(200) comment '文件路径'")
     private String filePath;
+
+    @Column(name = "num",columnDefinition = "varchar(2) not null comment '对话轮次:1-第一次对话;2-第二次对话;3-第三次对话;4-第四次对话;5-第五次对话'")
+    private String num;
 }

+ 3 - 0
src/main/java/com/rf/kjb/chat/dao/domain/ResultQuestionEntity.java

@@ -31,4 +31,7 @@ public class ResultQuestionEntity extends BaseEntry {
 
     @Column(name = "next_question_no",columnDefinition = "varchar(50) not null comment '下一问题编号'")
     private String nextQuestionNo;
+
+    @Column(name = "num",columnDefinition = "varchar(2) not null comment '对话轮次:1-第一次对话;2-第二次对话;3-第三次对话;4-第四次对话;5-第五次对话'")
+    private String num;
 }

+ 1 - 1
src/main/java/com/rf/kjb/chat/dao/repository/ChatAnswerRepository.java

@@ -9,7 +9,7 @@ import java.util.List;
 public interface ChatAnswerRepository extends BaseRepository<ChatAnswerEntity,String> {
     List<ChatAnswerEntity> findByQuestionNo(String questionNo);
 
-    List<ChatAnswerEntity> findByQuestionNoAndLabel(String questionNo, String label);
+    List<ChatAnswerEntity> findByQuestionNoAndLabelAndNum(String questionNo, String label, String num);
 
     void deleteByLabel(String label);
 }

+ 1 - 1
src/main/java/com/rf/kjb/chat/dao/repository/ChatQuestionRepository.java

@@ -6,7 +6,7 @@ import com.rf.kjb.chat.dao.domain.ChatQuestionEntity;
 import com.rf.kjb.chat.dao.domain.ChatQuestionId;
 
 public interface ChatQuestionRepository extends BaseRepository<ChatQuestionEntity, ChatQuestionId> {
-    ChatQuestionEntity findByIdAndLabel(String id, String label);
+    ChatQuestionEntity findByIdAndLabelAndNum(String id, String label, String num);
 
     void deleteByLabel(String label);
 }

+ 10 - 8
src/main/java/com/rf/kjb/chat/rest/ChatController.java

@@ -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);
         }

+ 1 - 1
src/main/java/com/rf/kjb/chat/service/ChatAnswerService.java

@@ -8,7 +8,7 @@ import java.util.List;
 public interface ChatAnswerService {
     List<ChatAnswerEntity> findByQuestionNo(String questionNo);
 
-    List<ChatAnswerEntity> findByQuestionNoAndLabel(String questionNo, String label);
+    List<ChatAnswerEntity> findByQuestionNoAndLabelAndNum(String questionNo, String label, String num);
     void deleteByLabel(String label);
 
     void saveBatch(List<ChatAnswerEntity> chatAnswerEntityList);

+ 1 - 1
src/main/java/com/rf/kjb/chat/service/ChatQuestionService.java

@@ -13,7 +13,7 @@ import java.util.List;
 public interface ChatQuestionService {
 //    ChatQuestionEntity findById(String id);
 
-    ChatQuestionEntity findByIdAndLabel(String id, String label);
+    ChatQuestionEntity findByIdAndLabelAndNum(String id, String label, String num);
 
     void deleteByLabel(String label);
 

+ 2 - 2
src/main/java/com/rf/kjb/chat/service/impl/ChatAnswerServiceImpl.java

@@ -24,8 +24,8 @@ public class ChatAnswerServiceImpl implements ChatAnswerService {
     }
 
     @Override
-    public List<ChatAnswerEntity> findByQuestionNoAndLabel(String questionNo, String label) {
-        return this.answerRepository.findByQuestionNoAndLabel(questionNo,label);
+    public List<ChatAnswerEntity> findByQuestionNoAndLabelAndNum(String questionNo, String label, String num) {
+        return this.answerRepository.findByQuestionNoAndLabelAndNum(questionNo,label,num);
     }
 
     @Override

+ 2 - 2
src/main/java/com/rf/kjb/chat/service/impl/ChatQuestionServiceImpl.java

@@ -24,8 +24,8 @@ public class ChatQuestionServiceImpl implements ChatQuestionService {
 //    }
 
     @Override
-    public ChatQuestionEntity findByIdAndLabel(String id, String label) {
-        return this.questionRepository.findByIdAndLabel(id,label);
+    public ChatQuestionEntity findByIdAndLabelAndNum(String id, String label, String num) {
+        return this.questionRepository.findByIdAndLabelAndNum(id,label,num);
     }
 
     @Override

+ 2 - 0
src/main/java/com/rf/kjb/intelligentDialogue/dao/domain/IntelligentDialogueEntity.java

@@ -39,5 +39,7 @@ public class IntelligentDialogueEntity extends BaseEntry {
     @Column(name = "question_no",columnDefinition = "varchar(50) null comment '问题编号'")
     private String questionNo;
 
+    @Column(name = "num",columnDefinition = "varchar(2) null comment '对话轮次:1-第一次对话;2-第二次对话;3-第三次对话;4-第四次对话;5-第五次对话'")
+    private String num;
 
 }

+ 1 - 1
src/main/java/com/rf/kjb/opLog/dao/model/SysLogEntity.java

@@ -27,7 +27,7 @@ import java.util.Date;
 @org.hibernate.annotations.Table(appliesTo = "t_sys_log", comment = "操作日志")
 public class SysLogEntity extends BaseEntry {
 
-    @Column(name = "identifier" ,columnDefinition = "varchar(20) not null unique comment '编号'")
+    @Column(name = "identifier" ,columnDefinition = "varchar(20) not null comment '编号'")
     private String identifier;
 
     @Column(name = "role",columnDefinition = "tinyint not null default 0 comment '角色:0普通用户 1管理员'")