Ver código fonte

deepseek RAG功能代码

S0025136190 7 meses atrás
pai
commit
42d181af02
82 arquivos alterados com 4882 adições e 24 exclusões
  1. 7 0
      pom.xml
  2. 7 0
      takai-admin/pom.xml
  3. 0 4
      takai-admin/src/main/java/com/takai/web/controller/bigmodel/BigModelController.java
  4. 416 0
      takai-admin/src/main/java/com/takai/web/controller/takaiai/TakaiAiController.java
  5. 23 2
      takai-admin/src/main/resources/application.yml
  6. 66 0
      takai-ai/pom.xml
  7. 49 0
      takai-ai/src/main/java/com/takai/ai/config/MinioConfig.java
  8. 45 0
      takai-ai/src/main/java/com/takai/ai/domain/TakaiSysOss.java
  9. 83 0
      takai-ai/src/main/java/com/takai/ai/domain/TakaiSysOssConfig.java
  10. 16 0
      takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiAsyncCompletions.java
  11. 24 0
      takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiAsyncResult.java
  12. 20 0
      takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiDialogDetailReqDTO.java
  13. 24 0
      takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiDialogReqDTO.java
  14. 40 0
      takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiDialogRespDTO.java
  15. 15 0
      takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiQuestionDTO.java
  16. 13 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiAppInfo.java
  17. 197 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiApplication.java
  18. 146 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiApplicationParams.java
  19. 41 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiCompletionsParams.java
  20. 161 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiDocument.java
  21. 26 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiDocumentObject.java
  22. 138 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiDocumentParams.java
  23. 24 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiDocumentSettings.java
  24. 24 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiIndexType.java
  25. 151 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiKnowledge.java
  26. 106 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiKnowledgeInfo.java
  27. 71 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiKnowledgeParams.java
  28. 116 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiMediaReplacement.java
  29. 44 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiPageParams.java
  30. 25 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiPromptInfo.java
  31. 25 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiPromptObject.java
  32. 17 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiQuestion.java
  33. 44 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiQuestionInfo.java
  34. 44 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiResultApplication.java
  35. 39 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiResultKnowledge.java
  36. 24 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiSearchObject.java
  37. 17 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiSliceParams.java
  38. 14 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiSliceUpdateParams.java
  39. 118 0
      takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiSseInfoParams.java
  40. 16 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiAppInfoMapper.java
  41. 52 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiApplicationMapper.java
  42. 22 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiDialogMapper.java
  43. 50 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiDocumentMapper.java
  44. 15 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiDocumentSettingsMapper.java
  45. 49 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiKnowledgeMapper.java
  46. 48 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiMediaReplacementMapper.java
  47. 24 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiQuestionMapper.java
  48. 9 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiSysOssConfigMapper.java
  49. 9 0
      takai-ai/src/main/java/com/takai/ai/mapper/TakaiSysOssMapper.java
  50. 10 0
      takai-ai/src/main/java/com/takai/ai/service/IMinioConfigService.java
  51. 86 0
      takai-ai/src/main/java/com/takai/ai/service/ITakaiAiService.java
  52. 39 0
      takai-ai/src/main/java/com/takai/ai/service/impl/MinioConfigServiceImpl.java
  53. 810 0
      takai-ai/src/main/java/com/takai/ai/service/impl/TakaiAiServiceImpl.java
  54. 155 0
      takai-ai/src/main/java/com/takai/ai/utils/MinioUtil.java
  55. 72 0
      takai-ai/src/main/java/com/takai/ai/utils/SnowflakeDigitGenerator.java
  56. 42 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiAppInfoMapper.xml
  57. 111 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiApplicationMapper.xml
  58. 179 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiDialogMapper.xml
  59. 103 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiDocumentMapper.xml
  60. 67 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiDocumentSettingsMapper.xml
  61. 97 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiKnowledgeMapper.xml
  62. 83 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiMediaReplacementMapper.xml
  63. 61 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiQuestionMapper.xml
  64. 35 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiSysOssConfigMapper.xml
  65. 40 0
      takai-ai/src/main/resources/mapper/takaiai/TakaiSysOssMapper.xml
  66. 0 2
      takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/BmApplicationMapper.java
  67. 0 1
      takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/BmDocumentMapper.java
  68. 0 1
      takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/BmKnowledgeMapper.java
  69. 0 3
      takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/BmMediaReplacementMapper.java
  70. 0 2
      takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/DialogMapper.java
  71. 0 2
      takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/QuestionMapper.java
  72. 3 0
      takai-bigmodel/src/main/java/com/takai/bigmodel/service/IBigModelService.java
  73. 4 1
      takai-bigmodel/src/main/java/com/takai/bigmodel/service/impl/BigModelServiceImpl.java
  74. 1 1
      takai-bigmodel/src/main/resources/mapper/bm/BmApplicationMapper.xml
  75. 1 1
      takai-bigmodel/src/main/resources/mapper/bm/DialogMapper.xml
  76. 1 1
      takai-common/src/main/java/com/takai/common/annotation/DataSource.java
  77. 120 0
      takai-common/src/main/java/com/takai/common/config/DeepseekConfig.java
  78. 1 0
      takai-common/src/main/java/com/takai/common/utils/PageUtils.java
  79. 1 1
      takai-framework/src/main/java/com/takai/framework/config/DruidConfig.java
  80. 1 1
      takai-framework/src/main/java/com/takai/framework/config/SecurityConfig.java
  81. 4 0
      takai-quartz/src/main/java/com/takai/quartz/service/impl/SysJobServiceImpl.java
  82. 1 1
      takai-system/src/main/java/com/takai/system/service/impl/SysConfigServiceImpl.java

+ 7 - 0
pom.xml

