zhouyy 3 miesięcy temu
rodzic
commit
38998c8bc9

+ 14 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/AIQuestionController.java

@@ -34,4 +34,18 @@ public class AIQuestionController {
         return responseEntity;
     }
 
+    @PostMapping("/getLatestQuestionList")
+    public HttpRespMsg getLatestQuestion(HttpServletRequest request){
+        HttpRespMsg msg = new HttpRespMsg();
+        msg = aiQuestionService.getLatestQuestionList(request);
+        return msg;
+    }
+
+    @PostMapping("/getHisQuestion")
+    public HttpRespMsg getHisQuestion(HttpServletRequest request){
+        HttpRespMsg msg = new HttpRespMsg();
+        msg = aiQuestionService.getHisQuestion(request);
+        return msg;
+    }
+
 }

+ 8 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/entity/AIQuestion.java

@@ -39,4 +39,12 @@ public class AIQuestion extends Model<AIQuestion> {
      */
     @TableField("creator_id")
     private String creatorId;
+
+    /**
+     * 会话名称
+     */
+    @TableField("name")
+    private String name;
+
+
 }

+ 4 - 0
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/AIQuestionService.java

@@ -12,4 +12,8 @@ public interface AIQuestionService extends IService<AIQuestion> {
     HttpRespMsg ask(QuestionBO questionBO, HttpServletRequest request);
 
     ResponseEntity<byte[]> downloadContent(Integer questionId, HttpServletRequest request);
+
+    HttpRespMsg getLatestQuestionList(HttpServletRequest request);
+
+    HttpRespMsg getHisQuestion(HttpServletRequest request);
 }

+ 47 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/service/impl/AIQuestionServiceImpl.java

@@ -339,11 +339,14 @@ public class AIQuestionServiceImpl extends ServiceImpl<AIQuestionMapper, AIQuest
             }
         }
 
+        Map<String,Object> resMap = new HashMap<>();
+
         if(null == questionBO.getQuestionId()){
             //提问获取回答,再插入
             AIQuestion aiQuestion = new AIQuestion();
             aiQuestion.setCompanyId(user.getCompanyId());
             aiQuestion.setCreatorId(user.getId());
+            aiQuestion.setName(questionBO.getContent());
             aiQuestionMapper.insert(aiQuestion);
 
             Integer questionId = aiQuestion.getQuestionId();
@@ -372,6 +375,8 @@ public class AIQuestionServiceImpl extends ServiceImpl<AIQuestionMapper, AIQuest
             aiAnswer.setStartDate(questionBO.getStartDate());
             aiAnswer.setEndDate(questionBO.getEndDate());
             aiQuestionDetailMapper.insert(aiAnswer);
+
+            resMap.put("questionId",questionId);
         } else {
             Integer questionId = questionBO.getQuestionId();
             AIQuestionDetail lastOne = aiQuestionDetailMapper.selectOne(new LambdaQueryWrapper<AIQuestionDetail>()
@@ -410,9 +415,12 @@ public class AIQuestionServiceImpl extends ServiceImpl<AIQuestionMapper, AIQuest
             aiAnswer.setEndDate(questionBO.getEndDate());
             aiQuestionDetailMapper.insert(aiAnswer);
 
+            resMap.put("questionId",questionId);
         }
 
-        httpRespMsg.setData(queryRes);
+
+        resMap.put("queryRes",queryRes);
+        httpRespMsg.setData(resMap);
         return httpRespMsg;
     }
 
@@ -472,6 +480,44 @@ public class AIQuestionServiceImpl extends ServiceImpl<AIQuestionMapper, AIQuest
                 .body(out.toByteArray());
     }
 
+    @Override
+    public HttpRespMsg getLatestQuestionList(HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("token"));
+        AIQuestion aiQuestion = aiQuestionMapper.selectOne(new LambdaQueryWrapper<AIQuestion>()
+                .eq(AIQuestion::getCreatorId, user.getId())
+                .orderByDesc(AIQuestion::getCreateTime)
+                .last(" limit 1")
+        );
+        Map<String,Object> resMap = new HashMap<>();
+        if(null != aiQuestion){
+            List<AIQuestionDetail> aiQuestionDetails = aiQuestionDetailMapper.selectList(new LambdaQueryWrapper<AIQuestionDetail>()
+                    .select(AIQuestionDetail::getQuestionId, AIQuestionDetail::getSeq
+                            , AIQuestionDetail::getType, AIQuestionDetail::getContent)
+                    .eq(AIQuestionDetail::getQuestionId, aiQuestion.getQuestionId())
+                    .orderByAsc(AIQuestionDetail::getSeq)
+            );
+
+
+            resMap.put("latestQuestionId",aiQuestion.getQuestionId());
+            resMap.put("contents",aiQuestionDetails);
+            httpRespMsg.setData(resMap);
+        }
+        return httpRespMsg;
+    }
+
+    @Override
+    public HttpRespMsg getHisQuestion(HttpServletRequest request) {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("token"));
+        List<AIQuestion> aiQuestions = aiQuestionMapper.selectList(new LambdaQueryWrapper<AIQuestion>()
+                .eq(AIQuestion::getCreatorId, user.getId())
+                .orderByDesc(AIQuestion::getCreateTime)
+        );
+        httpRespMsg.setData(aiQuestions);
+        return httpRespMsg;
+    }
+
     public static List<Map<String, Object>> convertListWithAlias(ResultSet rs) {
         List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
         try {