@@ -175,6 +175,12 @@
                 <version>${takai.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>com.takai</groupId>
+                <artifactId>takai-ai</artifactId>
+                <version>${takai.version}</version>
+            </dependency>
+
         </dependencies>
     </dependencyManagement>
 
@@ -186,6 +192,7 @@
         <module>takai-generator</module>
         <module>takai-common</module>
         <module>takai-bigmodel</module>
+        <module>takai-ai</module>
     </modules>
     <packaging>pom</packaging>
 

+ 7 - 0
takai-admin/pom.xml

@@ -71,6 +71,13 @@
             <scope>compile</scope>
         </dependency>
 
+        <dependency>
+            <groupId>com.takai</groupId>
+            <artifactId>takai-ai</artifactId>
+            <version>1.0.0</version>
+            <scope>compile</scope>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 0 - 4
takai-admin/src/main/java/com/takai/web/controller/bigmodel/BigModelController.java

@@ -11,11 +11,7 @@ import com.takai.common.annotation.Log;
 import com.takai.common.config.BigModelConfig;
 import com.takai.common.core.controller.BaseController;
 import com.takai.common.core.domain.AjaxResult;
-import com.takai.common.core.domain.BaseEntity;
-import com.takai.common.core.domain.entity.Prompt;
-import com.takai.common.core.page.PageDomain;
 import com.takai.common.core.page.TableDataInfo;
-import com.takai.common.core.page.TableSupport;
 import com.takai.common.enums.BusinessType;
 import com.takai.common.utils.poi.ExcelUtil;
 import lombok.extern.slf4j.Slf4j;

+ 416 - 0
takai-admin/src/main/java/com/takai/web/controller/takaiai/TakaiAiController.java

@@ -0,0 +1,416 @@
+package com.takai.web.controller.takaiai;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.takai.ai.domain.entity.*;
+import com.takai.ai.service.ITakaiAiService;
+import com.takai.bigmodel.domain.dto.DialogRespDTO;
+import com.takai.bigmodel.domain.entity.PageParams;
+import com.takai.common.core.controller.BaseController;
+import com.takai.common.core.domain.AjaxResult;
+import com.takai.common.core.page.TableDataInfo;
+import com.takai.ai.domain.dto.TakaiDialogRespDTO;
+import com.takai.common.utils.poi.ExcelUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@RestController
+@RequestMapping("/takai/api")
+public class TakaiAiController extends BaseController {
+
+    @Autowired
+    private ITakaiAiService takaiAisService;
+
+    /**
+     * 对话聊天
+     * @param response
+     * @param request
+     * @param sseParams
+     * @return
+     */
+    @PostMapping(value = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
+    public SseEmitter chat(HttpServletResponse response, HttpServletRequest request, @RequestBody TakaiSseInfoParams sseParams)
+    {
+        return takaiAisService.sseInvoke(sseParams);
+    }
+
+    @PostMapping("/async/completions")
+    public AjaxResult asyncCompletions(@RequestBody TakaiCompletionsParams params)
+    {
+        return success(takaiAisService.asyncCompletions(params));
+    }
+
+    /**
+     * 对话详情
+     * @param dialogId
+     * @return
+     */
+    @GetMapping("/dialog/detail/{dialogId}")
+    public AjaxResult dialogDetail(@PathVariable String dialogId)
+    {
+        List<TakaiDialogRespDTO> detail = takaiAisService.getDialogDetail(dialogId);
+        return AjaxResult.success(detail);
+    }
+
+    /**
+     * 应用列表
+     * @param params
+     * @return
+     */
+    @PostMapping("/getApplicationList")
+    public TableDataInfo getApplicationList(@RequestBody TakaiPageParams params)
+    {
+        List<TakaiApplication> s = takaiAisService.getApplicationList();
+        PageHelper.startPage(params.getPageNumber(), params.getPageSize(), "").setReasonable(true);
+        List<TakaiApplication> list = takaiAisService.getApplicationList();
+        return getDataTableResultTotal(list, Long.valueOf(s.size()));
+    }
+
+    /**
+     * 创建应用
+     * @param params
+     * @return
+     */
+    @PostMapping("/createApplication")
+    public AjaxResult addApplication(@RequestBody TakaiApplicationParams params)
+    {
+        int i = takaiAisService.createApplication(params);
+        return AjaxResult.success(i);
+    }
+
+    /**
+     * 查询应用详情
+     * @param appId
+     * @return
+     */
+    @GetMapping("/selectApplication/{appId}")
+    public AjaxResult selectApplication(@PathVariable String appId)
+    {
+        JSONObject application = takaiAisService.selectApplication(appId);
+        return AjaxResult.success(application);
+    }
+
+    /**
+     * 修改应用
+     * @param params
+     * @param appId
+     * @return
+     */
+    @PutMapping("/updateApplication/{appId}")
+    public AjaxResult updateApplication(@RequestBody TakaiApplicationParams params, @PathVariable String appId)
+    {
+        int application = takaiAisService.updateApplication(params, appId);
+        return AjaxResult.success(application);
+    }
+
+    /**
+     * 删除应用
+     * @param appId
+     * @return
+     */
+    @DeleteMapping("/delApplication/{appId}")
+    public AjaxResult delApplication(@PathVariable String appId)
+    {
+        int application = takaiAisService.delApplication(appId);
+        return AjaxResult.success(application);
+    }
+
+    /**
+     * 首页
+     * @param params
+     * @return
+     */
+    @PostMapping("/index")
+    public AjaxResult index(@RequestBody PageParams params){
+        // 问答应用总数
+        List<TakaiApplication> appList = takaiAisService.getApplicationList();
+        // 知识库总数
+        List<TakaiKnowledge> knowledgeList = takaiAisService.queryKnowledgeList();
+        Map<String, Object> map = new HashMap();
+        map.put("applicationCount", appList.size());
+        map.put("knowledgeCount", knowledgeList.size());
+        return success(map);
+    }
+
+    /**
+     * 获取知识库下拉列表
+     * @return
+     */
+    @GetMapping("/knowledgeList")
+    public AjaxResult getApplicationList(){
+        return success(takaiAisService.queryKnowledgeList());
+    }
+
+
+    /**
+     * 知识库列表
+     * @param params
+     * @return
+     */
+    @PostMapping("/getKnowledgeList")
+    public TableDataInfo getKnowledgeList(@RequestBody TakaiPageParams params)
+    {
+        List<TakaiKnowledge> s = takaiAisService.queryKnowledgeList();
+        PageHelper.startPage(params.getPageNumber(), params.getPageSize(), "").setReasonable(true);
+        List<TakaiKnowledge> list = takaiAisService.queryKnowledgeList();
+        return getDataTableResultTotal(list, Long.valueOf(s.size()));
+    }
+
+    /**
+     * 创建知识库
+     * @param knowledge
+     * @return
+     */
+    @PostMapping("/createKnowledge")
+    public AjaxResult createKnowledge(@RequestBody TakaiKnowledgeParams knowledge) {
+        int i = takaiAisService.createKnowledge(knowledge);
+        return success(i);
+    }
+
+    /**
+     * 知识库详情
+     * @param knowledgeId
+     * @return
+     */
+    @GetMapping("/detailKnowledge/{knowledgeId}")
+    public AjaxResult detailKnowledge(@PathVariable String knowledgeId){
+        TakaiKnowledge result = takaiAisService.detailKnowledge(knowledgeId);
+        return success(result);
+    }
+
+    /**
+     * 修改知识库
+     * @param knowledge
+     * @param knowledgeId
+     * @return
+     */
+    @PutMapping("/updateKnowledge/{knowledgeId}")
+    public AjaxResult updateKnowledge(@RequestBody TakaiKnowledgeParams knowledge, @PathVariable String knowledgeId) {
+        int i = takaiAisService.updateKnowledge(knowledge, knowledgeId);
+        return success(i);
+    }
+
+    /**
+     * 删除知识库
+     * @param knowledgeId
+     * @return
+     */
+    @DeleteMapping("/delKnowledge/{knowledgeId}")
+    public AjaxResult delKnowledge(@PathVariable String knowledgeId) {
+        int i = takaiAisService.delKnowledge(knowledgeId);
+        return success(i);
+    }
+
+    /**
+     * 知识列表
+     * @param params
+     * @return
+     */
+    @PostMapping("/documentList")
+    public TableDataInfo documentList(@RequestBody TakaiDocumentParams params) {
+        List<TakaiDocument> sTotal = takaiAisService.documentList(params);
+        PageHelper.startPage(params.getPage(), params.getSize(), "").setReasonable(true);
+        List<TakaiDocument> list = takaiAisService.documentList(params);
+        return getDataTableResultTotal(list, Long.valueOf(sTotal.size()));
+    }
+
+    /**
+     * 知识详情
+     * @param documentId
+     * @return
+     */
+    @GetMapping("/documentDetail/{documentId}")
+    public AjaxResult documentDetail(@PathVariable String documentId){
+        return success(takaiAisService.documentDetail(documentId));
+    }
+
+    /**
+     * 更新知识
+     * @param params
+     * @param documentId
+     * @return
+     */
+    @PutMapping("/updateDocument/{documentId}")
+    public AjaxResult updateDocument(@RequestBody TakaiDocumentParams params, @PathVariable String documentId) {
+        int i = takaiAisService.updateDocument(params, documentId);
+        return success(i);
+    }
+
+    /**
+     * 删除知识
+     * @param documentId
+     * @return
+     */
+    @DeleteMapping("/delDocument/{documentId}")
+    public AjaxResult delDocument(@PathVariable String documentId) {
+        int i = takaiAisService.delDocument(documentId);
+        return success(i);
+    }
+
+    /**
+     * 上传知识文件
+     * @param file
+     * @param knowledgeId
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/uploadDocument/{knowledgeId}") //@RequestPart DocumentParams documentParams,
+    public AjaxResult uploadDocument(@RequestParam("file") MultipartFile file,
+                                     @PathVariable String knowledgeId) throws Exception {
+        try{
+            int i = takaiAisService.uploadDocument(file, knowledgeId);
+            return success(i);
+        }catch (Exception e){
+            return error("0");
+        }
+    }
+
+    /**
+     *
+     * 获取知识配置信息
+     * @param documentId
+     * @return
+     */
+    @GetMapping("/documentSetting/{documentId}")
+    public AjaxResult documentSetting(@PathVariable String documentId) {
+        TakaiDocumentSettings json = takaiAisService.documentSetting(documentId);
+        return success(json);
+    }
+
+    /**
+     * 更新知识配置详情
+     * @param documentSetting
+     * @param documentId
+     * @return
+     */
+    @PutMapping("/updateDocumentSetting/{documentId}")
+    public AjaxResult updateDocumentSetting(@RequestBody TakaiDocumentSettings documentSetting, @PathVariable String documentId) {
+        int i = takaiAisService.updateDocumentSetting(documentSetting, documentId); // 更新知识配置信息
+        return success(i);
+    }
+
+    /**
+     * 获取切片列表
+     * @param params
+     * @return
+     */
+    @PostMapping("/getSliceList")
+    public AjaxResult getDialogDetail(@RequestBody TakaiSliceParams params) {
+        JSONObject json = takaiAisService.getSliceList(params);
+        return success(json);
+    }
+
+    /**
+     * 删除切片
+     * @param sliceId
+     * @param knowledgeId
+     */
+    @DeleteMapping("/deleteSlice/{sliceId}/{knowledgeId}")
+    public AjaxResult deleteSlice(@PathVariable String sliceId, @PathVariable String knowledgeId) {
+        return success (takaiAisService.deleteSlice(sliceId, knowledgeId));
+    }
+
+    /**
+     * 切片详情
+     * @param sliceId
+     * @param knowledgeId
+     * @return
+     */
+    @GetMapping("/getSliceDetail/{sliceId}/{knowledgeId}")
+    public AjaxResult test(@PathVariable String sliceId, @PathVariable String knowledgeId) {
+        JSONObject json = takaiAisService.getSliceDetail(sliceId, knowledgeId);
+        return success(json);
+    }
+
+    /**
+     * 更新切片信息
+     * @param params
+     * @return
+     */
+    @PutMapping("/updateSliceInfo")
+    public AjaxResult updateSliceInfo(@RequestBody TakaiSliceUpdateParams params)
+    {
+        return success(takaiAisService.updateSliceInfo(params));
+    }
+
+    /**
+     * 获取聊天列表
+     * @param params
+     * @return
+     */
+    @PostMapping("/chatHistory/list")
+    public TableDataInfo dataExportList(@RequestBody TakaiPageParams params){
+        if(StringUtils.isNotBlank(params.getAppId())){
+            //获取应用聊天列表
+            List<Object> s = takaiAisService.selectDialogListByAppId(params.getAppId(), params.getUserId());
+            PageHelper.startPage(params.getPageNumber(), params.getPageSize(), "").setReasonable(true);
+            List<Object> list = takaiAisService.selectDialogListByAppId(params.getAppId(), params.getUserId());
+            return getDataTableResultTotal(list, Long.valueOf(s.size()));
+        }else{
+            //获取所有列表
+            List<Object> s = takaiAisService.selectDialogListByAppId(null, null);
+            PageHelper.startPage(params.getPageNumber(), params.getPageSize(), "").setReasonable(true);
+            List<Object> list = takaiAisService.selectDialogListByAppId(null, null);
+            return getDataTableResultTotal(list, Long.valueOf(s.size()));
+        }
+    }
+
+
+    /**
+     * 导出聊天记录
+     * @param response
+     * @param id
+     */
+    @PostMapping("/dialog/export/{id}")
+    public void export(HttpServletResponse response, @PathVariable String id) {
+        List<TakaiDialogRespDTO> dialogs = takaiAisService.exportExcel(id);
+        ExcelUtil<TakaiDialogRespDTO> util = new ExcelUtil(TakaiDialogRespDTO.class);
+        util.exportExcel(response, dialogs, "聊天记录");
+    }
+
+
+
+
+
+
+
+
+
+
+
+    @GetMapping("/download/{fileName}")
+    public void downloadFile(@PathVariable String fileName) {
+        try {
+//            InputStream stream = minioUtil.download(bucketName, fileName);
+            // 这里简化处理,实际应该设置正确的Content-Type和Content-Disposition
+//            return ResponseEntity.ok()
+//                    .header("Content-Type", "application/octet-stream")
+//                    .header("Content-Disposition", "attachment; filename=\"" + fileName + "\"")
+//                    .body(stream);
+        } catch (Exception e) {
+            logger.error("文件下载失败: " + e.getMessage());
+        }
+    }
+
+    @DeleteMapping("/delete/{fileName}")
+    public void deleteFile(@PathVariable String fileName) {
+        try {
+//            minioUtil.remove(bucketName, fileName);
+        } catch (Exception e) {
+            logger.error("文件删除失败: " + e.getMessage());
+        }
+    }
+
+}

+ 23 - 2
takai-admin/src/main/resources/application.yml

@@ -162,5 +162,26 @@ bigmodel:
   modelList: https://open.bigmodel.cn/api/biz/model/trial/list
   #提示词
   prompt: 你是总结和提问大师。 """应用的名称:{{应用名称}} 这是用户的历史对话记录:{{历史对话}}""" 你只根据用户的对话记录,推演出用户接下来可能提出的问题,不要杜撰问题。可以参考应用的名称和应用的简介。 你必须遵守以下要求:1. 不要输出用户问过的问题;2. 你需要输出3个问题供用户选择。3. 你只需要输出问题,不需要解释,不需要提问。4. 你的问题可以是空的,但你不能杜撰问题。5. 问题需要站在使用这个应用的人的视角提出,因此你要注意提问的语气和人称代词。不要用您这个字。你一定要按照以下格式输出:{"问题":["xxx","xxx","xxx"]}
-
-
+deepseek:
+  #base url
+  baseurl: http://192.168.3.209:6000
+  #创建知识库
+  createKnowledge: /rag/create_collection
+  #删除知识库
+  deleteKnowledge: /rag/delete_knowledge
+  #获取切片列表
+  slicePage: /rag/search_word
+  #删除切片
+  deleteSlice: /rag/delete_slice
+  #切片详情
+  sliceDetail: /rag/search
+  #编辑切片信息
+  updateSlice: /rag/update_slice
+  #上传文件
+  uploadKnowledge: /upload_knowledge
+  #聊天
+  chat: /rag/chat
+  #异步提示词(还想问)
+  asyncCompletions: /rag/query
+  #提示词
+  prompt: 你是总结和提问大师。你只根据用户的对话记录,推演出用户接下来可能提出的问题,不要杜撰问题。可以参考应用的名称和应用的简介。 你必须遵守以下要求:1. 不要输出用户问过的问题;2. 你需要输出3个问题供用户选择。3. 你只需要输出问题,不需要解释,不需要提问。4. 你的问题可以是空的,但你不能杜撰问题。5. 问题需要站在使用这个应用的人的视角提出,因此你要注意提问的语气和人称代词。不要用您这个字。你一定要按照以下格式输出:{"问题":["xxx","xxx","xxx"]}

+ 66 - 0
takai-ai/pom.xml

@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>takai</artifactId>
+        <groupId>com.takai</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>takai-ai</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+    <description>
+        takaiAI模块
+    </description>
+
+    <dependencies>
+
+        <!-- 通用工具-->
+        <dependency>
+            <groupId>com.takai</groupId>
+            <artifactId>takai-common</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-webmvc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>4.9.3</version>
+<!--            <exclusions>-->
+<!--                <exclusion>-->
+<!--                    <groupId>com.squareup.okio</groupId>-->
+<!--                    <artifactId>okio</artifactId>-->
+<!--                </exclusion>-->
+<!--            </exclusions>-->
+        </dependency>
+
+        <dependency>
+            <groupId>io.minio</groupId>
+            <artifactId>minio</artifactId>
+            <version>7.1.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp-sse</artifactId>
+            <version>4.9.3</version>
+        </dependency>
+
+    </dependencies>
+
+</project>

+ 49 - 0
takai-ai/src/main/java/com/takai/ai/config/MinioConfig.java

@@ -0,0 +1,49 @@
+package com.takai.ai.config;
+
+import com.takai.ai.domain.TakaiSysOssConfig;
+import com.takai.ai.service.IMinioConfigService;
+import io.minio.MinioClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.beans.factory.annotation.Value;
+
+@Configuration
+public class MinioConfig {
+
+    @Bean
+    public MinioClient minioClient(@Autowired IMinioConfigService configService) throws Exception {
+        TakaiSysOssConfig config = configService.getCurrentConfig();
+        return MinioClient.builder()
+                .endpoint(config.getEndpoint())
+                .credentials(config.getAccessKey(), config.getSecretKey())
+                .build();
+    }
+
+    @Bean
+    public String minioBucketName(@Autowired IMinioConfigService configService) {
+        return configService.getCurrentConfig().getBucketName();
+    }
+
+
+//    @Value("${minio.endpoint}")
+//    private String endpoint;
+//
+//    @Value("${minio.accessKey}")
+//    private String accessKey;
+//
+//    @Value("${minio.secretKey}")
+//    private String secretKey;
+//
+//    @Value("${minio.bucketName}")
+//    private String bucketName;
+//
+//    @Bean
+//    public MinioClient minioClient() {
+//        return MinioClient.builder()
+//                .endpoint(endpoint)
+//                .credentials(accessKey, secretKey)
+//                .build();
+//    }
+
+}

+ 45 - 0
takai-ai/src/main/java/com/takai/ai/domain/TakaiSysOss.java

@@ -0,0 +1,45 @@
+package com.takai.ai.domain;
+
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * OSS对象存储对象
+ *
+ * @author Lion Li
+ */
+@Data
+public class TakaiSysOss extends BaseEntity {
+
+    /**
+     * 对象存储主键
+     */
+    private String ossId;
+
+    /**
+     * 文件名
+     */
+    private String fileName;
+
+    /**
+     * 原名
+     */
+    private String originalName;
+
+    /**
+     * 文件后缀名
+     */
+    private String fileSuffix;
+
+    /**
+     * URL地址
+     */
+    private String url;
+
+    /**
+     * 服务商
+     */
+    private String service;
+
+}

+ 83 - 0
takai-ai/src/main/java/com/takai/ai/domain/TakaiSysOssConfig.java

@@ -0,0 +1,83 @@
+package com.takai.ai.domain;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 对象存储配置对象 sys_oss_config
+ *
+ * @author Lion Li
+ */
+@Data
+public class TakaiSysOssConfig extends BaseEntity {
+
+    /**
+     * 主建
+     */
+    private Long ossConfigId;
+
+    /**
+     * 配置key
+     */
+    private String configKey;
+
+    /**
+     * accessKey
+     */
+    private String accessKey;
+
+    /**
+     * 秘钥
+     */
+    private String secretKey;
+
+    /**
+     * 桶名称
+     */
+    private String bucketName;
+
+    /**
+     * 前缀
+     */
+    private String prefix;
+
+    /**
+     * 访问站点
+     */
+    private String endpoint;
+
+    /**
+     * 自定义域名
+     */
+    private String domain;
+
+    /**
+     * 是否https(0否 1是)
+     */
+    private String isHttps;
+
+    /**
+     * 域
+     */
+    private String region;
+
+    /**
+     * 是否默认(0=是,1=否)
+     */
+    private String status;
+
+    /**
+     * 扩展字段
+     */
+    private String ext1;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 桶权限类型(0private 1public 2custom)
+     */
+    private String accessPolicy;
+}

+ 16 - 0
takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiAsyncCompletions.java

@@ -0,0 +1,16 @@
+package com.takai.ai.domain.dto;
+
+import lombok.Data;
+
+@Data
+public class TakaiAsyncCompletions {
+
+    private String id;
+
+    private String model;
+
+    private String request_id;
+
+    private String task_status;
+
+}

+ 24 - 0
takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiAsyncResult.java

@@ -0,0 +1,24 @@
+package com.takai.ai.domain.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TakaiAsyncResult {
+
+    private List choices;
+
+    private String created;
+
+    private String id;
+
+    private String model;
+
+    private String request_id;
+
+    private String task_status;
+
+    private Object usage;
+
+}

+ 20 - 0
takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiDialogDetailReqDTO.java

@@ -0,0 +1,20 @@
+package com.takai.ai.domain.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class TakaiDialogDetailReqDTO {
+
+    @NotNull(message = "明细id不能为空")
+    private String id;
+
+    private String role;
+
+    private String content;
+
+    private String date;
+
+    private String dialogId;
+}

+ 24 - 0
takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiDialogReqDTO.java

@@ -0,0 +1,24 @@
+package com.takai.ai.domain.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class TakaiDialogReqDTO {
+
+    //@NotNull(message = "id不能为空")
+    private String id;
+
+    private String appId;
+
+    private String knowledgeId;
+
+    private String userId;
+
+    private String dialogName;
+
+    private List<TakaiDialogDetailReqDTO> messages;
+
+
+}

+ 40 - 0
takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiDialogRespDTO.java

@@ -0,0 +1,40 @@
+package com.takai.ai.domain.dto;
+
+import com.takai.common.annotation.Excel;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+public class TakaiDialogRespDTO {
+
+    @Excel(name = "日志ID")
+    private String id;
+
+    @Excel(name = "AppID")
+    private String appId;
+
+    @Excel(name = "知识库ID")
+    private String knowledgeIdd;
+
+    @Excel(name = "用户ID")
+    private String userId;
+
+    private String did;
+
+    @Excel(name = "聊天标题")
+    private String dialog_name;
+
+    private String dialog_id;
+
+    @Excel(name = "类型")
+    private String type;
+
+    @Excel(name = "聊天内容")
+    private String content;
+
+    @Excel(name = "创建时间")
+    private LocalDateTime create_time;
+
+
+}

+ 15 - 0
takai-ai/src/main/java/com/takai/ai/domain/dto/TakaiQuestionDTO.java

@@ -0,0 +1,15 @@
+package com.takai.ai.domain.dto;
+
+import lombok.Data;
+
+@Data
+public class TakaiQuestionDTO {
+
+    private String id;
+
+    private String appId;
+
+    private String question;
+
+    private String createTime;
+}

+ 13 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiAppInfo.java

@@ -0,0 +1,13 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Data;
+
+@Data
+public class TakaiAppInfo extends BaseEntity {
+
+    private String appId;
+
+    private String appInfo;
+
+}

+ 197 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiApplication.java

@@ -0,0 +1,197 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Builder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 智谱应用列表 bm_application
+ * 
+ * @author takai
+ */
+@Builder
+public class TakaiApplication extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+
+    /** 应用ID */
+    private String appId;
+
+    /** 应用名称 */
+    private String name;
+
+    /** 应用描述 */
+    private String desc;
+
+    /** 模版 */
+    private String prompt;
+
+    /** 采样温度的另一种方式 */
+    private String topP;
+
+    /** 采样温度 */
+    private String temperature;
+
+    /** 知识库id列表 */
+    private String knowledgeIds;
+
+    /** 分片数量 */
+    private Integer sliceCount;
+
+    /** model */
+    private String model;
+
+    /** icon_color */
+    private String iconColor;
+
+    /** icon_type */
+    private String iconType;
+
+    /** max_token */
+    private Integer maxToken;
+
+    private String knowledgeInfo;
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+    public String getPrompt() {
+        return prompt;
+    }
+
+    public void setPrompt(String prompt) {
+        this.prompt = prompt;
+    }
+
+    public String getTopP() {
+        return topP;
+    }
+
+    public void setTopP(String topP) {
+        this.topP = topP;
+    }
+
+    public String getTemperature() {
+        return temperature;
+    }
+
+    public void setTemperature(String temperature) {
+        this.temperature = temperature;
+    }
+
+    public String getKnowledgeIds() {
+        return knowledgeIds;
+    }
+
+    public void setKnowledgeIds(String knowledgeIds) {
+        this.knowledgeIds = knowledgeIds;
+    }
+
+    public Integer getSliceCount() {
+        return sliceCount;
+    }
+
+    public void setSliceCount(Integer sliceCount) {
+        this.sliceCount = sliceCount;
+    }
+
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    public String getIconColor() {
+        return iconColor;
+    }
+
+    public void setIconColor(String iconColor) {
+        this.iconColor = iconColor;
+    }
+
+    public String getIconType() {
+        return iconType;
+    }
+
+    public void setIconType(String iconType) {
+        this.iconType = iconType;
+    }
+
+    public Integer getMaxToken() {
+        return maxToken;
+    }
+
+    public void setMaxToken(Integer maxToken) {
+        this.maxToken = maxToken;
+    }
+
+    public String getKnowledgeInfo() {
+        return knowledgeInfo;
+    }
+
+    public void setKnowledgeInfo(String knowledgeInfo) {
+        this.knowledgeInfo = knowledgeInfo;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("appId", getAppId())
+            .append("name", getName())
+            .append("desc", getDesc())
+            .append("prompt", getPrompt())
+            .append("topP", getTopP())
+            .append("temperature", getTemperature())
+            .append("knowledgeIds", getKnowledgeIds())
+            .append("sliceCount", getSliceCount())
+            .append("model", getModel())
+            .append("iconColor", getIconColor())
+            .append("iconType", getIconType())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("maxToken", getMaxToken())
+            .append("knowledgeInfo", getKnowledgeInfo())
+            .toString();
+    }
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        TakaiApplication that = (TakaiApplication) o;
+
+        return appId.equals(that.appId);
+    }
+
+    @Override
+    public int hashCode() {
+        return  appId.hashCode();
+    }
+}

+ 146 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiApplicationParams.java

@@ -0,0 +1,146 @@
+package com.takai.ai.domain.entity;
+
+import java.util.List;
+
+public class TakaiApplicationParams {
+
+    private String name;
+
+    private String desc;
+
+    private String prompt;
+
+    private String top_p;
+
+    private String temperature;
+
+    private String knowledge_ids;
+
+    private String model;
+
+    private String icon_color;
+
+    private String icon_type;
+
+    private String knowledge_info;
+
+    private String param_desc;
+
+    private Integer max_token;
+
+    private Integer slice_count;
+
+    private List<String> questionList;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+    public String getPrompt() {
+        return prompt;
+    }
+
+    public void setPrompt(String prompt) {
+        this.prompt = prompt;
+    }
+
+    public String getTop_p() {
+        return top_p;
+    }
+
+    public void setTop_p(String top_p) {
+        this.top_p = top_p;
+    }
+
+    public String getTemperature() {
+        return temperature;
+    }
+
+    public void setTemperature(String temperature) {
+        this.temperature = temperature;
+    }
+
+    public String getKnowledge_ids() {
+        return knowledge_ids;
+    }
+
+    public void setKnowledge_ids(String knowledge_ids) {
+        this.knowledge_ids = knowledge_ids;
+    }
+
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    public String getIcon_color() {
+        return icon_color;
+    }
+
+    public void setIcon_color(String icon_color) {
+        this.icon_color = icon_color;
+    }
+
+    public String getIcon_type() {
+        return icon_type;
+    }
+
+    public void setIcon_type(String icon_type) {
+        this.icon_type = icon_type;
+    }
+
+    public String getKnowledge_info() {
+        return knowledge_info;
+    }
+
+    public void setKnowledge_info(String knowledge_info) {
+        this.knowledge_info = knowledge_info;
+    }
+
+    public String getParam_desc() {
+        return param_desc;
+    }
+
+    public void setParam_desc(String param_desc) {
+        this.param_desc = param_desc;
+    }
+
+    public Integer getMax_token() {
+        return max_token;
+    }
+
+    public void setMax_token(Integer max_token) {
+        this.max_token = max_token;
+    }
+
+    public List<String> getQuestionList() {
+        return questionList;
+    }
+
+    public void setQuestionList(List<String> questionList) {
+        this.questionList = questionList;
+    }
+
+    public Integer getSlice_count() {
+        return slice_count;
+    }
+
+    public void setSlice_count(Integer slice_count) {
+        this.slice_count = slice_count;
+    }
+}

+ 41 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiCompletionsParams.java

@@ -0,0 +1,41 @@
+package com.takai.ai.domain.entity;
+
+import java.util.List;
+
+public class TakaiCompletionsParams {
+
+    private static final long serialVersionUID = 1L;
+
+    private String appId;
+
+    private String model;
+
+    /**
+     * messages
+     */
+    private List<TakaiPromptInfo> messages;
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    public List<TakaiPromptInfo> getMessages() {
+        return messages;
+    }
+
+    public void setMessages(List<TakaiPromptInfo> messages) {
+        this.messages = messages;
+    }
+}

+ 161 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiDocument.java

@@ -0,0 +1,161 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Builder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 智谱知识列表 bm_document
+ * 
+ * @author takai
+ */
+@Builder
+public class TakaiDocument extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+
+    /** 知识ID */
+    private String documentId;
+
+    private String knowledgeId;
+
+    /** 切片规则 */
+    private String customSeparator;
+
+    /** 知识类型 */
+    private Integer knowledgeType;
+
+    /** 切片大小 */
+    private String sentenceSize;
+
+    /** 文件字数 */
+    private Integer wordNum;
+
+    /** 文件大小(字节) */
+    private Integer length;
+
+    /** 文件名 */
+    private String name;
+
+    /** 文件下载链接 */
+    private String url;
+
+    private Integer parseImage;
+
+    public String getDocumentId() {
+        return documentId;
+    }
+
+    public void setDocumentId(String documentId) {
+        this.documentId = documentId;
+    }
+
+    public String getKnowledgeId() {
+        return knowledgeId;
+    }
+
+    public void setKnowledgeId(String knowledgeId) {
+        this.knowledgeId = knowledgeId;
+    }
+
+    public String getCustomSeparator() {
+        return customSeparator;
+    }
+
+    public void setCustomSeparator(String customSeparator) {
+        this.customSeparator = customSeparator;
+    }
+
+    public Integer getKnowledgeType() {
+        return knowledgeType;
+    }
+
+    public void setKnowledgeType(Integer knowledgeType) {
+        this.knowledgeType = knowledgeType;
+    }
+
+    public String getSentenceSize() {
+        return sentenceSize;
+    }
+
+    public void setSentenceSize(String sentenceSize) {
+        this.sentenceSize = sentenceSize;
+    }
+
+    public Integer getWordNum() {
+        return wordNum;
+    }
+
+    public void setWordNum(Integer wordNum) {
+        this.wordNum = wordNum;
+    }
+
+    public Integer getLength() {
+        return length;
+    }
+
+    public void setLength(Integer length) {
+        this.length = length;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public Integer getParseImage() {
+        return parseImage;
+    }
+
+    public void setParseImage(Integer parseImage) {
+        this.parseImage = parseImage;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("documentId", getDocumentId())
+            .append("knowledgeId", getKnowledgeId())
+            .append("customSeparator", getCustomSeparator())
+            .append("knowledgeType", getKnowledgeType())
+            .append("sentenceSize", getSentenceSize())
+            .append("wordNum", getWordNum())
+            .append("length", getLength())
+            .append("name", getName())
+            .append("url", getUrl())
+            .append("parseImage", getParseImage())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        TakaiDocument that = (TakaiDocument) o;
+
+        return documentId.equals(that.documentId);
+    }
+
+    @Override
+    public int hashCode() {
+        return  documentId.hashCode();
+    }
+}

+ 26 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiDocumentObject.java

@@ -0,0 +1,26 @@
+package com.takai.ai.domain.entity;
+
+import java.util.List;
+
+public class TakaiDocumentObject {
+
+    private List<TakaiDocumentParams> upload_detail;
+
+    private String knowledge_id;
+
+    public List<TakaiDocumentParams> getUpload_detail() {
+        return upload_detail;
+    }
+
+    public void setUpload_detail(List<TakaiDocumentParams> upload_detail) {
+        this.upload_detail = upload_detail;
+    }
+
+    public String getKnowledge_id() {
+        return knowledge_id;
+    }
+
+    public void setKnowledge_id(String knowledge_id) {
+        this.knowledge_id = knowledge_id;
+    }
+}

+ 138 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiDocumentParams.java

@@ -0,0 +1,138 @@
+package com.takai.ai.domain.entity;
+
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+public class TakaiDocumentParams {
+
+    private MultipartFile[] files;
+
+    private String name;
+
+    private int knowledge_type;
+
+    private List<String> custom_separator;
+
+    private int sentence_size;
+
+    private Boolean parse_image;
+
+    private String callback_url;
+
+    private Object callback_header;
+
+    private String word_num_limit;
+
+    private String req_id;
+
+    private String knowledge_id;
+
+    private int page;
+
+    private int size;
+
+    public MultipartFile[] getFiles() {
+        return files;
+    }
+
+    public void setFiles(MultipartFile[] files) {
+        this.files = files;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getKnowledge_type() {
+        return knowledge_type;
+    }
+
+    public void setKnowledge_type(int knowledge_type) {
+        this.knowledge_type = knowledge_type;
+    }
+
+    public List<String> getCustom_separator() {
+        return custom_separator;
+    }
+
+    public void setCustom_separator(List<String> custom_separator) {
+        this.custom_separator = custom_separator;
+    }
+
+    public int getSentence_size() {
+        return sentence_size;
+    }
+
+    public void setSentence_size(int sentence_size) {
+        this.sentence_size = sentence_size;
+    }
+
+    public Boolean isParse_image() {
+        return parse_image;
+    }
+
+    public void setParse_image(Boolean parse_image) {
+        this.parse_image = parse_image;
+    }
+
+    public String getCallback_url() {
+        return callback_url;
+    }
+
+    public void setCallback_url(String callback_url) {
+        this.callback_url = callback_url;
+    }
+
+    public Object getCallback_header() {
+        return callback_header;
+    }
+
+    public void setCallback_header(Object callback_header) {
+        this.callback_header = callback_header;
+    }
+
+    public String getWord_num_limit() {
+        return word_num_limit;
+    }
+
+    public void setWord_num_limit(String word_num_limit) {
+        this.word_num_limit = word_num_limit;
+    }
+
+    public String getReq_id() {
+        return req_id;
+    }
+
+    public void setReq_id(String req_id) {
+        this.req_id = req_id;
+    }
+
+    public String getKnowledge_id() {
+        return knowledge_id;
+    }
+
+    public void setKnowledge_id(String knowledge_id) {
+        this.knowledge_id = knowledge_id;
+    }
+
+    public int getPage() {
+        return page;
+    }
+
+    public void setPage(int page) {
+        this.page = page;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+}

+ 24 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiDocumentSettings.java

@@ -0,0 +1,24 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Builder;
+import lombok.Data;
+
+@Data
+public class TakaiDocumentSettings extends BaseEntity {
+
+    private String id;
+
+    private String knowledgeId;
+
+    private String documentId;
+
+    private String setSlice;
+
+    private String sliceValue;
+
+    private String setAnalyze;
+
+    private String hidInfo;
+
+}

+ 24 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiIndexType.java

@@ -0,0 +1,24 @@
+package com.takai.ai.domain.entity;
+
+public class TakaiIndexType {
+
+    private String knowledge_id;
+
+    private Integer index_type_id;
+
+    public String getKnowledge_id() {
+        return knowledge_id;
+    }
+
+    public void setKnowledge_id(String knowledge_id) {
+        this.knowledge_id = knowledge_id;
+    }
+
+    public Integer getIndex_type_id() {
+        return index_type_id;
+    }
+
+    public void setIndex_type_id(Integer index_type_id) {
+        this.index_type_id = index_type_id;
+    }
+}

+ 151 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiKnowledge.java

@@ -0,0 +1,151 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Builder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 智谱知识库列表 bm_knowledge
+ * 
+ * @author takai
+ */
+@Builder
+public class TakaiKnowledge extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+
+    /** 知识库ID */
+    private String knowledgeId;
+
+    /** 知识库绑定的向量化模型 */
+    private String embeddingId;
+
+    /** 知识库名称 */
+    private String name;
+
+    /** 知识库描述 */
+    private String description;
+
+    /** 背景颜色 */
+    private String background;
+
+    /** 知识库图标 */
+    private String icon;
+
+    /** 知识库总字数 */
+    private Integer wordNum;
+
+    /** 知识库总大小(字节) */
+    private Integer length;
+
+    /** 知识文件数量 */
+    private Integer documentSize;
+
+    public String getKnowledgeId() {
+        return knowledgeId;
+    }
+
+    public void setKnowledgeId(String knowledgeId) {
+        this.knowledgeId = knowledgeId;
+    }
+
+    public String getEmbeddingId() {
+        return embeddingId;
+    }
+
+    public void setEmbeddingId(String embeddingId) {
+        this.embeddingId = embeddingId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getBackground() {
+        return background;
+    }
+
+    public void setBackground(String background) {
+        this.background = background;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    public Integer getWordNum() {
+        return wordNum;
+    }
+
+    public void setWordNum(Integer wordNum) {
+        this.wordNum = wordNum;
+    }
+
+    public Integer getLength() {
+        return length;
+    }
+
+    public void setLength(Integer length) {
+        this.length = length;
+    }
+
+    public Integer getDocumentSize() {
+        return documentSize;
+    }
+
+    public void setDocumentSize(Integer documentSize) {
+        this.documentSize = documentSize;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("knowledgeId", getKnowledgeId())
+            .append("embeddingId", getEmbeddingId())
+            .append("name", getName())
+            .append("description", getDescription())
+            .append("background", getBackground())
+            .append("icon", getIcon())
+            .append("wordNum", getWordNum())
+            .append("length", getLength())
+            .append("documentSize", getDocumentSize())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        TakaiKnowledge that = (TakaiKnowledge) o;
+
+        return knowledgeId.equals(that.knowledgeId);
+    }
+
+    @Override
+    public int hashCode() {
+        return  knowledgeId.hashCode();
+    }
+}

+ 106 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiKnowledgeInfo.java

@@ -0,0 +1,106 @@
+package com.takai.ai.domain.entity;
+
+import java.util.List;
+
+public class TakaiKnowledgeInfo {
+
+    private String slice_config_type;
+
+    private String recall_method;
+
+    private Integer rerank_status;
+
+    private Integer slice_count;
+
+    private String rerank_model_name;
+
+    private Integer embedding_recall_ratio;
+
+    private Boolean show_recall_result;
+
+    private List<TakaiIndexType> rerank_index_type_list;
+
+    private List<TakaiIndexType> recall_index_type_list;
+
+    private String recall_slice_splicing_method;
+
+    public String getSlice_config_type() {
+        return slice_config_type;
+    }
+
+    public void setSlice_config_type(String slice_config_type) {
+        this.slice_config_type = slice_config_type;
+    }
+
+    public String getRecall_method() {
+        return recall_method;
+    }
+
+    public void setRecall_method(String recall_method) {
+        this.recall_method = recall_method;
+    }
+
+    public Integer getRerank_status() {
+        return rerank_status;
+    }
+
+    public void setRerank_status(Integer rerank_status) {
+        this.rerank_status = rerank_status;
+    }
+
+    public Integer getSlice_count() {
+        return slice_count;
+    }
+
+    public void setSlice_count(Integer slice_count) {
+        this.slice_count = slice_count;
+    }
+
+    public String getRerank_model_name() {
+        return rerank_model_name;
+    }
+
+    public void setRerank_model_name(String rerank_model_name) {
+        this.rerank_model_name = rerank_model_name;
+    }
+
+    public Integer getEmbedding_recall_ratio() {
+        return embedding_recall_ratio;
+    }
+
+    public void setEmbedding_recall_ratio(Integer embedding_recall_ratio) {
+        this.embedding_recall_ratio = embedding_recall_ratio;
+    }
+
+    public Boolean getShow_recall_result() {
+        return show_recall_result;
+    }
+
+    public void setShow_recall_result(Boolean show_recall_result) {
+        this.show_recall_result = show_recall_result;
+    }
+
+    public List<TakaiIndexType> getRerank_index_type_list() {
+        return rerank_index_type_list;
+    }
+
+    public void setRerank_index_type_list(List<TakaiIndexType> rerank_index_type_list) {
+        this.rerank_index_type_list = rerank_index_type_list;
+    }
+
+    public List<TakaiIndexType> getRecall_index_type_list() {
+        return recall_index_type_list;
+    }
+
+    public void setRecall_index_type_list(List<TakaiIndexType> recall_index_type_list) {
+        this.recall_index_type_list = recall_index_type_list;
+    }
+
+    public String getRecall_slice_splicing_method() {
+        return recall_slice_splicing_method;
+    }
+
+    public void setRecall_slice_splicing_method(String recall_slice_splicing_method) {
+        this.recall_slice_splicing_method = recall_slice_splicing_method;
+    }
+}

+ 71 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiKnowledgeParams.java

@@ -0,0 +1,71 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.enums.IconImg;
+
+public class TakaiKnowledgeParams {
+
+    private String knowledgeId;
+
+    /** 知识库绑定的向量化模型 */
+    private String embeddingId;
+
+    /** 知识库名称 */
+    private String name;
+
+    /** 知识库描述 */
+    private String description;
+
+    /** 背景颜色 */
+    private String background;
+
+    /** 知识库图标 */
+    private String icon = IconImg.QUESTION.getValue();
+
+    public String getKnowledgeId() {
+        return knowledgeId;
+    }
+
+    public void setKnowledgeId(String knowledgeId) {
+        this.knowledgeId = knowledgeId;
+    }
+
+    public String getEmbeddingId() {
+        return embeddingId;
+    }
+
+    public void setEmbeddingId(String embeddingId) {
+        this.embeddingId = embeddingId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getBackground() {
+        return background;
+    }
+
+    public void setBackground(String background) {
+        this.background = background;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+}

+ 116 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiMediaReplacement.java

@@ -0,0 +1,116 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Builder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 智谱媒体文件对照表 bm_media_replacement
+ * 
+ * @author takai
+ */
+@Builder
+public class TakaiMediaReplacement extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+
+    /** ID */
+    private Long id;
+
+    /** 应用ID */
+    private String documentId;
+
+    /** 原标签 */
+    private String originText;
+
+    /** 媒体类型 */
+    private String mediaType;
+
+    /** key值 */
+    private String mediaKey;
+
+    /** url */
+    private String mediaUrl;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getDocumentId() {
+        return documentId;
+    }
+
+    public void setDocumentId(String documentId) {
+        this.documentId = documentId;
+    }
+    public String getOriginText() {
+        return originText;
+    }
+
+
+    public void setOriginText(String originText) {
+        this.originText = originText;
+    }
+
+    public String getMediaType() {
+        return mediaType;
+    }
+
+    public void setMediaType(String mediaType) {
+        this.mediaType = mediaType;
+    }
+
+    public String getMediaKey() {
+        return mediaKey;
+    }
+
+    public void setMediaKey(String mediaKey) {
+        this.mediaKey = mediaKey;
+    }
+
+    public String getMediaUrl() {
+        return mediaUrl;
+    }
+
+    public void setMediaUrl(String mediaUrl) {
+        this.mediaUrl = mediaUrl;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("documentId", getDocumentId())
+            .append("originText", getOriginText())
+            .append("mediaType", getMediaType())
+            .append("mediaKey", getMediaKey())
+            .append("mediaUrl", getMediaUrl())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        TakaiMediaReplacement that = (TakaiMediaReplacement) o;
+
+        return id.longValue() == that.id.longValue();
+    }
+
+    @Override
+    public int hashCode() {
+        return  id.hashCode();
+    }
+}

+ 44 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiPageParams.java

@@ -0,0 +1,44 @@
+package com.takai.ai.domain.entity;
+
+public class TakaiPageParams {
+
+    private Integer pageNumber;
+
+    private Integer pageSize;
+
+    private String appId;
+
+    private String userId;
+
+    public Integer getPageNumber() {
+        return pageNumber;
+    }
+
+    public void setPageNumber(Integer pageNumber) {
+        this.pageNumber = pageNumber;
+    }
+
+    public Integer getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(Integer pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+}

+ 25 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiPromptInfo.java

@@ -0,0 +1,25 @@
+package com.takai.ai.domain.entity;
+
+public class TakaiPromptInfo {
+
+    private String role;
+
+    private String content;
+
+
+    public String getRole() {
+        return role;
+    }
+
+    public void setRole(String role) {
+        this.role = role;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+}

+ 25 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiPromptObject.java

@@ -0,0 +1,25 @@
+package com.takai.ai.domain.entity;
+
+public class TakaiPromptObject {
+
+    private String role;
+
+    private String content;
+
+
+    public String getRole() {
+        return role;
+    }
+
+    public void setRole(String role) {
+        this.role = role;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+}

+ 17 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiQuestion.java

@@ -0,0 +1,17 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Builder;
+
+@Builder
+public class TakaiQuestion extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String appId;
+
+    private String question;
+
+}

+ 44 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiQuestionInfo.java

@@ -0,0 +1,44 @@
+package com.takai.ai.domain.entity;
+
+public class TakaiQuestionInfo {
+
+    private String id;
+
+    private String appId;
+
+    private String question;
+
+    private String delFlag;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+
+    public String getQuestion() {
+        return question;
+    }
+
+    public void setQuestion(String question) {
+        this.question = question;
+    }
+
+    public String getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+}

+ 44 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiResultApplication.java

@@ -0,0 +1,44 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Data;
+
+@Data
+public class TakaiResultApplication extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+
+    /** 应用ID */
+    private String appId;
+
+    /** 应用名称 */
+    private String name;
+
+    /** 应用描述 */
+    private String desc;
+
+    /** 模版 */
+    private String prompt;
+
+    /** 采样温度的另一种方式 */
+    private String topP;
+
+    /** 采样温度 */
+    private String temperature;
+
+    /** 知识库id列表 */
+    private String knowledgeIds;
+
+    /** 分片数量 */
+    private Integer sliceCount;
+
+    /** model */
+    private String model;
+
+    /** icon_color */
+    private String iconColor;
+
+    /** icon_type */
+    private String iconType;
+}

+ 39 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiResultKnowledge.java

@@ -0,0 +1,39 @@
+package com.takai.ai.domain.entity;
+
+import com.takai.common.core.domain.BaseEntity;
+import lombok.Data;
+
+@Data
+public class TakaiResultKnowledge extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+
+    /** 知识库ID */
+    private String knowledgeId;
+
+    /** 知识库绑定的向量化模型 */
+    private Integer embeddingId;
+
+    /** 知识库名称 */
+    private String name;
+
+    /** 知识库描述 */
+    private String description;
+
+    /** 背景颜色 */
+    private String background;
+
+    /** 知识库图标 */
+    private String icon;
+
+    /** 知识库总字数 */
+    private Integer wordNum;
+
+    /** 知识库总大小(字节) */
+    private Integer length;
+
+    /** 知识文件数量 */
+    private Integer documentSize;
+
+}

+ 24 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiSearchObject.java

@@ -0,0 +1,24 @@
+package com.takai.ai.domain.entity;
+
+public class TakaiSearchObject {
+
+    private Boolean enable;
+
+    private Boolean search_result;
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public Boolean getSearch_result() {
+        return search_result;
+    }
+
+    public void setSearch_result(Boolean search_result) {
+        this.search_result = search_result;
+    }
+}

+ 17 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiSliceParams.java

@@ -0,0 +1,17 @@
+package com.takai.ai.domain.entity;
+
+import lombok.Data;
+
+@Data
+public class TakaiSliceParams {
+
+    private String document_id;
+
+    private String knowledge_id;
+
+    private String text;
+
+    private Integer pageNum;
+
+    private Integer pageSize;
+}

+ 14 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiSliceUpdateParams.java

@@ -0,0 +1,14 @@
+package com.takai.ai.domain.entity;
+
+import lombok.Data;
+
+@Data
+public class TakaiSliceUpdateParams {
+
+    private String knowledgeId;
+
+    private String sliceId;
+
+    private String sliceText;
+
+}

+ 118 - 0
takai-ai/src/main/java/com/takai/ai/domain/entity/TakaiSseInfoParams.java

@@ -0,0 +1,118 @@
+package com.takai.ai.domain.entity;
+
+
+
+import java.util.List;
+
+public class TakaiSseInfoParams {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 请求唯⼀id
+     */
+    private String request_id;
+
+    /**
+     * 是否增量返回
+     */
+    private Boolean incremental;
+
+    /**
+     * 1.调⽤对话模型时,将当前对话信息列表作为提⽰输⼊给模型;按照{"role": "user", "content": "
+     * 你好
+     * "}
+     * 的键值对形式进⾏传
+     * 参;总⻓度超过模型最⻓输⼊限制后会⾃动截断,需按时间由旧到新排
+     * 序
+     * 2. list必须是奇数个
+     */
+    private List<TakaiPromptInfo> prompt;
+
+    private String appId;
+    /**
+     * ⽤于控制每次返回内容的类型,空或者没有此字段时默认按照json_string
+     * 返回
+     * json_string
+     * 返回标准的JSON字符串
+     * text
+     * 返回原始的⽂本内容
+     */
+    private String returnType;
+
+    /**
+     * 知识库id列表:不传,则使⽤应⽤关联的所有知识库
+     */
+    private String knowledge_ids;
+
+    /**
+     * 知识id列表:不传,则使⽤应⽤关联的所有知识库
+     */
+    private List<Long> document_ids;
+
+    private String model;
+
+    public String getRequest_id() {
+        return request_id;
+    }
+
+    public void setRequest_id(String request_id) {
+        this.request_id = request_id;
+    }
+
+    public Boolean getIncremental() {
+        return incremental;
+    }
+
+    public void setIncremental(Boolean incremental) {
+        this.incremental = incremental;
+    }
+
+    public List<TakaiPromptInfo> getPrompt() {
+        return prompt;
+    }
+
+    public void setPrompt(List<TakaiPromptInfo> prompt) {
+        this.prompt = prompt;
+    }
+
+    public String getReturnType() {
+        return returnType;
+    }
+
+    public void setReturnType(String returnType) {
+        this.returnType = returnType;
+    }
+
+    public String getKnowledge_ids() {
+        return knowledge_ids;
+    }
+
+    public void setKnowledge_ids(String knowledge_ids) {
+        this.knowledge_ids = knowledge_ids;
+    }
+
+    public List<Long> getDocument_ids() {
+        return document_ids;
+    }
+
+    public void setDocument_ids(List<Long> document_ids) {
+        this.document_ids = document_ids;
+    }
+
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    public String getAppId() {
+        return appId;
+    }
+
+    public void setAppId(String appId) {
+        this.appId = appId;
+    }
+}

+ 16 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiAppInfoMapper.java

@@ -0,0 +1,16 @@
+package com.takai.ai.mapper;
+
+import com.takai.ai.domain.entity.TakaiAppInfo;
+
+public interface TakaiAppInfoMapper {
+
+    int insertAppInfo (TakaiAppInfo info);
+
+    TakaiAppInfo selectAppInfoByAppId(String appId);
+
+    int delAppInfoByAppId(String appId);
+
+	int updateAppInfoByAppId(TakaiAppInfo info);
+
+
+}

+ 52 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiApplicationMapper.java

@@ -0,0 +1,52 @@
+package com.takai.ai.mapper;
+
+
+import com.takai.ai.domain.entity.TakaiApplication;
+
+import java.util.List;
+
+/**
+ * 高井 应用列表
+ * 
+ * @author takai
+ */
+public interface TakaiApplicationMapper
+{
+    /**
+     * 根据条件分页查询应用信息
+     * 
+     * @param mData 应用信息
+     * @return 应用信息
+     */
+    public List<TakaiApplication> selectApplicationList(TakaiApplication mData);
+
+
+    /**
+     * 查询唯一应用信息
+     * @param mData
+     * @return
+     */
+    public TakaiApplication selectTargetApplication(TakaiApplication mData);
+
+
+    /**
+     * 新增应用信息
+     * 
+     * @param mData 应用信息
+     * @return 结果
+     */
+    public int insertApplication(TakaiApplication mData);
+
+    /**
+     * 更新应用信息
+     *
+     * @param mData 应用信息
+     * @return 结果
+     */
+    public int updateApplication(TakaiApplication mData);
+
+    int delApplication(String appId);
+
+
+
+}

+ 22 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiDialogMapper.java

@@ -0,0 +1,22 @@
+package com.takai.ai.mapper;
+
+import com.takai.ai.domain.dto.TakaiDialogRespDTO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 高井 对话消息头表信息
+ * 
+ * @author takai
+ */
+public interface TakaiDialogMapper
+{
+
+    List<TakaiDialogRespDTO> selectDialogDetail(String dialogId);
+
+    List<TakaiDialogRespDTO> selectDialog(@Param("appId") String appId, @Param("userId") String userId);
+
+    List<TakaiDialogRespDTO> selectDialogExport(String appId);
+
+}

+ 50 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiDocumentMapper.java

@@ -0,0 +1,50 @@
+package com.takai.ai.mapper;
+
+
+import com.takai.ai.domain.entity.TakaiDocument;
+
+import java.util.List;
+
+/**
+ * 高井 知识列表
+ * 
+ * @author takai
+ */
+public interface TakaiDocumentMapper
+{
+    /**
+     * 根据条件分页查询知识信息
+     * 
+     * @param mData 知识信息
+     * @return 知识信息
+     */
+    public List<TakaiDocument> selectDocumentList(TakaiDocument mData);
+
+
+    /**
+     * 查询唯一知识信息
+     * @param mData
+     * @return
+     */
+    public TakaiDocument selectTargetDocument(TakaiDocument mData);
+
+
+    /**
+     * 新增知识信息
+     * 
+     * @param mData 知识信息
+     * @return 结果
+     */
+    public int insertDocument(TakaiDocument mData);
+
+    /**
+     * 更新知识信息
+     *
+     * @param mData 知识信息
+     * @return 结果
+     */
+    public int updateDocument(TakaiDocument mData);
+
+    int delDocument(String documentId);
+
+}

+ 15 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiDocumentSettingsMapper.java

@@ -0,0 +1,15 @@
+package com.takai.ai.mapper;
+
+import com.takai.ai.domain.entity.TakaiDocumentSettings;
+
+public interface TakaiDocumentSettingsMapper {
+
+    TakaiDocumentSettings selectById(String id);
+
+    int insertDocumentSettings(TakaiDocumentSettings mData);
+
+    int updateDocumentSettings(TakaiDocumentSettings mData);
+
+    int deleteDocumentSettings(String id);
+
+}

+ 49 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiKnowledgeMapper.java

@@ -0,0 +1,49 @@
+package com.takai.ai.mapper;
+
+import com.takai.ai.domain.entity.TakaiKnowledge;
+
+import java.util.List;
+
+/**
+ * 高井 知识库列表
+ * 
+ * @author takai
+ */
+public interface TakaiKnowledgeMapper
+{
+    /**
+     * 根据条件分页查询知识库信息
+     * 
+     * @param mData 知识库信息
+     * @return 知识库信息
+     */
+    public List<TakaiKnowledge> selectKnowledgeList(TakaiKnowledge mData);
+
+
+    /**
+     * 查询唯一知识库信息
+     * @param mData
+     * @return
+     */
+    public TakaiKnowledge selectTargetKnowledge(TakaiKnowledge mData);
+
+
+    /**
+     * 新增知识库信息
+     * 
+     * @param mData 知识库信息
+     * @return 结果
+     */
+    public int insertKnowledge(TakaiKnowledge mData);
+
+    /**
+     * 更新知识库信息
+     *
+     * @param mData 知识库信息
+     * @return 结果
+     */
+    public int updateKnowledge(TakaiKnowledge mData);
+
+    int delKnowledge(String knowledgeId);
+
+}

+ 48 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiMediaReplacementMapper.java

@@ -0,0 +1,48 @@
+package com.takai.ai.mapper;
+
+
+import com.takai.ai.domain.entity.TakaiMediaReplacement;
+
+import java.util.List;
+
+/**
+ * 高井多媒体文件
+ * 
+ * @author takai
+ */
+public interface TakaiMediaReplacementMapper
+{
+    /**
+     * 根据条件分页查询媒体对照信息
+     * 
+     * @param mData 媒体对照信息
+     * @return 媒体对照信息数据集合信息
+     */
+    public List<TakaiMediaReplacement> selectMediaList(TakaiMediaReplacement mData);
+
+
+    /**
+     * 查询唯一媒体对照信息
+     * @param mData
+     * @return
+     */
+    public TakaiMediaReplacement selectTargetMedia(TakaiMediaReplacement mData);
+
+
+    /**
+     * 新增媒体对照信息
+     * 
+     * @param mData 媒体对照信息
+     * @return 结果
+     */
+    public int insertMedia(TakaiMediaReplacement mData);
+
+    /**
+     * 更新媒体对照信息
+     *
+     * @param mData 媒体对照信息
+     * @return 结果
+     */
+    public int updateMedia(TakaiMediaReplacement mData);
+
+}

+ 24 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiQuestionMapper.java

@@ -0,0 +1,24 @@
+package com.takai.ai.mapper;
+
+
+import com.takai.ai.domain.dto.TakaiQuestionDTO;
+import com.takai.ai.domain.entity.TakaiQuestion;
+
+import java.util.List;
+
+public interface TakaiQuestionMapper {
+
+    List<TakaiQuestionDTO> getQuestionList(String appId);
+
+    int insertQuestion(TakaiQuestion vo);
+
+    int updateQuestion(TakaiQuestion vo);
+
+    int delQuestion(String id);
+
+    TakaiQuestion selectQuestionById(String id);
+
+    int delQuestionByAppId(String appId);
+
+
+}

+ 9 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiSysOssConfigMapper.java

@@ -0,0 +1,9 @@
+package com.takai.ai.mapper;
+
+import com.takai.ai.domain.TakaiSysOssConfig;
+
+public interface TakaiSysOssConfigMapper {
+
+    TakaiSysOssConfig selectByOssConfigId(String ossConfigId);
+
+}

+ 9 - 0
takai-ai/src/main/java/com/takai/ai/mapper/TakaiSysOssMapper.java

@@ -0,0 +1,9 @@
+package com.takai.ai.mapper;
+
+import com.takai.ai.domain.TakaiSysOss;
+
+public interface TakaiSysOssMapper {
+
+    int insertSysOss(TakaiSysOss record);
+
+}

+ 10 - 0
takai-ai/src/main/java/com/takai/ai/service/IMinioConfigService.java

@@ -0,0 +1,10 @@
+package com.takai.ai.service;
+
+import com.takai.ai.domain.TakaiSysOssConfig;
+
+public interface IMinioConfigService {
+
+    TakaiSysOssConfig getCurrentConfig();
+    void refreshConfig();
+
+}

+ 86 - 0
takai-ai/src/main/java/com/takai/ai/service/ITakaiAiService.java

@@ -0,0 +1,86 @@
+package com.takai.ai.service;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.takai.ai.domain.dto.TakaiDialogReqDTO;
+import com.takai.ai.domain.dto.TakaiDialogRespDTO;
+import com.takai.ai.domain.dto.TakaiQuestionDTO;
+import com.takai.ai.domain.entity.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 高井 业务层
+ * 
+ * @author takai
+ */
+public interface ITakaiAiService
+{
+
+    SseEmitter sseInvoke(TakaiSseInfoParams sseParams);
+
+    List<String> asyncCompletions(TakaiCompletionsParams params);
+
+    List<TakaiDialogRespDTO> getDialogDetail(String dialogId);
+
+    void saveDialog(TakaiDialogReqDTO dialogReqDTO);
+
+    List<Object> getDialogList(String appId);
+
+    void DelDialogDetail(String id);
+
+    void updateDialog(TakaiDialogReqDTO dialogReqDTO);
+
+    List<TakaiDialogRespDTO> exportExcel(String dialogId);
+
+    int createKnowledge(TakaiKnowledgeParams knowledge);
+
+    int updateKnowledge(TakaiKnowledgeParams knowledge, String knowledgeId);
+
+    TakaiKnowledge detailKnowledge(String knowledgeId);
+
+    int delKnowledge(String knowledgeId);
+
+    int uploadDocument(MultipartFile files, String knowledgeId) throws Exception;
+
+    int updateDocument(TakaiDocumentParams documentParams, String documentId);
+
+    List<TakaiDocument> documentList(TakaiDocumentParams documentParams);
+
+    TakaiDocument documentDetail(String documentId);
+
+    int delDocument(String documentId);
+
+    void uploadUrl(TakaiDocumentObject object);
+
+    int createApplication(TakaiApplicationParams params);
+
+    int updateApplication(TakaiApplicationParams params, String appId);
+
+    List<TakaiApplication> getApplicationList();
+
+    JSONObject selectApplication(String appId);
+
+    int delApplication(String appId);
+
+    List<TakaiQuestionDTO> selectQuestionByAppId(String appId);
+
+    List<TakaiKnowledge> queryKnowledgeList();
+
+    List<Object> selectDialogListByAppId(String appId, String userId);
+
+    TakaiDocumentSettings documentSetting(String dialogId);
+
+    int updateDocumentSetting(TakaiDocumentSettings documentSettings, String documentId);
+
+    JSONObject getSliceList(TakaiSliceParams params);
+
+    int deleteSlice(String sliceId, String knowledgeId);
+
+    JSONObject getSliceDetail(String sliceId, String knowledgeId);
+
+    int updateSliceInfo(TakaiSliceUpdateParams params);
+
+}

+ 39 - 0
takai-ai/src/main/java/com/takai/ai/service/impl/MinioConfigServiceImpl.java

@@ -0,0 +1,39 @@
+package com.takai.ai.service.impl;
+
+import com.takai.ai.domain.TakaiSysOssConfig;
+import com.takai.ai.mapper.TakaiSysOssConfigMapper;
+import com.takai.ai.service.IMinioConfigService;
+import com.takai.common.annotation.DataSource;
+import com.takai.common.enums.DataSourceType;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+
+@Service
+@DataSource(DataSourceType.MASTER)
+public class MinioConfigServiceImpl implements IMinioConfigService {
+
+    @Autowired
+    private TakaiSysOssConfigMapper takaiSysOssConfigMapper;
+
+    private TakaiSysOssConfig currentConfig;
+
+    @PostConstruct
+    public void init() {
+        refreshConfig();
+    }
+
+    @Override
+    public TakaiSysOssConfig getCurrentConfig() {
+        return currentConfig;
+    }
+
+    @Override
+    public void refreshConfig() {
+        this.currentConfig = takaiSysOssConfigMapper.selectByOssConfigId("1");
+        if (this.currentConfig == null) {
+            throw new IllegalStateException("未找到可用的MinIO配置");
+        }
+    }
+}

+ 810 - 0
takai-ai/src/main/java/com/takai/ai/service/impl/TakaiAiServiceImpl.java

@@ -0,0 +1,810 @@
+package com.takai.ai.service.impl;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.takai.ai.domain.TakaiSysOss;
+import com.takai.ai.domain.entity.*;
+import com.takai.ai.mapper.*;
+import com.takai.ai.service.ITakaiAiService;
+import com.takai.ai.utils.MinioUtil;
+import com.takai.ai.utils.SnowflakeDigitGenerator;
+import com.takai.common.annotation.DataSource;
+import com.takai.common.config.DeepseekConfig;
+import com.takai.common.enums.DataSourceType;
+import com.takai.ai.domain.dto.TakaiDialogReqDTO;
+import com.takai.ai.domain.dto.TakaiDialogRespDTO;
+import com.takai.ai.domain.dto.TakaiQuestionDTO;
+import com.takai.common.utils.StringUtils;
+import com.takai.common.utils.uuid.IdUtils;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import okhttp3.sse.EventSource;
+import okhttp3.sse.EventSourceListener;
+import okhttp3.sse.EventSources;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
+
+import javax.validation.constraints.NotNull;
+import java.io.File;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+/**
+ * 高井 业务层处理
+ *
+ * @author takai
+ */
+@Slf4j
+@Service
+@DataSource(DataSourceType.MASTER)
+public class TakaiAiServiceImpl implements ITakaiAiService {
+    private static final Logger logger = LoggerFactory.getLogger(TakaiAiServiceImpl.class);
+    @Autowired
+    private TakaiDialogMapper takaiDialogMapper;
+
+    @Autowired
+    private TakaiApplicationMapper takaiApplicationMapper;
+
+    @Autowired
+    private TakaiQuestionMapper takaiQuestionMapper;
+
+    @Autowired
+    private TakaiKnowledgeMapper takaiKnowledgeMapper;
+
+    @Autowired
+    private TakaiDocumentMapper takaiDocumentMapper;
+
+    @Autowired
+    private TakaiSysOssConfigMapper takaiSysOssConfigMapper;
+
+    @Autowired
+    private TakaiSysOssMapper takaiSysOssMapper;
+
+    @Autowired
+    private MinioUtil minioUtil;
+
+    @Autowired
+    private TakaiDocumentSettingsMapper takaiDocumentSettingsMapper;
+
+    @Autowired
+    private DeepseekConfig deepseekConfig;
+
+    @Autowired
+    private TakaiAppInfoMapper takaiAppInfoMapper;
+
+    @Autowired
+    private TakaiMediaReplacementMapper takaiMediaReplacementMapper;
+
+    public static final String START_SIGN = "【";
+    public static final String END_SIGN = "】";
+    public static final String SYMBOL = "【示意图序号";
+
+    @Override
+    public SseEmitter sseInvoke(TakaiSseInfoParams sseParams) {
+        SseEmitter sseEmitter = new SseEmitter(0L);
+        String url = deepseekConfig.getBaseurl() + deepseekConfig.getChat();
+        TakaiAppInfo info = takaiAppInfoMapper.selectAppInfoByAppId(sseParams.getAppId());
+        JSONObject json = JSONObject.parseObject(info.getAppInfo());
+        json.put("query", "在上海建科集团业务管理平台中,登记和退款流程是什么样的。");
+        json.put("embeddingId", "multilingual-e5-large-instruct");
+
+        RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), json.toJSONString());
+        Request request = buildPostRequest(url, requestBody);
+        // 使用EventSourceListener处理来自服务器的SSE事件
+        EventSourceListener listener = new EventSourceListener() {
+            private String preData = "";
+            //图片识别
+            private String symbolData = "";
+
+            @Override
+            public void onOpen(@NotNull EventSource eventSource, @NotNull Response response) {
+                log.info("deepseek Connection opened. Headers: {}", response.headers());
+                log.info("deepseek Request URL: {}", response.request().url());
+            }
+            @Override
+            public void onClosed(@NotNull EventSource eventSource) {
+                log.info("deepseek Connection closed.");
+                sseEmitter.complete();
+            }
+
+            @Override
+            public void onEvent(@NotNull EventSource eventSource, String id, String type, @NotNull String data) {
+                if(StringUtils.isEmpty(data)){
+                    return;
+                }
+                String newData = data.substring(preData.length());
+                preData = data;
+                if (newData.indexOf(START_SIGN) > -1 || symbolData.length() > 0) {
+                    symbolData = symbolData + newData;
+                    //接收到了完整的图片标识
+                    if (newData.indexOf(END_SIGN) > -1) {
+                        //是图片
+                        if (symbolData.indexOf(SYMBOL) > -1) {
+                            String documentId = symbolData.substring(SYMBOL.length() + 1, symbolData.lastIndexOf("_"));
+                            TakaiMediaReplacement mrParams = TakaiMediaReplacement.builder()
+                                    .documentId(documentId)
+                                    .originText(symbolData)
+                                    .mediaType("image").build();
+                            TakaiMediaReplacement mrVo = takaiMediaReplacementMapper.selectTargetMedia(mrParams);
+                            symbolData = mrVo.getMediaUrl();
+                        }
+                        JSONObject json = new JSONObject();
+                        json.put("id", id);
+                        json.put("event", "add");
+                        json.put("data", symbolData);
+                        log.info("deepseek返回信息:" + json);
+                        symbolData = "";
+                        send(sseEmitter, json);
+                    }
+                } else {
+//                        if(com.takai.common.utils.StringUtils.isNotEmpty(type) && "finish".equals(type)){
+//                            if(com.takai.common.utils.StringUtils.isNotEmpty(data)){
+//                                JSONObject json = new JSONObject();
+//                                json.put("id", id);
+//                                json.put("event", "add");
+//                                json.put("data", data);
+//                                log.info("deepseek返回切片消息:" + data);
+//                                send(sseEmitter, json);
+//                            }
+//                        }
+                    JSONObject json = new JSONObject();
+                    json.put("id", id);
+                    json.put("event", type);
+                    json.put("data", newData);
+                    log.info("deepseek返回信息:" + json);
+                    send(sseEmitter, json);
+                }
+            }
+
+            @Override
+            public void onFailure(@NotNull EventSource eventSource, Throwable t, Response response) {
+                if (response != null) {
+                    log.error("deepseek Connection failed. Response code: {}, message: {}, body: {}",
+                            response.code(), response.message(), response.body() != null ? response.body().toString() : "null");
+                } else {
+                    log.error("deepseek Connection failed with no response", t);
+                }
+                sseEmitter.completeWithError(t);
+            }
+
+            private void send(SseEmitter sseEmitter, Object obj) {
+                try {
+                    sseEmitter.send(obj);
+                } catch (IOException e) {
+                    log.error("deepseek 推送数据失败", e);
+                }
+            }
+        };
+        OkHttpClient client = buildOkHttpClient();
+        EventSource.Factory factory = EventSources.createFactory(client);
+        factory.newEventSource(request, listener);
+        return sseEmitter;
+    }
+
+    @Override
+    public List<String> asyncCompletions(TakaiCompletionsParams params) {
+        List<String> list = new ArrayList<>();
+        TakaiApplication vo = takaiApplicationMapper.selectTargetApplication(TakaiApplication.builder().appId(params.getAppId()).build());
+        TakaiPromptInfo info = new TakaiPromptInfo();
+        info.setContent(deepseekConfig.getPrompt());
+        info.setRole("user");
+        params.getMessages().add(info);
+
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("model", "DeepSeek-R1-Distill-Qwen-14B");
+        jsonObject.put("messages", params.getMessages());
+        JSONObject result = getasyncCompletions(jsonObject);
+        if(result != null && result.getInteger("code") == 200){
+            JSONArray array = result.getJSONArray("data");
+            list.addAll(array.toJavaList(String.class));
+        }
+        return list;
+    }
+
+    private JSONObject getasyncCompletions(JSONObject jsonObject){
+        String url = deepseekConfig.getBaseurl() + deepseekConfig.getAsyncCompletions();
+        RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), jsonObject.toJSONString());
+        Request request = buildPostRequest(url, requestBody);
+        OkHttpClient client = buildOkHttpClient();
+        try {
+            Response response = client.newCall(request).execute();
+            if (response.isSuccessful()) {
+                String body = response.body().string();
+                if(isJsonObject(body)){
+                    return JSON.parseObject(body);
+                }
+            }
+        }catch (IOException e) {
+            log.info("deepseek Request URL: {}", e.getMessage());
+        }
+        return null;
+    }
+
+    @Override
+    public List<TakaiDialogRespDTO> getDialogDetail(String dialogId) {
+        List<TakaiDialogRespDTO> detail = takaiDialogMapper.selectDialogDetail(dialogId);
+        return detail;
+    }
+
+    @Override
+    public void saveDialog(TakaiDialogReqDTO dialogReqDTO) {
+
+    }
+
+    @Override
+    public List<Object> getDialogList(String appId) {
+        return null;
+    }
+
+    @Override
+    public void DelDialogDetail(String id) {
+
+    }
+
+    @Override
+    public void updateDialog(TakaiDialogReqDTO dialogReqDTO) {
+
+    }
+
+    @Override
+    public List<TakaiDialogRespDTO> exportExcel(String dialogId) {
+        return takaiDialogMapper.selectDialogExport(dialogId);
+    }
+
+    @Override
+    public int createKnowledge(TakaiKnowledgeParams knowledge) {
+        SnowflakeDigitGenerator snowflakeDigitGenerator = new SnowflakeDigitGenerator(1, 1);
+        long knowledgeId = snowflakeDigitGenerator.nextId();
+
+        String url = deepseekConfig.getBaseurl() + deepseekConfig.getCreateKnowledge();
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("knowledge_id", "a" + knowledgeId);
+        jsonObject.put("embedding_id", knowledge.getEmbeddingId());
+
+        RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), jsonObject.toJSONString());
+        Request request = buildPostRequest(url, requestBody);
+        OkHttpClient client = buildOkHttpClient();
+        try {
+            Response response = client.newCall(request).execute();
+            if (response.isSuccessful()) {
+                String body = response.body().string();
+                JSONObject obj = JSON.parseObject(body);
+                Integer code = obj.getInteger("code");
+                if (code == 200) {
+                    TakaiKnowledge params = TakaiKnowledge.builder()
+                            .knowledgeId("a" + knowledgeId)
+                            .name(knowledge.getName())
+                            .embeddingId(knowledge.getEmbeddingId())
+                            .description(knowledge.getDescription())
+                            .build();
+                    int i = takaiKnowledgeMapper.insertKnowledge(params);
+                }
+            } else {
+                logger.error("创建知识库调用python接口失败,返回状态码:{}", response.code());
+            }
+        } catch (IOException e) {
+            logger.error("创建知识库调用python接口失败", e.getMessage());
+        }
+        return 0;
+    }
+
+    @Override
+    public int updateKnowledge(TakaiKnowledgeParams knowledge, String knowledgeId) {
+        TakaiKnowledge params = TakaiKnowledge.builder().knowledgeId(knowledgeId)
+                .name(knowledge.getName())
+                .description(knowledge.getDescription())
+                .embeddingId(knowledge.getEmbeddingId())
+                .build();
+        return takaiKnowledgeMapper.updateKnowledge(params);
+    }
+
+    @Override
+    public TakaiKnowledge detailKnowledge(String knowledgeId) {
+        TakaiKnowledge vo = TakaiKnowledge.builder().knowledgeId(knowledgeId).build();
+        return takaiKnowledgeMapper.selectTargetKnowledge(vo);
+    }
+
+    @Override
+    public int delKnowledge(String knowledgeId) {
+        String url = deepseekConfig.getBaseurl() + deepseekConfig.getDeleteKnowledge() + "/" + knowledgeId;
+        Request request = buildDeleteRequest(url);
+        OkHttpClient client = buildOkHttpClient();
+        Response response = null;
+        try {
+            response = client.newCall(request).execute();
+            if (response.isSuccessful()) {
+                String body = response.body().string();
+                JSONObject obj = JSON.parseObject(body);
+                Integer code = obj.getInteger("code");
+                if (code == 200) {
+//                    TakaiKnowledge info = takaiKnowledgeMapper.selectTargetKnowledge(TakaiKnowledge.builder().knowledgeId(knowledgeId).build());
+                    int i = takaiKnowledgeMapper.delKnowledge(knowledgeId);
+                }
+            }
+        } catch (IOException e) {
+            logger.error("删除知识库调用python接口失败", e.getMessage());
+        }
+        return 0;
+    }
+
+    @Override
+    public int uploadDocument(MultipartFile files, String knowledgeId) {
+        TakaiSysOss result = null;
+        try {
+            result = minioUtil.uploadMultiple(files);
+        } catch (Exception e) {
+            logger.error("上传文件失败", e.getMessage());
+        }
+        if (result != null) {
+            SnowflakeDigitGenerator documentIdGenerator = new SnowflakeDigitGenerator(1, 1);
+            long documentId = documentIdGenerator.nextId();
+
+            TakaiDocumentSettings settings = new TakaiDocumentSettings();
+            settings.setDocumentId("a" + documentId);
+            settings.setKnowledgeId(knowledgeId);
+            boolean flag = analysisFile(result, settings, "upload");
+
+            if (flag) {
+                // 保存知识信息
+                TakaiDocument document = TakaiDocument.builder()
+                        .documentId("a" + documentId)
+                        .knowledgeId(knowledgeId)
+                        .customSeparator(String.format("[\"%s\"", "\\n") + "]")
+                        .sentenceSize("300")
+                        .name(result.getOriginalName())
+                        .url(result.getUrl()).build();
+                int documentIdInsert = takaiDocumentMapper.insertDocument(document);
+                int ossInsert = 0;
+                int settingInsert = 0;
+                if (documentIdInsert > 0) {
+                    // oss保存到数据库
+                    ossInsert = takaiSysOssMapper.insertSysOss(result);
+                    if (ossInsert > 0) {
+                        // 保存知识设置信息
+                        SnowflakeDigitGenerator snowflakeDigitGenerator = new SnowflakeDigitGenerator(1, 1);
+                        long id = snowflakeDigitGenerator.nextId();
+                        TakaiDocumentSettings dSettings = new TakaiDocumentSettings();
+                        dSettings.setId(String.valueOf(id));
+                        dSettings.setKnowledgeId(knowledgeId);
+                        dSettings.setDocumentId("a" + documentId);
+                        dSettings.setSetSlice("0");   // 默认 按标题段落切片
+                        dSettings.setSetAnalyze("1"); // 默认 图片转换成标识符
+                        settingInsert = takaiDocumentSettingsMapper.insertDocumentSettings(dSettings);
+                    }
+                }
+                if (documentIdInsert > 0 && ossInsert > 0 && settingInsert > 0) {
+                    return 1;
+                }
+            }
+        }
+        return 0;
+    }
+
+
+    @Override
+    public int updateDocument(TakaiDocumentParams documentParams, String documentId) {
+        int i = takaiDocumentMapper.updateDocument(TakaiDocument.builder()
+                .documentId(documentId)
+                .name(documentParams.getName())
+                .build());
+        return i;
+    }
+
+    @Override
+    public List<TakaiDocument> documentList(TakaiDocumentParams documentParams) {
+        return takaiDocumentMapper.selectDocumentList(TakaiDocument.builder().knowledgeId(documentParams.getKnowledge_id()).build());
+    }
+
+    @Override
+    public TakaiDocument documentDetail(String documentId) {
+        return takaiDocumentMapper.selectTargetDocument(TakaiDocument.builder().documentId(documentId).build());
+    }
+
+    @Override
+    public int delDocument(String documentId) {
+        return takaiDocumentMapper.delDocument(documentId);
+    }
+
+    @Override
+    public void uploadUrl(TakaiDocumentObject object) {
+
+    }
+
+    @Override
+    public int createApplication(TakaiApplicationParams params) {
+        SnowflakeDigitGenerator snowflakeDigitGenerator = new SnowflakeDigitGenerator(1, 1);
+        long appId = snowflakeDigitGenerator.nextId();
+        TakaiApplication info = TakaiApplication.builder().appId(String.valueOf(appId))
+                .name(params.getName())
+                .desc(params.getDesc())
+                .model(params.getModel())
+                .knowledgeIds(params.getKnowledge_ids().toString())
+                .topP(params.getTop_p())
+                .temperature(params.getTemperature())
+                .maxToken(params.getMax_token())
+                .prompt(params.getPrompt())
+                .knowledgeInfo(params.getKnowledge_info())
+                .sliceCount(params.getSlice_count())
+                .build();
+        int i = takaiApplicationMapper.insertApplication(info);
+        if (i > 0) {
+            logger.info("create application success, id:{}, name:{}", appId, params.getName());
+            TakaiAppInfo appInfo = new TakaiAppInfo();
+            appInfo.setAppId(String.valueOf(appId));
+            appInfo.setAppInfo(String.valueOf(JSONObject.from(info).toJSONString()));
+            takaiAppInfoMapper.insertAppInfo(appInfo);
+
+            List<String> list = params.getQuestionList();
+            if (!list.isEmpty() && list.size() > 0) {
+                for (String str : list) {
+                    if (org.apache.commons.lang3.StringUtils.isNotBlank(str)) {
+                        String uuid = IdUtils.simpleUUID();
+                        TakaiQuestion question = TakaiQuestion.builder().id(uuid).question(str).appId(String.valueOf(appId)).build();
+                        takaiQuestionMapper.insertQuestion(question);
+                    }
+                }
+            }
+        }
+        return i;
+    }
+
+    @Override
+    public int updateApplication(TakaiApplicationParams params, String appId) {
+        TakaiApplication info = TakaiApplication.builder().appId(appId)
+                .name(params.getName())
+                .desc(params.getDesc())
+                .model(params.getModel())
+                .knowledgeIds(params.getKnowledge_ids().toString())
+                .topP(params.getTop_p())
+                .temperature(params.getTemperature())
+                .maxToken(params.getMax_token())
+                .prompt(params.getPrompt())
+                .knowledgeInfo(params.getKnowledge_info())
+                .sliceCount(params.getSlice_count())
+                .build();
+        int i = takaiApplicationMapper.updateApplication(info);
+        if (1 > 0) {
+            TakaiAppInfo appInfo = new TakaiAppInfo();
+            appInfo.setAppId(appId);
+            appInfo.setAppInfo(String.valueOf(JSONObject.from(info).toJSONString()));
+            takaiAppInfoMapper.updateAppInfoByAppId(appInfo);
+            logger.info("update application success, id:{}, name:{}", appId, params.getName());
+            //预设问题写入数据库
+            takaiQuestionMapper.delQuestionByAppId(appId);
+            List<String> list = params.getQuestionList();
+            if (!list.isEmpty() && list.size() > 0) {
+                for (String str : list) {
+                    if (org.apache.commons.lang3.StringUtils.isNotBlank(str)) {
+                        String uuid = IdUtils.simpleUUID();
+                        TakaiQuestion question = TakaiQuestion.builder().id(uuid).question(str).appId(String.valueOf(appId)).build();
+                        takaiQuestionMapper.insertQuestion(question);
+                    }
+                }
+            }
+        }
+        return i;
+    }
+
+    @Override
+    public List<TakaiApplication> getApplicationList() {
+        return takaiApplicationMapper.selectApplicationList(null);
+    }
+
+    @Override
+    public JSONObject selectApplication(String appId) {
+        JSONObject object = new JSONObject();
+        TakaiApplication application = TakaiApplication.builder().appId(appId).build();
+        TakaiApplication takaiApplication = takaiApplicationMapper.selectTargetApplication(application);
+        List<TakaiQuestionDTO> list = takaiQuestionMapper.getQuestionList(appId);
+        object.put("detail", takaiApplication);
+        object.put("questionlist", list);
+        return object;
+    }
+
+    @Override
+    public int delApplication(String appId) {
+        int i = takaiApplicationMapper.delApplication(appId);
+        if (i > 0) {
+            takaiAppInfoMapper.delAppInfoByAppId(appId);
+            takaiQuestionMapper.delQuestionByAppId(appId);
+        }
+        return i;
+    }
+
+    @Override
+    public List<TakaiQuestionDTO> selectQuestionByAppId(String appId) {
+        return null;
+    }
+
+    @Override
+    public List<TakaiKnowledge> queryKnowledgeList() {
+        return takaiKnowledgeMapper.selectKnowledgeList(null);
+    }
+
+    @Override
+    public List<Object> selectDialogListByAppId(String appId, String userId) {
+        List<TakaiDialogRespDTO> list = takaiDialogMapper.selectDialog(appId, userId);
+        List<Object> result = setDialogList(list);
+        return result;
+    }
+
+    @Override
+    public TakaiDocumentSettings documentSetting(String documentId) {
+        return takaiDocumentSettingsMapper.selectById(documentId);
+    }
+
+    @Override
+    public int updateDocumentSetting(TakaiDocumentSettings documentSettings, String documentId) {
+        if (StringUtils.isNotEmpty(documentSettings.getSetSlice()) && !"3".equals(documentSettings.getSetSlice())) {
+            documentSettings.setDocumentId(documentId);
+            int i = takaiDocumentSettingsMapper.updateDocumentSettings(documentSettings);
+            return i;
+        }
+        TakaiSysOss ossVo = new TakaiSysOss();
+        TakaiDocumentSettings settings = new TakaiDocumentSettings();
+        TakaiDocumentSettings settingsVo = takaiDocumentSettingsMapper.selectById(documentId);
+        settings.setDocumentId(documentId);
+        settings.setKnowledgeId(settingsVo.getKnowledgeId());
+        settings.setSetSlice(documentSettings.getSetSlice());
+        settings.setSliceValue(documentSettings.getSliceValue());
+        settings.setSetAnalyze(documentSettings.getSetAnalyze());
+        TakaiDocument document = takaiDocumentMapper.selectTargetDocument(TakaiDocument.builder().documentId(documentId).build());
+        ossVo.setUrl(document.getUrl());
+        ossVo.setOriginalName(document.getName());
+        boolean status = analysisFile(ossVo, settings, "update");
+        if (status) {
+            logger.info("update document setting success, id:{}", documentId);
+            documentSettings.setDocumentId(documentId);
+            int i = takaiDocumentSettingsMapper.updateDocumentSettings(documentSettings);
+            return i;
+        }
+        return 0;
+    }
+
+    @Override
+    public JSONObject getSliceList(TakaiSliceParams params) {
+        String url = deepseekConfig.getBaseurl() + deepseekConfig.getSlicePage();
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("document_id", "f62059be-a119-47ee-b07e-20970257e033");
+        jsonObject.put("knowledge_id", "milvus_hybrid");
+        jsonObject.put("text", params.getText());
+        jsonObject.put("pageNum", params.getPageNum());
+        jsonObject.put("pageSize", params.getPageSize());
+
+        RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), jsonObject.toJSONString());
+        Request request = buildPostRequest(url, requestBody);
+
+        OkHttpClient client = buildOkHttpClient();
+        Response response = null;
+        try {
+            response = client.newCall(request).execute();
+            if (response.isSuccessful()) {
+                String body = response.body().string();
+                JSONObject obj = JSON.parseObject(body);
+                Integer code = obj.getInteger("code");
+                if (code == 200) {
+                    return obj;
+                }
+            } else {
+                logger.info("获取切片列表调用python接口失败,返回状态码:{}", response.code());
+            }
+        } catch (IOException e) {
+            logger.error("获取切片列表调用python接口失败", e.getMessage());
+        }
+        return null;
+    }
+
+    @Override
+    public int deleteSlice(String sliceId, String knowledgeId) {
+        TakaiKnowledge knowledge = takaiKnowledgeMapper.selectTargetKnowledge(TakaiKnowledge.builder().knowledgeId(knowledgeId).build());
+
+        String url = deepseekConfig.getBaseurl() + deepseekConfig.getDeleteSlice() + "/" + sliceId + "/milvus_hybrid";
+        Request request = buildDeleteRequest(url);
+        OkHttpClient client = buildOkHttpClient();
+        Response response = null;
+        try {
+            response = client.newCall(request).execute();
+            if (response.isSuccessful()) {
+                String body = response.body().string();
+                JSONObject obj = JSON.parseObject(body);
+                Integer code = obj.getInteger("code");
+                if (code == 200) {
+                    return 1;
+                }
+            }
+        } catch (IOException e) {
+            logger.error("删除切片调用python接口失败", e.getMessage());
+        }
+        return 0;
+    }
+
+    @Override
+    public JSONObject getSliceDetail(String sliceId, String knowledgeId) {
+        String url = deepseekConfig.getBaseurl() + deepseekConfig.getSliceDetail() + "/milvus_hybrid" + "/" + sliceId;
+        Request request = buildGetRequest(url);
+
+        OkHttpClient client = buildOkHttpClient();
+        try {
+            Response response = client.newCall(request).execute();
+            if (response.isSuccessful()) {
+                String body = response.body().string();
+                log.info("查询切片详情返回:" + body);
+                return JSON.parseObject(body);
+            } else {
+                logger.info("获取切片详情调用python接口失败,返回状态码:{}", response.code());
+            }
+        } catch (IOException e) {
+            log.error("查询切片详情调用python接口失败", e.getMessage());
+        }
+        return null;
+    }
+
+    @Override
+    public int updateSliceInfo(TakaiSliceUpdateParams params) {
+        String url = deepseekConfig.getBaseurl() + deepseekConfig.getUpdateSlice();
+        JSONObject object = new JSONObject();
+        object.put("knowledge_id", "milvus_hybrid");
+        object.put("slice_id", params.getSliceId());
+        object.put("slice_text", params.getSliceText());
+        RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), object.toJSONString());
+
+        Request request = buildPutRequest(url, requestBody);
+        OkHttpClient client = buildOkHttpClient();
+        try {
+            Response response = client.newCall(request).execute();
+            if (response.isSuccessful()) {
+                String body = response.body().string();
+                JSONObject obj = JSON.parseObject(body);
+                Integer code = obj.getInteger("code");
+                if (code == 200) {
+                    return 1;
+                }
+            }
+        } catch (Exception e) {
+            logger.error("更新切片信息调用python接口失败", e.getMessage());
+        }
+        return 0;
+    }
+
+    private boolean analysisFile(TakaiSysOss result, TakaiDocumentSettings settings, String flag) {
+        TakaiKnowledge knowledge = takaiKnowledgeMapper.selectTargetKnowledge(TakaiKnowledge.builder().knowledgeId(settings.getKnowledgeId()).build());
+        String url = deepseekConfig.getBaseurl() + deepseekConfig.getUploadKnowledge();
+        JSONObject json = new JSONObject();
+        json.put("knowledge_id", settings.getKnowledgeId());
+        json.put("document_id", settings.getDocumentId());
+        json.put("embedding_id", knowledge == null ? "" : knowledge.getEmbeddingId());
+        json.put("name", result.getOriginalName());
+        json.put("url", result.getUrl());
+        if ("upload".equals(flag)) {
+            json.put("set_slice", "0");
+            json.put("slice_value", null);
+            json.put("set_analyze", "1");
+            json.put("flag", "upload");
+        } else {
+            json.put("set_slice", settings.getSetSlice());
+            json.put("slice_value", settings.getSliceValue());
+            json.put("set_analyze", settings.getSetAnalyze());
+            json.put("flag", "update");
+        }
+
+        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), json.toJSONString());
+        Request request = buildPostRequest(url, requestBody);
+        OkHttpClient client = buildOkHttpClient();
+        Response response = null;
+        try {
+            response = client.newCall(request).execute();
+            if (response.isSuccessful()) {
+                String body = response.body().string();
+                JSONObject obj = JSON.parseObject(body);
+                Integer code = obj.getInteger("code");
+                if (code == 200) {
+                    logger.info("上传文档调用python接口成功,返回内容:{}", body);
+                    return true;
+                }
+                return false;
+            } else {
+                logger.error("上传文档调用python接口失败返回code:{}", response.code());
+                return false;
+            }
+        } catch (IOException e) {
+            logger.error("上传文档调用python接口失败", e.getMessage());
+            return false;
+        }
+    }
+
+    private List<Object> setDialogList(List<TakaiDialogRespDTO> list) {
+        //根据时间分组降序排序
+        NavigableMap<LocalDateTime, List<TakaiDialogRespDTO>> groupList = list.stream().collect(Collectors.groupingBy(TakaiDialogRespDTO::getCreate_time, TreeMap::new, Collectors.toList())).descendingMap();
+        List<Object> obj = new ArrayList();
+        if(!groupList.isEmpty()){
+            for(Map.Entry<LocalDateTime, List<TakaiDialogRespDTO>> entry: groupList.entrySet()){
+                List<TakaiDialogRespDTO> aList = entry.getValue();
+                List<TakaiDialogRespDTO> detailList = takaiDialogMapper.selectDialogExport(aList.get(0).getId());
+                Map<String, Object> map = new HashMap();
+                map.put("dialog_name", aList.get(0).getDialog_name());
+                map.put("length", detailList.size());
+                map.put("create_time", aList.get(0).getCreate_time());
+                map.put("did", aList.get(0).getDid());
+                map.put("id", aList.get(0).getId());
+                obj.add(map);
+            }
+        }
+        return obj;
+    }
+
+    private String getMimeType(File file) {
+        if (!file.exists()) {
+            return null;
+        }
+
+        String fileName = file.getName().toLowerCase();
+        if (fileName.endsWith(".pdf")) {
+            return "application/json";
+        } else if (fileName.endsWith(".doc") || fileName.endsWith(".docx")) {
+            return "application/msword";
+        } else if (fileName.endsWith(".txt")) {
+            return "text/plain";
+        } else {
+            return null;
+        }
+    }
+
+    private OkHttpClient buildOkHttpClient() {
+        return new OkHttpClient.Builder()
+                .connectTimeout(10, TimeUnit.SECONDS)
+                .writeTimeout(50, TimeUnit.SECONDS)
+                .readTimeout(10, TimeUnit.MINUTES)
+                .build();
+    }
+
+    private Request buildGetRequest(String url) {
+        return new Request.Builder()
+                .addHeader("User-Agent", "insomnia/10.3.1")
+                .url(url).get().build();
+    }
+
+    private Request buildPostRequest(String url, RequestBody requestBody) {
+        return new Request.Builder()
+                .addHeader("User-Agent", "insomnia/10.3.1")
+                .addHeader("Content-Type", "application/json")
+                .url(url).post(requestBody).build();
+    }
+
+    private Request buildPutRequest(String url, RequestBody requestBody) {
+        return new Request.Builder()
+                .addHeader("User-Agent", "insomnia/10.3.1")
+                .url(url).put(requestBody).build();
+    }
+
+    private Request buildDeleteRequest(String url) {
+        return new Request.Builder()
+                .addHeader("Content-Type", "multipart/form-data")
+                .addHeader("User-Agent", "insomnia/10.3.1")
+                .url(url).delete().build();
+    }
+
+    private Request buildUploadPostRequest(String url, RequestBody requestBody) {
+        return new Request.Builder()
+                .addHeader("User-Agent", "insomnia/10.3.1")
+                .addHeader("Content-Type", "application/json")
+                .url(url).post(requestBody).build();
+    }
+
+    private boolean isJsonObject(String data){
+        try {
+            JSON.parseObject(data);
+            return true;
+        }catch (Exception e){
+            return false;
+        }
+    }
+
+}

+ 155 - 0
takai-ai/src/main/java/com/takai/ai/utils/MinioUtil.java

@@ -0,0 +1,155 @@
+package com.takai.ai.utils;
+
+import com.takai.ai.domain.TakaiSysOss;
+import com.takai.ai.domain.TakaiSysOssConfig;
+import org.springframework.stereotype.Component;
+import io.minio.*;
+import io.minio.messages.Bucket;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+@Component
+public class MinioUtil {
+
+    private final MinioClient minioClient;
+    private final String bucketName;
+
+    @Autowired
+    public MinioUtil(MinioClient minioClient, String bucketName) throws Exception{
+        this.minioClient = minioClient;
+        this.bucketName = bucketName;
+        initializeBucket();
+    }
+
+    private void initializeBucket() throws Exception {
+        if (!minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build())) {
+            minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
+        }
+    }
+
+    /**
+     * 批量上传文件
+     * @param files      文件列表
+     * @return 上传成功的文件URL列表
+     */
+    public TakaiSysOss uploadMultiple(MultipartFile files) throws Exception {
+        try {
+            TakaiSysOss ossVo = upload(files);
+            return ossVo;
+        } catch (Exception e) {
+            // 记录失败文件信息,但继续处理其他文件
+            System.err.println("文件上传失败: " + files.getOriginalFilename() + ", 原因: " + e.getMessage());
+        }
+//        List<TakaiSysOss> result = new ArrayList<>();
+//        for (MultipartFile file : files) {
+//            if (file.isEmpty()) {
+//                continue;
+//            }
+//            try {
+//                TakaiSysOss ossVo = upload(file);
+//                result.add(ossVo);
+//            } catch (Exception e) {
+//                // 记录失败文件信息,但继续处理其他文件
+//                System.err.println("文件上传失败: " + file.getOriginalFilename() + ", 原因: " + e.getMessage());
+//            }
+//        }
+        return null;
+    }
+
+    /**
+     * 检查存储桶是否存在
+     */
+    public boolean bucketExists(String bucketName) throws Exception {
+        return minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
+    }
+
+    /**
+     * 创建存储桶
+     */
+    public void makeBucket(String bucketName) throws Exception {
+        if (!bucketExists(bucketName)) {
+            minioClient.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
+        }
+    }
+
+    /**
+     * 列出所有存储桶
+     */
+    public List<Bucket> listBuckets() throws Exception {
+        return minioClient.listBuckets();
+    }
+
+    /**
+     * 上传文件
+     * @param file       文件对象
+     * @return 文件访问URL
+     */
+    public TakaiSysOss upload(MultipartFile file) throws Exception {
+        // 如果存储桶不存在则创建
+        makeBucket(bucketName);
+        // 生成日期目录路径 yyyy/MM/dd
+        String dateDir = new SimpleDateFormat("yyyy/MM/dd").format(new Date());
+        // 生成唯一文件名
+        String originalFilename = file.getOriginalFilename();
+//        String fileName = UUID.randomUUID().toString() + originalFilename.substring(originalFilename.lastIndexOf("."));
+        String fileName = dateDir + "/" + originalFilename;
+        // 上传文件
+        try (InputStream inputStream = file.getInputStream()) {
+            minioClient.putObject(
+                    PutObjectArgs.builder()
+                            .bucket(bucketName)
+                            .object(fileName)
+                            .stream(inputStream, file.getSize(), -1)
+                            .contentType(file.getContentType())
+                            .build());
+        }
+        SnowflakeDigitGenerator snowflakeDigitGenerator = new SnowflakeDigitGenerator(1, 1);
+        long ossId = snowflakeDigitGenerator.nextId();
+        String url = minioClient.getObjectUrl(bucketName, fileName);
+        TakaiSysOss oss = new TakaiSysOss();
+        oss.setOssId("a"+ossId);
+        oss.setUrl(url);
+        oss.setFileName(fileName);
+        oss.setOriginalName(originalFilename);
+        oss.setService("service");
+        oss.setFileSuffix(fileName.substring(fileName.lastIndexOf(".")));
+        return oss;
+    }
+
+    /**
+     * 下载文件
+     */
+    public InputStream download(String bucketName, String objectName) throws Exception {
+        return minioClient.getObject(
+                GetObjectArgs.builder()
+                        .bucket(bucketName)
+                        .object(objectName)
+                        .build());
+    }
+
+    /**
+     * 删除文件
+     */
+    public void remove(String bucketName, String objectName) throws Exception {
+        minioClient.removeObject(
+                RemoveObjectArgs.builder()
+                        .bucket(bucketName)
+                        .object(objectName)
+                        .build());
+    }
+
+    /**
+     * 获取文件URL
+     */
+    public String getFileUrl(String bucketName, String objectName) throws Exception {
+        return minioClient.getObjectUrl(bucketName, objectName);
+    }
+
+}

+ 72 - 0
takai-ai/src/main/java/com/takai/ai/utils/SnowflakeDigitGenerator.java

@@ -0,0 +1,72 @@
+package com.takai.ai.utils;
+
+public class SnowflakeDigitGenerator {
+
+    private final long twepoch = 1288834974657L; // 起始时间戳
+    private final long workerIdBits = 5L;
+    private final long datacenterIdBits = 5L;
+    private final long sequenceBits = 12L;
+
+    private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
+    private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
+
+    private final long workerIdShift = sequenceBits;
+    private final long datacenterIdShift = sequenceBits + workerIdBits;
+    private final long timestampShift = sequenceBits + workerIdBits + datacenterIdBits;
+
+    private long workerId;
+    private long datacenterId;
+    private long sequence = 0L;
+    private long lastTimestamp = -1L;
+
+    public SnowflakeDigitGenerator(long workerId, long datacenterId) {
+        if (workerId > maxWorkerId || workerId < 0) {
+            throw new IllegalArgumentException("worker Id can't be greater than " + maxWorkerId + " or less than 0");
+        }
+        if (datacenterId > maxDatacenterId || datacenterId < 0) {
+            throw new IllegalArgumentException("datacenter Id can't be greater than " + maxDatacenterId + " or less than 0");
+        }
+        this.workerId = workerId;
+        this.datacenterId = datacenterId;
+    }
+
+    public synchronized long nextId() {
+        long timestamp = timeGen();
+
+        if (timestamp < lastTimestamp) {
+            throw new RuntimeException("Clock moved backwards. Refusing to generate id for " + (lastTimestamp - timestamp) + " milliseconds");
+        }
+
+        if (lastTimestamp == timestamp) {
+            sequence = (sequence + 1) & ((1 << sequenceBits) - 1);
+            if (sequence == 0) {
+                timestamp = tilNextMillis(lastTimestamp);
+            }
+        } else {
+            sequence = 0L;
+        }
+
+        lastTimestamp = timestamp;
+
+        long id = ((timestamp - twepoch) << timestampShift)
+                | (datacenterId << datacenterIdShift)
+                | (workerId << workerIdShift)
+                | sequence;
+
+        // 转换为19位数字
+        return 1000000000000000000L + (id % 9000000000000000000L);
+    }
+
+    private long tilNextMillis(long lastTimestamp) {
+        long timestamp = timeGen();
+        while (timestamp <= lastTimestamp) {
+            timestamp = timeGen();
+        }
+        return timestamp;
+    }
+
+    private long timeGen() {
+        return System.currentTimeMillis();
+    }
+
+}

+ 42 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiAppInfoMapper.xml

@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+		PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+		"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiAppInfoMapper">
+
+	<resultMap type="com.takai.ai.domain.entity.TakaiAppInfo" id="AppInfoResult">
+		<id property="appId"   column="appId"   />
+		<result property="appInfo"  column="appInfo"  />
+		<result property="create_time" column="create_time" />
+	</resultMap>
+
+	<insert id="insertAppInfo" parameterType="TakaiAppInfo">
+		insert into app_info(
+		<if test="appId != null">appId,</if>
+		<if test="appInfo != null">app_info,</if>
+		create_time
+		)values(
+		<if test="appId != null">#{appId},</if>
+		<if test="appInfo != null">#{appInfo},</if>
+		sysdate()
+		)
+	</insert>
+
+	<select id="selectAppInfoByAppId"  resultMap="AppInfoResult">
+		select
+			q.appId,
+			q.app_info as appInfo,
+			q.create_time as createTime
+		from app_info q
+		where q.appId = #{appId}
+	</select>
+
+	<delete id="delAppInfoByAppId" parameterType="String">
+		delete from app_info where appId = #{appId}
+	</delete>
+
+	<update id="updateAppInfoByAppId" parameterType="TakaiAppInfo">
+		update app_info set app_info = #{appInfo} where appId = #{appId}
+	</update>
+
+</mapper>

+ 111 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiApplicationMapper.xml

@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiApplicationMapper">
+	
+	<resultMap type="com.takai.ai.domain.entity.TakaiApplication" id="BmApplicationResult">
+		<id property="appId"   column="appId"   />
+		<result property="name"  column="name"  />
+		<result property="desc"  column="description"  />
+		<result property="prompt"   column="prompt"   />
+		<result property="topP"   column="top_p"   />
+		<result property="temperature"   column="temperature"   />
+		<result property="knowledgeIds"   column="knowledge_ids"   />
+		<result property="sliceCount"   column="slice_count"   />
+		<result property="model"   column="model"   />
+		<result property="iconColor"   column="icon_color"   />
+		<result property="iconType"   column="icon_type"   />
+		<result property="maxToken" column="max_token" />
+		<result property="paramDesc"   column="param_desc"/>
+		<result property="remark"   column="remark"   />
+		<result property="createBy"   column="create_by"   />
+		<result property="createTime" column="create_time" />
+		<result property="updateBy"   column="update_by"   />
+		<result property="updateTime" column="update_time" />
+		<result property="knowledgeInfo" column="knowledge_info" />
+	</resultMap>
+	
+	<sql id="selectSql">
+        select appId, name, description, prompt, top_p, temperature, knowledge_ids, slice_count,model,icon_color,icon_type,max_token, create_by, create_time, remark, knowledge_info
+		from bm_application
+    </sql>
+
+	<select id="selectApplicationList" parameterType="BmApplication" resultMap="BmApplicationResult">
+	    <include refid="selectSql"/>
+		<where>
+		    <if test="appId != null and appId != ''">
+				AND appId = #{appId}
+			</if>
+		</where>
+		order by create_time asc
+	</select>
+
+	<select id="selectTargetApplication" parameterType="BmApplication" resultMap="BmApplicationResult">
+		<include refid="selectSql"/>
+		where appId = #{appId}
+	</select>
+ 	
+ 	<insert id="insertApplication" parameterType="TakaiApplication">
+ 		insert into bm_application(
+ 			<if test="appId != null">appId,</if>
+ 			<if test="name != null and name != ''">name,</if>
+ 			<if test="desc != null and desc != ''">description,</if>
+ 			<if test="prompt != null and prompt != ''">prompt,</if>
+ 			<if test="topP != null and topP != ''">top_p,</if>
+			<if test="temperature != null and temperature != ''">temperature,</if>
+			<if test="knowledgeIds != null and knowledgeIds != ''">knowledge_ids,</if>
+			<if test="sliceCount != null">slice_count,</if>
+			<if test="model != null and model != ''">model,</if>
+			<if test="iconColor != null and iconColor != ''">icon_color,</if>
+			<if test="iconType != null and iconType != ''">icon_type,</if>
+ 			<if test="remark != null and remark != ''">remark,</if>
+ 			<if test="createBy != null and createBy != ''">create_by,</if>
+		    <if test="knowledgeInfo != null and knowledgeInfo != ''">knowledge_info,</if>
+		    <if test="maxToken != null and maxToken != ''">max_token,</if>
+ 			create_time
+ 		)values(
+			<if test="appId != null">#{appId},</if>
+			<if test="name != null and name != ''">#{name},</if>
+			<if test="desc != null and desc != ''">#{desc},</if>
+			<if test="prompt != null and prompt != ''">#{prompt},</if>
+			<if test="topP != null and topP != ''">#{topP},</if>
+			<if test="temperature != null and temperature != ''">#{temperature},</if>
+			<if test="knowledgeIds != null and knowledgeIds != ''">#{knowledgeIds},</if>
+			<if test="sliceCount != null">#{sliceCount},</if>
+			<if test="model != null and model != ''">#{model},</if>
+			<if test="iconColor != null and iconColor != ''">#{iconColor},</if>
+			<if test="iconType != null and iconType != ''">#{iconType},</if>
+ 			<if test="remark != null and remark != ''">#{remark},</if>
+ 			<if test="createBy != null and createBy != ''">#{createBy},</if>
+		    <if test="knowledgeInfo != null and knowledgeInfo != ''">#{knowledgeInfo},</if>
+		    <if test="maxToken != null and maxToken != ''">#{maxToken},</if>
+ 			sysdate()
+ 		)
+	</insert>
+
+	<update id="updateApplication" parameterType="BmApplication">
+		update bm_application
+		<set>
+			<if test="name != null and name != ''">name = #{name},</if>
+			<if test="desc != null and desc != ''">description = #{desc},</if>
+			<if test="prompt != null and prompt != ''">prompt = #{prompt},</if>
+			<if test="topP != null and topP != ''">top_p = #{topP},</if>
+			<if test="temperature != null and temperature != ''">temperature = #{temperature},</if>
+			<if test="knowledgeIds != null and knowledgeIds != ''">knowledge_ids = #{knowledgeIds},</if>
+			<if test="sliceCount != null">slice_count = #{sliceCount},</if>
+			<if test="model != null and model != ''">model = #{model},</if>
+			<if test="iconColor != null and iconColor != ''">icon_color = #{iconColor},</if>
+			<if test="iconType != null and iconType != ''">icon_type = #{iconType},</if>
+			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+			<if test="remark != null">remark = #{remark},</if>
+			update_time = sysdate()
+		</set>
+		where appId = #{appId}
+	</update>
+
+	<delete id="delApplication" parameterType="String">
+		delete from bm_application where appId = #{appId}
+	</delete>
+	
+</mapper> 

+ 179 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiDialogMapper.xml

@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiDialogMapper">
+	
+	<resultMap type="com.takai.ai.domain.dto.TakaiDialogRespDTO" id="TakaiDialogResult">
+		<id property="id"   column="id"   />
+		<result property="dialog_name"  column="dialog_name"  />
+		<result property="dialog_id"  column="dialog_id"  />
+		<result property="did"   column="did"   />
+		<result property="content"   column="content"   />
+		<result property="type"   column="type"   />
+		<result property="create_time" column="create_time" />
+	</resultMap>
+
+	<select id="selectDialogById" parameterType="String" resultMap="TakaiDialogResult">
+		select id
+		from dialog
+		<where>
+			<if test="dialogId != null and dialogId != ''">
+				AND id = #{dialogId}
+			</if>
+		</where>
+	</select>
+
+	<select id="selectDialogDetailById" parameterType="String" resultMap="TakaiDialogResult">
+		select id
+		from dialog_detail
+		<where>
+			<if test="detailId != null and detailId != ''">
+				AND id = #{detailId}
+			</if>
+		</where>
+	</select>
+
+	<select id="selectDialogList"  resultMap="TakaiDialogResult">
+		select
+		d.id as id,
+		d.app_id as appId,
+		d.dialog_name as dialog_name,
+		date_format(d.create_time, '%Y-%m-%d') as create_time
+		from dialog d
+		<where>
+			<if test="appId != null">
+				d.app_id = #{appId}
+			</if>
+		</where>
+		GROUP BY d.id,d.app_id,d.dialog_name,d.create_time
+		ORDER BY d.create_time desc
+	</select>
+
+	<insert id="insertDialog" parameterType="DialogReqDTO">
+		insert into dialog(
+		id,
+		<if test="appId != null">app_id,</if>
+		<if test="knowledgeId != null">knowledge_id,</if>
+		<if test="userId != null">user_id,</if>
+		<if test="dialogName != null">dialog_name,</if>
+		create_time
+		)values(
+		#{id},
+		<if test="appId != null">#{appId},</if>
+		<if test="knowledgeId != null">#{knowledgeId},</if>
+		<if test="userId != null">#{userId},</if>
+		<if test="dialogName != null">#{dialogName},</if>
+		sysdate()
+		)
+	</insert>
+
+	<insert id="insertDialogDetail" parameterType="DialogDetailReqDTO">
+		insert into dialog_detail(
+		id,
+		<if test="dialogId != null">dialog_id,</if>
+		<if test="role != null">type,</if>
+		<if test="content != null">content,</if>
+		<if test="role != null">create_by,</if>
+		create_time
+		)values(
+		#{id},
+		<if test="dialogId != null">#{dialogId},</if>
+		<if test="role != null">#{role},</if>
+		<if test="content != null">#{content},</if>
+		<if test="role != null">#{role},</if>
+		sysdate()
+		)
+	</insert>
+
+	<select id="selectDialogDetail"  resultMap="TakaiDialogResult">
+		select
+			d.id,
+			d.app_id as appId,
+			d.knowledge_id as knowledgeId,
+			d.user_id as userId,
+			d.dialog_name,
+			d.create_time,
+			dd.id as did,
+			dd.type,
+			dd.content,
+			dd.dialog_id
+		from dialog d
+				 left join dialog_detail dd on d.id = dd.dialog_id
+		where dd.dialog_id = #{dialogId}
+		ORDER BY dd.create_time asc, dd.type desc
+	</select>
+
+	<delete id="delDialog" parameterType="String">
+		delete from dialog where id = #{id}
+	</delete>
+
+	<delete id="delDialogDetail" parameterType="String">
+		delete from dialog_detail where dialog_id = #{dialogId}
+	</delete>
+
+	<update id="updateDialog" parameterType="DialogDetailReqDTO">
+		update dialog set dialog_name = #{dialogName} where id = #{id}
+	</update>
+
+	<select id="selectDialogExport"  resultMap="TakaiDialogResult">
+		select
+			d.id,
+			d.app_id as appId,
+			d.knowledge_id as knowledgeId,
+			d.user_id as userId,
+			d.dialog_name,
+			d.create_time,
+			dd.id as did,
+			dd.type,
+			dd.content,
+			dd.dialog_id
+		from dialog d
+				 left join dialog_detail dd on d.id = dd.dialog_id
+		where dd.dialog_id = #{id}
+		ORDER BY dd.create_time asc, dd.type desc
+	</select>
+
+	<select id="selectDialogListByAppId" resultMap="TakaiDialogResult">
+		select
+		d.id,
+		d.app_id as appId,
+		d.knowledge_id as knowledgeId,
+		d.user_id as userId,
+		d.dialog_name,
+		d.create_time,
+		dd.id as did,
+		dd.type,
+		dd.content,
+		dd.dialog_id
+		from dialog d
+		left join dialog_detail dd on d.id = dd.dialog_id
+		<where>
+			<if test="appId != null">
+				d.app_id = #{appId}
+			</if>
+		</where>
+		ORDER BY dd.create_time asc, dd.type desc
+	</select>
+
+	<select id="selectDialog" resultMap="TakaiDialogResult">
+		select
+		d.id,
+		d.app_id as appId,
+		d.knowledge_id as knowledgeId,
+		d.user_id as userId,
+		d.dialog_name,
+		d.create_time
+		from dialog d
+		<where>
+			<if test="appId != null and appId != null">
+				d.app_id = #{appId}
+			</if>
+			<if test="userId != null and userId != null">
+				d.user_id = #{userId}
+			</if>
+		</where>
+		ORDER BY d.create_time asc
+	</select>
+
+</mapper>

+ 103 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiDocumentMapper.xml

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiDocumentMapper">
+	
+	<resultMap type="com.takai.ai.domain.entity.TakaiDocument" id="BmDocumentResult">
+		<id property="documentId"   column="document_id"   />
+		<result property="knowledgeId"  column="knowledge_id"  />
+		<result property="customSeparator"  column="custom_separator"  />
+		<result property="knowledgeType"  column="knowledge_type"  />
+		<result property="sentenceSize"   column="sentence_size"   />
+		<result property="length"   column="length"   />
+		<result property="wordNum"   column="word_num"   />
+		<result property="name"   column="name"   />
+		<result property="url"   column="url"   />
+		<result property="parseImage"   column="parse_image"   />
+		<result property="remark"   column="remark"   />
+		<result property="createBy"   column="create_by"   />
+		<result property="createTime" column="create_time" />
+		<result property="updateBy"   column="update_by"   />
+		<result property="updateTime" column="update_time" />
+	</resultMap>
+	
+	<sql id="selectSql">
+        select document_id, knowledge_id,custom_separator, knowledge_type, sentence_size, length, word_num, name,url, create_by, create_time, remark, update_time
+		from bm_document
+    </sql>
+
+	<select id="selectDocumentList" parameterType="BmDocument" resultMap="BmDocumentResult">
+	    <include refid="selectSql"/>
+		<where>
+		    <if test="documentId != null and documentId != ''">
+				AND document_id = #{documentId}
+			</if>
+			<if test="knowledgeId != null and knowledgeId != ''">
+				AND knowledge_id = #{knowledgeId}
+			</if>
+		</where>
+		order by create_time asc
+	</select>
+	
+	<select id="selectTargetDocument" parameterType="BmDocument" resultMap="BmDocumentResult">
+		<include refid="selectSql"/>
+		where document_id = #{documentId}
+	</select>
+ 	
+ 	<insert id="insertDocument" parameterType="BmDocument">
+ 		insert into bm_document(
+ 			<if test="documentId != null  and documentId != ''">document_id,</if>
+			<if test="knowledgeId != null  and knowledgeId != ''">knowledge_id,</if>
+			<if test="customSeparator != null  and customSeparator != ''">custom_separator,</if>
+ 			<if test="knowledgeType != null">knowledge_type,</if>
+ 			<if test="sentenceSize != null and sentenceSize != ''">sentence_size,</if>
+			<if test="wordNum != null">word_num,</if>
+			<if test="length != null">length,</if>
+			<if test="name != null and name != ''">name,</if>
+			<if test="url != null and url != ''">url,</if>
+		    <if test="parseImage != null">parse_image,</if>
+ 			<if test="remark != null and remark != ''">remark,</if>
+ 			<if test="createBy != null and createBy != ''">create_by,</if>
+ 			create_time
+ 		)values(
+			<if test="documentId != null  and documentId != ''">#{documentId},</if>
+			<if test="knowledgeId != null  and knowledgeId != ''">#{knowledgeId},</if>
+			<if test="customSeparator != null  and customSeparator != ''">#{customSeparator},</if>
+			<if test="knowledgeType != null">#{knowledgeType},</if>
+			<if test="sentenceSize != null and sentenceSize != ''">#{sentenceSize},</if>
+			<if test="wordNum != null">#{wordNum},</if>
+			<if test="length != null">#{length},</if>
+			<if test="name != null and name != ''">#{name},</if>
+			<if test="url != null and url != ''">#{url},</if>
+			<if test="parseImage != null">#{parseImage},</if>
+ 			<if test="remark != null and remark != ''">#{remark},</if>
+ 			<if test="createBy != null and createBy != ''">#{createBy},</if>
+ 			sysdate()
+ 		)
+	</insert>
+
+
+	<update id="updateDocument" parameterType="BmDocument">
+		update bm_document
+		<set>
+			<if test="customSeparator != null  and customSeparator != ''">custom_separator = #{customSeparator},</if>
+			<if test="knowledgeType != null">knowledge_type = #{knowledgeType},</if>
+			<if test="sentenceSize != null and sentenceSize != ''">sentence_size = #{sentenceSize},</if>
+			<if test="wordNum != null">word_num = #{wordNum},</if>
+			<if test="length != null">length = #{length},</if>
+			<if test="name != null and name != ''">name = #{name},</if>
+			<if test="url != null and url != ''">url = #{url},</if>
+			<if test="parseImage != null">parse_image = #{parseImage},</if>
+			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+			<if test="remark != null">remark = #{remark},</if>
+			update_time = sysdate()
+		</set>
+		where document_id = #{documentId}
+	</update>
+
+	<delete id="delDocument" parameterType="String">
+		delete from bm_document where document_id = #{documentId}
+	</delete>
+	
+</mapper> 

+ 67 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiDocumentSettingsMapper.xml

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiDocumentSettingsMapper">
+	
+	<resultMap type="com.takai.ai.domain.entity.TakaiDocumentSettings" id="DocumentSettingsResult">
+		<id property="id"   column="id"   />
+		<result property="knowledgeId"  column="knowledge_id" />
+		<result property="documentId"  column="document_id" />
+		<result property="setSlice"  column="set_slice"  />
+		<result property="setAnalyze"   column="set_analyze" />
+		<result property="hidInfo"   column="hid_info"   />
+		<result property="sliceValue"   column="slice_value" />
+	</resultMap>
+
+	<sql id="Base_Column">
+		id, knowledge_id, document_id, set_slice, set_analyze, hid_info, slice_value
+	</sql>
+
+	<select id="selectById" resultMap="DocumentSettingsResult">
+		select
+		<include refid="Base_Column"/>
+		from document_settings
+		where document_id = #{id}
+	</select>
+
+	<insert id="insertDocumentSettings" parameterType="TakaiDocumentSettings">
+		insert into document_settings(
+		<if test="id != null  and id != ''">id,</if>
+		<if test="knowledgeId != null  and knowledgeId != ''">knowledge_id,</if>
+		<if test="documentId != null  and documentId != ''">document_id,</if>
+		<if test="setSlice != null and setSlice != ''">set_slice,</if>
+		<if test="setAnalyze != null and setAnalyze != ''">set_analyze,</if>
+		<if test="hidInfo != null and hidInfo != ''">hid_info,</if>
+		create_time
+		)values(
+		<if test="id != null  and id != ''">#{id},</if>
+		<if test="knowledgeId != null  and knowledgeId != ''">#{knowledgeId},</if>
+		<if test="documentId != null  and documentId != ''">#{documentId},</if>
+		<if test="setSlice != null and setSlice != ''">#{setSlice},</if>
+		<if test="setAnalyze != null and setAnalyze != ''">#{setAnalyze},</if>
+		<if test="hidInfo != null and hidInfo != ''">#{hidInfo},</if>
+		sysdate()
+		)
+	</insert>
+
+	<update id="updateDocumentSettings" parameterType="TakaiDocumentSettings">
+		update document_settings
+		<set>
+			<if test="id != null  and id != ''">id= #{id},</if>
+			<if test="knowledgeId != null  and knowledgeId != ''">knowledge_id= #{knowledgeId},</if>
+			<if test="documentId != null  and documentId != ''">document_id= #{documentId},</if>
+			<if test="setSlice != null and setSlice != ''">set_slice= #{setSlice},</if>
+			<if test="setAnalyze != null and setAnalyze != ''">set_analyze= #{setAnalyze},</if>
+			<if test="hidInfo != null and hidInfo != ''">hid_info= #{hidInfo},</if>
+			slice_value= #{sliceValue},
+			update_time = sysdate()
+		</set>
+		where document_id = #{documentId}
+	</update>
+
+	<delete id="deleteDocumentSettings" parameterType="String">
+		delete from document_settings where id = #{id}
+	</delete>
+
+</mapper>

+ 97 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiKnowledgeMapper.xml

@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiKnowledgeMapper">
+	
+	<resultMap type="com.takai.ai.domain.entity.TakaiKnowledge" id="BmKnowledgeResult">
+		<id property="knowledgeId"   column="knowledge_id"   />
+		<result property="embeddingId"  column="embedding_id"  />
+		<result property="name"  column="name"  />
+		<result property="description"   column="description"   />
+		<result property="background"   column="background"   />
+		<result property="icon"   column="icon"   />
+		<result property="wordNum"   column="word_num"   />
+		<result property="length"   column="length"   />
+		<result property="documentSize"   column="document_size"   />
+		<result property="remark"   column="remark"   />
+		<result property="createBy"   column="create_by"   />
+		<result property="createTime" column="create_time" />
+		<result property="updateBy"   column="update_by"   />
+		<result property="updateTime" column="update_time" />
+	</resultMap>
+	
+	<sql id="selectSql">
+        select knowledge_id, embedding_id, name, description, background, icon, word_num, length,document_size, create_by, create_time,update_time, remark
+		from bm_knowledge
+    </sql>
+
+	<select id="selectKnowledgeList" parameterType="TakaiKnowledge" resultMap="BmKnowledgeResult">
+	    <include refid="selectSql"/>
+		<where>
+		    <if test="knowledgeId != null and knowledgeId != ''">
+				AND knowledge_id = #{knowledgeId}
+			</if>
+		</where>
+		order by create_time asc
+	</select>
+	
+	<select id="selectTargetKnowledge" parameterType="TakaiKnowledge" resultMap="BmKnowledgeResult">
+		<include refid="selectSql"/>
+		where knowledge_id = #{knowledgeId}
+	</select>
+ 	
+ 	<insert id="insertKnowledge" parameterType="TakaiKnowledge">
+ 		insert into bm_knowledge(
+ 			<if test="knowledgeId != null  and knowledgeId != ''">knowledge_id,</if>
+ 			<if test="embeddingId != null and embeddingId != ''">embedding_id,</if>
+ 			<if test="name != null and name != ''">name,</if>
+ 			<if test="description != null and description != ''">description,</if>
+ 			<if test="background != null and background != ''">background,</if>
+			<if test="icon != null and icon != ''">icon,</if>
+			<if test="wordNum != null">word_num,</if>
+			<if test="length != null">length,</if>
+			<if test="documentSize != null">document_size,</if>
+ 			<if test="remark != null and remark != ''">remark,</if>
+ 			<if test="createBy != null and createBy != ''">create_by,</if>
+ 			create_time
+ 		)values(
+			<if test="knowledgeId != null  and knowledgeId != ''">#{knowledgeId},</if>
+			<if test="embeddingId != null and embeddingId != ''">#{embeddingId},</if>
+			<if test="name != null and name != ''">#{name},</if>
+			<if test="description != null and description != ''">#{description},</if>
+			<if test="background != null and background != ''">#{background},</if>
+			<if test="icon != null and icon != ''">#{icon},</if>
+			<if test="wordNum != null">#{wordNum},</if>
+			<if test="length != null">#{length},</if>
+			<if test="documentSize != null">#{documentSize},</if>
+ 			<if test="remark != null and remark != ''">#{remark},</if>
+ 			<if test="createBy != null and createBy != ''">#{createBy},</if>
+ 			sysdate()
+ 		)
+	</insert>
+
+	<update id="updateKnowledge" parameterType="BmKnowledge">
+		update bm_knowledge
+		<set>
+			<if test="knowledgeId != null  and knowledgeId != ''">knowledge_id = #{knowledgeId},</if>
+			<if test="embeddingId != null">embedding_id = #{embeddingId},</if>
+			<if test="name != null and name != ''">name = #{name},</if>
+			<if test="description != null and description != ''">description = #{description},</if>
+			<if test="background != null and background != ''">background = #{background},</if>
+			<if test="icon != null and icon != ''">icon = #{icon},</if>
+			<if test="wordNum != null">word_num = #{wordNum},</if>
+			<if test="length != null">length = #{length},</if>
+			<if test="documentSize != null">document_size = #{documentSize},</if>
+			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+			<if test="remark != null">remark = #{remark},</if>
+			update_time = sysdate()
+		</set>
+		where knowledge_id = #{knowledgeId}
+	</update>
+
+	<delete id="delKnowledge" parameterType="String">
+		delete from bm_knowledge where knowledge_id = #{knowledgeId}
+	</delete>
+	
+</mapper> 

+ 83 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiMediaReplacementMapper.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiMediaReplacementMapper">
+	
+	<resultMap type="com.takai.ai.domain.entity.TakaiMediaReplacement" id="BmMediaReplacementResult">
+		<id     property="id"   column="id"   />
+		<result property="documentId"   column="document_id"   />
+		<result property="originText"  column="origin_text"  />
+		<result property="mediaType"  column="media_type"  />
+		<result property="mediaKey"   column="media_key"   />
+		<result property="mediaUrl"   column="media_url"   />
+		<result property="remark"   column="remark"   />
+		<result property="createBy"   column="create_by"   />
+		<result property="createTime" column="create_time" />
+		<result property="updateBy"   column="update_by"   />
+		<result property="updateTime" column="update_time" />
+	</resultMap>
+	
+	<sql id="selectSql">
+        select id, document_id, origin_text, media_type, media_key, media_url, create_by, create_time, remark
+		from bm_media_replacement
+    </sql>
+
+	<select id="selectMediaList" parameterType="BmMediaReplacement" resultMap="BmMediaReplacementResult">
+	    <include refid="selectSql"/>
+		<where>
+		    <if test="documentId != null and documentId != ''">
+				AND document_id = #{documentId}
+			</if>
+			<if test="mediaType != null and mediaType != ''">
+				AND media_type = #{mediaType}
+			</if>
+		</where>
+		order by create_time asc
+	</select>
+	
+	<select id="selectTargetMedia" parameterType="BmMediaReplacement" resultMap="BmMediaReplacementResult">
+		<include refid="selectSql"/>
+		where document_id = #{documentId}
+		and origin_text = #{originText}
+ 		and media_type = #{mediaType}
+	</select>
+ 	
+ 	<insert id="insertMedia" parameterType="BmMediaReplacement">
+ 		insert into bm_media_replacement(
+ 			<if test="documentId != null">document_id,</if>
+ 			<if test="originText != null and originText != ''">origin_text,</if>
+ 			<if test="mediaType != null and mediaType != ''">media_type,</if>
+ 			<if test="mediaKey != null and mediaKey != ''">media_key,</if>
+ 			<if test="mediaUrl != null and mediaUrl != ''">media_url,</if>
+ 			<if test="remark != null and remark != ''">remark,</if>
+ 			<if test="createBy != null and createBy != ''">create_by,</if>
+ 			create_time
+ 		)values(
+ 		    <if test="documentId != null">#{documentId},</if>
+ 		    <if test="originText != null and originText != ''">#{originText},</if>
+ 			<if test="mediaType != null and mediaType != ''">#{mediaType},</if>
+ 			<if test="mediaKey != null and mediaKey != ''">#{mediaKey},</if>
+ 			<if test="mediaUrl != null and mediaUrl != ''">#{mediaUrl},</if>
+ 			<if test="remark != null and remark != ''">#{remark},</if>
+ 			<if test="createBy != null and createBy != ''">#{createBy},</if>
+ 			sysdate()
+ 		)
+	</insert>
+
+	<update id="updateMedia" parameterType="BmMediaReplacement">
+		update bm_media_replacement
+		<set>
+			<if test="documentId != null">document_id = #{documentId},</if>
+			<if test="originText != null and originText != ''">origin_text = #{originText},</if>
+			<if test="mediaType != null and mediaType != ''">media_type = #{mediaType},</if>
+			<if test="mediaKey != null and mediaKey != ''">media_key = #{mediaKey},</if>
+			<if test="mediaUrl != null and mediaUrl != ''">media_url = #{mediaUrl},</if>
+			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+			<if test="remark != null">remark = #{remark},</if>
+			update_time = sysdate()
+		</set>
+		where id = #{id}
+	</update>
+	
+</mapper> 

+ 61 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiQuestionMapper.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiQuestionMapper">
+	
+	<resultMap type="com.takai.ai.domain.dto.TakaiQuestionDTO" id="QuestionResult">
+		<id property="id"   column="id"   />
+		<result property="app_id"  column="app_id"  />
+		<result property="question"  column="question"  />
+		<result property="create_time" column="create_time" />
+	</resultMap>
+
+	<select id="getQuestionList"  resultMap="QuestionResult">
+		select
+			q.id,
+			q.app_id as appId,
+			q.question,
+			q.create_time as createTime
+		from question q
+		where q.app_id = #{appId}
+		ORDER BY q.create_time desc
+	</select>
+ 	
+ 	<insert id="insertQuestion" parameterType="Question">
+ 		insert into question(
+		    id,
+			<if test="appId != null">app_id,</if>
+			<if test="question != null">question,</if>
+ 			create_time
+ 		)values(
+			#{id},
+			<if test="appId != null">#{appId},</if>
+			<if test="question != null">#{question},</if>
+ 			sysdate()
+ 		)
+	</insert>
+
+	<select id="selectQuestionById"  resultMap="QuestionResult">
+		select
+			q.id,
+			q.app_id as appId,
+			q.question,
+			q.create_time
+		from question q
+		where q.id = #{id}
+	</select>
+
+	<delete id="delQuestion" parameterType="String">
+		delete from question where id = #{id}
+	</delete>
+
+	<update id="updateQuestion" parameterType="Question">
+		update question set question = #{question} where id = #{id}
+	</update>
+
+	<delete id="delQuestionByAppId" parameterType="String">
+		delete from question where app_id = #{appId}
+	</delete>
+
+</mapper>

+ 35 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiSysOssConfigMapper.xml

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiSysOssConfigMapper">
+	
+	<resultMap type="com.takai.ai.domain.TakaiSysOssConfig" id="SysOssResult">
+		<id property="ossConfigId"   column="oss_config_id"   />
+		<result property="configKey"  column="config_key"  />
+		<result property="accessKey"  column="access_key"  />
+		<result property="secretKey"   column="secret_key"   />
+		<result property="bucketName"   column="bucket_name"   />
+		<result property="prefix"   column="prefix"   />
+		<result property="domain"   column="domain"   />
+		<result property="isHttps"   column="is_https"   />
+		<result property="region"   column="region"   />
+		<result property="status"   column="status"   />
+		<result property="ext1"   column="ext1"   />
+		<result property="remark" column="remark" />
+		<result property="accessPolicy"   column="access_policy"/>
+	</resultMap>
+
+	<sql id="Base_Column">
+		oss_config_id, config_key, access_key, secret_key, bucket_name, prefix, endpoint, domain, is_https, region, status, ext1, remark, access_policy
+	</sql>
+
+	<select id="selectByOssConfigId" resultMap="SysOssResult">
+		select
+		<include refid="Base_Column"/>
+		from sys_oss_config
+		where oss_config_id = #{ossConfigId}
+	</select>
+
+	
+</mapper> 

+ 40 - 0
takai-ai/src/main/resources/mapper/takaiai/TakaiSysOssMapper.xml

@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.takai.ai.mapper.TakaiSysOssMapper">
+
+	<resultMap type="com.takai.ai.domain.TakaiSysOss" id="takaiSysOssResult">
+		<id property="ossId"   column="oss_id"   />
+		<result property="tenantId"  column="tenant_id"  />
+		<result property="fileName"  column="file_name"  />
+		<result property="originalName"   column="original_name"   />
+		<result property="fileSuffix"   column="file_suffix"   />
+		<result property="url"   column="url"   />
+		<result property="createDept"   column="create_dept"   />
+		<result property="service"   column="service"   />
+	</resultMap>
+
+	<insert id="insertSysOss" parameterType="com.takai.ai.domain.TakaiSysOss">
+		insert into sys_oss(
+		<if test="ossId != null and ossId != ''">oss_id,</if>
+		<if test="fileName != null and fileName != ''">file_name,</if>
+		<if test="originalName != null and originalName != ''">original_name,</if>
+		<if test="fileSuffix != null and fileSuffix != ''">file_suffix,</if>
+		<if test="url != null and url != ''">url,</if>
+		<if test="service != null and service != ''">service,</if>
+		create_time
+		)values(
+		<if test="ossId != null and ossId != ''">#{ossId},</if>
+		<if test="fileName != null and fileName != ''">#{fileName},</if>
+		<if test="originalName != null and originalName != ''">#{originalName},</if>
+		<if test="fileSuffix != null and fileSuffix != ''">#{fileSuffix},</if>
+		<if test="url != null and url != ''">#{url},</if>
+		<if test="service != null and service != ''">#{service},</if>
+		sysdate()
+		)
+	</insert>
+	
+
+	
+</mapper> 

+ 0 - 2
takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/BmApplicationMapper.java

@@ -1,8 +1,6 @@
 package com.takai.bigmodel.mapper;
 
 import com.takai.bigmodel.domain.entity.BmApplication;
-import com.takai.bigmodel.domain.entity.BmMediaReplacement;
-
 import java.util.List;
 
 /**

+ 0 - 1
takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/BmDocumentMapper.java

@@ -1,7 +1,6 @@
 package com.takai.bigmodel.mapper;
 
 import com.takai.bigmodel.domain.entity.BmDocument;
-
 import java.util.List;
 
 /**

+ 0 - 1
takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/BmKnowledgeMapper.java

@@ -1,7 +1,6 @@
 package com.takai.bigmodel.mapper;
 
 import com.takai.bigmodel.domain.entity.BmKnowledge;
-
 import java.util.List;
 
 /**

+ 0 - 3
takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/BmMediaReplacementMapper.java

@@ -1,9 +1,6 @@
 package com.takai.bigmodel.mapper;
 
 import com.takai.bigmodel.domain.entity.BmMediaReplacement;
-import com.takai.common.core.domain.entity.SysDictData;
-import org.apache.ibatis.annotations.Param;
-
 import java.util.List;
 
 /**

+ 0 - 2
takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/DialogMapper.java

@@ -3,8 +3,6 @@ package com.takai.bigmodel.mapper;
 import com.takai.bigmodel.domain.dto.DialogDetailReqDTO;
 import com.takai.bigmodel.domain.dto.DialogReqDTO;
 import com.takai.bigmodel.domain.dto.DialogRespDTO;
-import com.takai.bigmodel.domain.entity.BmApplication;
-
 import java.util.List;
 
 /**

+ 0 - 2
takai-bigmodel/src/main/java/com/takai/bigmodel/mapper/QuestionMapper.java

@@ -2,11 +2,9 @@ package com.takai.bigmodel.mapper;
 
 import com.takai.bigmodel.domain.dto.QuestionDTO;
 import com.takai.bigmodel.domain.entity.Question;
-
 import java.util.List;
 
 public interface QuestionMapper {
-
     List<QuestionDTO> getQuestionList(String appId);
 
     int insertQuestion(Question vo);

+ 3 - 0
takai-bigmodel/src/main/java/com/takai/bigmodel/service/IBigModelService.java

@@ -6,6 +6,8 @@ import com.takai.bigmodel.domain.dto.DialogReqDTO;
 import com.takai.bigmodel.domain.dto.DialogRespDTO;
 import com.takai.bigmodel.domain.dto.QuestionDTO;
 import com.takai.bigmodel.domain.entity.*;
+import com.takai.common.annotation.DataSource;
+import com.takai.common.enums.DataSourceType;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
 
@@ -17,6 +19,7 @@ import java.util.Map;
  * 
  * @author takai
  */
+@DataSource(value = DataSourceType.SLAVE)
 public interface IBigModelService
 {
 

+ 4 - 1
takai-bigmodel/src/main/java/com/takai/bigmodel/service/impl/BigModelServiceImpl.java

@@ -7,9 +7,11 @@ import com.takai.bigmodel.domain.dto.*;
 import com.takai.bigmodel.domain.entity.*;
 import com.takai.bigmodel.mapper.*;
 import com.takai.bigmodel.service.IBigModelService;
+import com.takai.common.annotation.DataSource;
 import com.takai.common.config.BigModelConfig;
 import com.takai.common.core.redis.RedisCache;
 import com.takai.common.enums.BackgroundColor;
+import com.takai.common.enums.DataSourceType;
 import com.takai.common.enums.IconImg;
 import com.takai.common.utils.uuid.IdUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -42,6 +44,7 @@ import java.util.stream.Collectors;
  */
 @Slf4j
 @Service
+@DataSource(DataSourceType.SLAVE)
 public class BigModelServiceImpl implements IBigModelService
 {
     @Autowired
@@ -298,7 +301,6 @@ public class BigModelServiceImpl implements IBigModelService
     }
 
 
-
     private void updateAppList(List<BmApplication> appList) {
         List<BmApplication>  dbList = bmApplicationMapper.selectApplicationList(null);
         for(BmApplication app : appList) {
@@ -358,6 +360,7 @@ public class BigModelServiceImpl implements IBigModelService
         }
     }
 
+
     private void updateImageList(List<BmMediaReplacement> imageList,String documentId) {
         BmMediaReplacement condition = BmMediaReplacement.builder().documentId(documentId).build();
         List<BmMediaReplacement>  dbList = bmMediaReplacementMapper.selectMediaList(condition);

+ 1 - 1
takai-bigmodel/src/main/resources/mapper/bm/BmApplicationMapper.xml

@@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		</where>
 		order by create_time asc
 	</select>
-	
+
 	<select id="selectTargetApplication" parameterType="BmApplication" resultMap="BmApplicationResult">
 		<include refid="selectSql"/>
 		where appId = #{appId}

+ 1 - 1
takai-bigmodel/src/main/resources/mapper/bm/DialogMapper.xml

@@ -17,7 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 	<resultMap type="String" id="DialogIdResult">
 		<id property="id"   column="id"   />
 	</resultMap>
-	
+
 	<sql id="selectSql">
         select id
 		from dialog

+ 1 - 1
takai-common/src/main/java/com/takai/common/annotation/DataSource.java

@@ -24,5 +24,5 @@ public @interface DataSource
     /**
      * 切换数据源名称
      */
-    public DataSourceType value() default DataSourceType.MASTER;
+    public DataSourceType value();
 }

+ 120 - 0
takai-common/src/main/java/com/takai/common/config/DeepseekConfig.java

@@ -0,0 +1,120 @@
+package com.takai.common.config;
+
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationProperties(prefix = "deepseek")
+public class DeepseekConfig {
+
+    private String baseurl;
+
+    private String createKnowledge;
+
+    private String deleteKnowledge;
+
+    private String slicePage;
+
+    private String deleteSlice;
+
+    private String sliceDetail;
+
+    private String updateSlice;
+
+    private String uploadKnowledge;
+
+    private String chat;
+
+    private String asyncCompletions;
+
+    private String prompt;
+
+    public String getBaseurl() {
+        return baseurl;
+    }
+
+    public void setBaseurl(String baseurl) {
+        this.baseurl = baseurl;
+    }
+
+    public String getCreateKnowledge() {
+        return createKnowledge;
+    }
+
+    public void setCreateKnowledge(String createKnowledge) {
+        this.createKnowledge = createKnowledge;
+    }
+
+    public String getDeleteKnowledge() {
+        return deleteKnowledge;
+    }
+
+    public void setDeleteKnowledge(String deleteKnowledge) {
+        this.deleteKnowledge = deleteKnowledge;
+    }
+
+    public String getSlicePage() {
+        return slicePage;
+    }
+
+    public void setSlicePage(String slicePage) {
+        this.slicePage = slicePage;
+    }
+
+    public String getDeleteSlice() {
+        return deleteSlice;
+    }
+
+    public void setDeleteSlice(String deleteSlice) {
+        this.deleteSlice = deleteSlice;
+    }
+
+    public String getSliceDetail() {
+        return sliceDetail;
+    }
+
+    public void setSliceDetail(String sliceDetail) {
+        this.sliceDetail = sliceDetail;
+    }
+
+    public String getUpdateSlice() {
+        return updateSlice;
+    }
+
+    public void setUpdateSlice(String updateSlice) {
+        this.updateSlice = updateSlice;
+    }
+
+    public String getUploadKnowledge() {
+        return uploadKnowledge;
+    }
+
+    public void setUploadKnowledge(String uploadKnowledge) {
+        this.uploadKnowledge = uploadKnowledge;
+    }
+
+    public String getChat() {
+        return chat;
+    }
+
+    public void setChat(String chat) {
+        this.chat = chat;
+    }
+
+    public String getAsyncCompletions() {
+        return asyncCompletions;
+    }
+
+    public String getPrompt() {
+        return prompt;
+    }
+
+    public void setPrompt(String prompt) {
+        this.prompt = prompt;
+    }
+
+    public void setAsyncCompletions(String asyncCompletions) {
+        this.asyncCompletions = asyncCompletions;
+    }
+}

+ 1 - 0
takai-common/src/main/java/com/takai/common/utils/PageUtils.java

@@ -32,4 +32,5 @@ public class PageUtils extends PageHelper
     {
         PageHelper.clearPage();
     }
+
 }

+ 1 - 1
takai-framework/src/main/java/com/takai/framework/config/DruidConfig.java

@@ -42,7 +42,7 @@ public class DruidConfig
 
     @Bean
     @ConfigurationProperties("spring.datasource.druid.slave")
-    @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
+//    @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
     public DataSource slaveDataSource(DruidProperties druidProperties)
     {
         DruidDataSource dataSource = DruidDataSourceBuilder.create().build();

+ 1 - 1
takai-framework/src/main/java/com/takai/framework/config/SecurityConfig.java

@@ -115,7 +115,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                         "/**/completions", "/**/slice_info/**", "/**/async_result/**", "/**/assistant/**", "/getInfo",
                         "/checkToken", "/**/presets/**", "/**/index/**", "/**/createApplaction/**", "/**/createKnowledge/**",
                         "/**/updateKnowledge/**", "/**/detailKnowledge/**", "/**/delKnowledge/**", "/**/knowledgeList/**",
-                        "/**//bigmodel/api/**", "/**/tool/gen/**").permitAll()
+                        "/**//bigmodel/api/**", "/**/tool/gen/**", "/**/takai/api/**").permitAll()
                 // 静态资源,可匿名访问
                 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
                 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

+ 4 - 0
takai-quartz/src/main/java/com/takai/quartz/service/impl/SysJobServiceImpl.java

@@ -2,6 +2,9 @@ package com.takai.quartz.service.impl;
 
 import java.util.List;
 import javax.annotation.PostConstruct;
+
+import com.takai.common.annotation.DataSource;
+import com.takai.common.enums.DataSourceType;
 import org.quartz.JobDataMap;
 import org.quartz.JobKey;
 import org.quartz.Scheduler;
@@ -35,6 +38,7 @@ public class SysJobServiceImpl implements ISysJobService
      * 项目启动时,初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据)
      */
     @PostConstruct
+    @DataSource(DataSourceType.SLAVE)
     public void init() throws SchedulerException, TaskException
     {
         scheduler.clear();

+ 1 - 1
takai-system/src/main/java/com/takai/system/service/impl/SysConfigServiceImpl.java

@@ -23,6 +23,7 @@ import com.takai.system.service.ISysConfigService;
  * @author takai
  */
 @Service
+@DataSource(DataSourceType.MASTER)
 public class SysConfigServiceImpl implements ISysConfigService
 {
     @Autowired
@@ -47,7 +48,6 @@ public class SysConfigServiceImpl implements ISysConfigService
      * @return 参数配置信息
      */
     @Override
-    @DataSource(DataSourceType.MASTER)
     public SysConfig selectConfigById(Long configId)
     {
         SysConfig config = new SysConfig();