Commit 3994edc5 authored by 林洋洋's avatar 林洋洋

调整项目结构

parent 3e02f69c
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="pig-upms-biz" />
<module name="pig-common-security" />
<module name="pig-common-core" />
<module name="pig-upms-api" />
<module name="ask-biz" />
<module name="pig-common-excel" />
<module name="pig-common-xss" />
<module name="pig-common-seata" />
<module name="pig-common-feign" />
<module name="pig-common-mybatis" />
<module name="pig-common-swagger" />
<module name="ask-api" />
<module name="pig-common-oss" />
<module name="pig-common-log" />
<module name="pig-common-datasource" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="ask" target="17" />
<module name="pig-auth" target="17" />
<module name="pig-boot" target="17" />
<module name="pig-common" target="17" />
<module name="pig-upms" target="17" />
</bytecodeTargetLevel>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="ask" options="-parameters" />
<module name="ask-api" options="-parameters" />
<module name="ask-biz" options="-parameters" />
<module name="pig" options="-parameters" />
<module name="pig-auth" options="-parameters" />
<module name="pig-boot" options="-parameters" />
<module name="pig-common" options="-parameters" />
<module name="pig-common-core" options="-parameters" />
<module name="pig-common-datasource" options="-parameters" />
<module name="pig-common-excel" options="-parameters" />
<module name="pig-common-feign" options="-parameters" />
<module name="pig-common-log" options="-parameters" />
<module name="pig-common-mybatis" options="-parameters" />
<module name="pig-common-oss" options="-parameters" />
<module name="pig-common-seata" options="-parameters" />
<module name="pig-common-security" options="-parameters" />
<module name="pig-common-swagger" options="-parameters" />
<module name="pig-common-xss" options="-parameters" />
<module name="pig-upms" options="-parameters" />
<module name="pig-upms-api" options="-parameters" />
<module name="pig-upms-biz" options="-parameters" />
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/pig-ask/pig-ask-api/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-ask/pig-ask-api/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-ask/pig-ask-biz/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-ask/pig-ask-biz/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-ask/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-ask/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-auth/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-auth/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-boot/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-boot/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-bom/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-bom/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-core/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-core/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-datasource/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-datasource/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-excel/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-excel/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-feign/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-feign/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-log/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-log/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-mybatis/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-mybatis/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-oss/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-oss/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-seata/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-seata/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-security/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-security/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-swagger/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-swagger/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-xss/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/pig-common-xss/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-upms/pig-upms-api/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-upms/pig-upms-api/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-upms/pig-upms-biz/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-upms/pig-upms-biz/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-upms/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/pig-upms/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central-portal-snapshots" />
<option name="name" value="Central Portal Snapshots" />
<option name="url" value="https://central.sonatype.com/repository/maven-snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="spring-snapshots" />
<option name="name" value="Spring Snapshots" />
<option name="url" value="https://repo.spring.io/snapshot" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
<option name="ignoredFiles">
<set>
<option value="$PROJECT_DIR$/pig-auth/pom.xml" />
<option value="$PROJECT_DIR$/pig-boot/pom.xml" />
<option value="$PROJECT_DIR$/pig-common/pom.xml" />
<option value="$PROJECT_DIR$/pig-upms/pom.xml" />
</set>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="ms-17" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="ask-data-ai-api" />
<module name="ask-data-ai-biz" />
<module name="ask-data-ai-boot" />
<module name="ask-data-ai-common" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="ask-data-ai" options="-parameters" />
<module name="ask-data-ai-api" options="-parameters" />
<module name="ask-data-ai-biz" options="-parameters" />
<module name="ask-data-ai-boot" options="-parameters" />
<module name="ask-data-ai-common" options="-parameters" />
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/ask-data-ai-api/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ask-data-ai-api/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ask-data-ai-biz/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ask-data-ai-biz/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ask-data-ai-boot/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ask-data-ai-boot/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ask-data-ai-common/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ask-data-ai-common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central-portal-snapshots" />
<option name="name" value="Central Portal Snapshots" />
<option name="url" value="https://central.sonatype.com/repository/maven-snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="spring-snapshots" />
<option name="name" value="Spring Snapshots" />
<option name="url" value="https://repo.spring.io/snapshot" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="ms-17" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
artifactId=ask-data-ai-api
groupId=com.ask
version=1.0.0-SNAPSHOT
com\ask\api\entity\GenTableColumnEntity.class
com\ask\api\entity\GenTable.class
com\ask\api\entity\ChatConversation.class
com\ask\api\dto\DocumentSegmentResult.class
com\ask\api\entity\GenDatasourceConf.class
com\ask\api\entity\KnowledgeBase.class
com\ask\api\entity\KnowledgeDocument.class
com\ask\api\dto\TableParam.class
com\ask\api\dto\TableDto.class
com\ask\api\entity\ChatConversationDetail.class
com\ask\api\dto\DocumentSegmentResult$DocumentSegment.class
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\entity\GenTable.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\dto\DocumentSegmentResult.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\entity\GenDatasourceConf.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\entity\GenTableColumnEntity.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\entity\ChatConversation.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\dto\TableDto.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\entity\KnowledgeDocument.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\entity\KnowledgeBase.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\dto\TableParam.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-api\src\main\java\com\ask\api\entity\ChatConversationDetail.java
artifactId=ask-data-ai-biz
groupId=com.ask
version=1.0.0-SNAPSHOT
com\ask\service\KnowledgeBaseService.class
com\ask\controller\ChatConversationController.class
com\ask\service\KnowledgeDocumentService.class
com\ask\config\PostgresChatMemoryDialect.class
com\ask\controller\KnowledgeDocumentController.class
com\ask\mapper\ChatConversationDetailMapper.class
com\ask\service\impl\ChatConversationServiceImpl.class
com\ask\service\ChatConversationService.class
com\ask\config\CommonConfiguration.class
com\ask\mapper\ChatConversationMapper.class
com\ask\service\impl\KnowledgeBaseServiceImpl.class
com\ask\service\impl\KnowledgeDocumentServiceImpl.class
com\ask\mapper\KnowledgeBaseMapper.class
com\ask\controller\ChatController.class
com\ask\controller\ChatConversationDetailController.class
com\ask\controller\KnowledgeBaseController.class
com\ask\mapper\KnowledgeDocumentMapper.class
com\ask\service\ChatConversationDetailService.class
com\ask\config\AsyncConfig.class
com\ask\service\impl\ChatConversationDetailServiceImpl.class
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\impl\KnowledgeBaseServiceImpl.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\config\CommonConfiguration.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\mapper\GenDatasourceConfMapper.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\GenDatasourceConfService.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\controller\KnowledgeBaseController.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\controller\ChatConversationDetailController.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\config\PostgresChatMemoryDialect.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\ChatConversationDetailService.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\controller\KnowledgeDocumentController.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\config\InitDataBase.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\mapper\GenTableMapper.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\impl\ChatConversationServiceImpl.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\mapper\ChatConversationMapper.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\KnowledgeDocumentService.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\impl\KnowledgeDocumentServiceImpl.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\mapper\KnowledgeDocumentMapper.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\config\AsyncConfig.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\ChatConversationService.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\GenTableService.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\mapper\ChatConversationDetailMapper.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\impl\GenDatasourceConfServiceImpl.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\VectorStoreService.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\impl\GenTableServiceImpl.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\controller\ChatConversationController.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\KnowledgeBaseService.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\impl\VectorStoreServiceImpl.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\service\impl\ChatConversationDetailServiceImpl.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\mapper\KnowledgeBaseMapper.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-biz\src\main\java\com\ask\controller\ChatController.java
server:
port: 9999
servlet:
context-path: /admin # 项目访问路径
spring:
application:
name: ask-data-ai
datasource:
url: jdbc:postgresql://81.70.183.25:25432/ask_data_ai_db
username: postgres
password: postgres123
driver-class-name: org.postgresql.Driver
ai:
vectorstore:
pgvector:
index-type: HNSW
distance-type: COSINE_DISTANCE
dimensions: 1024
max-document-batch-size: 10000 # Optional: Maximum number of documents per batch
schema-name: public
table-name: ask_vector_store
chat:
memory:
repository:
jdbc:
initialize-schema: never # 开发环境可以使用 always,方便调试
platform: postgresql
openai:
base-url: https://dashscope.aliyuncs.com/compatible-mode
api-key: sk-ae96ff281ff644c992843c64a711a950
chat:
options:
model: qwen-plus
embedding:
base-url: https://dashscope.aliyuncs.com/compatible-mode
api-key: sk-ae96ff281ff644c992843c64a711a950
options:
model: text-embedding-v4
mybatis-plus:
mapper-locations: classpath*:/mapper/*Mapper.xml # mapper文件位置
global-config:
banner: false # 是否打印 mybatis-plus banner
db-config:
id-type: auto # 主键类型
where-strategy: not_empty # where 条件策略
insert-strategy: not_empty # 插入策略
update-strategy: not_null # 更新策略
type-handlers-package: com.ask.common.mybatis.handler # 类型处理器包
configuration:
jdbc-type-for-null: 'null' # 是否设置字段为null
call-setters-on-nulls: true # 是否调用set方法时传入null值
shrink-whitespaces-in-sql: true # 去掉sql中多余的空格报错
# springdoc-openapi项目配置
springdoc:
swagger-ui:
enabled: true # 开启swagger-ui
path: /swagger-ui.html # 配置访问路径
api-docs:
enabled: true # 开启api-docs
path: /v3/api-docs # 配置访问路径
group-configs:
- group: 'default'
paths-to-match: '/**'
packages-to-scan: com.ask
default-produces-media-type: application/json
default-consumes-media-type: application/json
# knife4j的增强配置,不需要增强可以不配
knife4j:
enable: true
setting:
language: zh_cn
enable-swagger-models: true
enable-document-manage: true
swagger-model-name: 实体类列表
enable-version: false
enable-reload-cache-parameter: false
enable-after-script: false
enable-filter-multipart-api-method-type: POST
enable-filter-multipart-apis: false
enable-request-cache: true
enable-host: false
enable-host-text:
# swagger配置
swagger:
enabled: true
title: Ask Data AI接口文档
gateway: http://localhost:${server.port}/admin
token-url: ${swagger.gateway}/oauth2/token
scope: server
# 日志配置
logging:
level:
root: INFO
com.ask: DEBUG
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 -->
<property name="LOG_HOME" value="logs" />
<!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />-->
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n</pattern>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<FileNamePattern>${LOG_HOME}/ask-%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数 -->
<MaxHistory>30</MaxHistory>
<maxFileSize>10MB</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
</encoder>
</appender>
<!-- 每天生成一个html格式的日志结束 -->
<!--myibatis log configure -->
<logger name="com.apache.ibatis" level="TRACE" />
<logger name="java.sql.Connection" level="DEBUG" />
<logger name="java.sql.Statement" level="DEBUG" />
<logger name="java.sql.PreparedStatement" level="DEBUG" />
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
<logger name="okhttp3" level="ERROR"/>
</configuration>
\ No newline at end of file
artifactId=ask-data-ai-boot
groupId=com.ask
version=1.0.0-SNAPSHOT
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-boot\src\main\java\com\ask\AskDataAiApplication.java
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
swagger: swagger:
enabled: true enabled: true
title: Pig Swagger API title: Pig Swagger API
gateway: http://${GATEWAY-HOST:127.0.0.1}:${GATEWAY-PORT:9999} gateway: http://${GATEWAY-HOST:127.0.0.1}:${GATEWAY-PORT:9999}/admin
token-url: ${swagger.gateway}/admin/oauth2/token token-url: ${swagger.gateway}/admin/oauth2/token
scope: server scope: server
artifactId=ask-data-ai-common
groupId=com.ask
version=1.0.0-SNAPSHOT
com\ask\common\config\CorsConfig.class
com\ask\common\config\MybatisPlusConfig.class
com\ask\common\core\R.class
com\ask\common\factory\YamlPropertySourceFactory.class
com\ask\common\mybatis\handler\MybatisMetaObjectHandler.class
com\ask\common\base\BaseEntity.class
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-common\src\main\java\com\ask\common\core\R.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-common\src\main\java\com\ask\common\mybatis\handler\MybatisMetaObjectHandler.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-common\src\main\java\com\ask\common\config\MybatisPlusConfig.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-common\src\main\java\com\ask\common\factory\YamlPropertySourceFactory.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-common\src\main\java\com\ask\common\mybatis\handler\JsonTypeHandler.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-common\src\main\java\com\ask\common\config\CorsConfig.java
D:\java\ask_data_ai\pig-master\ask-data-ai\ask-data-ai-common\src\main\java\com\ask\common\base\BaseEntity.java
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
# 忽略匹配下列规则的Git 提交 V2.1.0
### gradle ###
.gradle
/build/
!gradle/wrapper/gradle-wrapper.jar
### STS ###
.settings/
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
bin/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
*.lock
rebel.xml
### NetBeans ###
nbproject/private/
build/
nbbuild/
nbdist/
.nb-gradle/
### maven ###
target/
*.war
*.ear
*.zip
*.tar
*.tar.gz
### logs ####
/logs/
*.log
### temp ignore ###
*.cache
*.diff
*.patch
*.tmp
*.java~
*.properties~
*.xml~
### system ignore ###
.DS_Store
Thumbs.db
Servers
.metadata
upload
gen_code
### node ###
node_modules
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-ask</artifactId>
<version>${revision}</version>
</parent>
<artifactId>pig-ask-api</artifactId>
<packaging>jar</packaging>
<description>ask 接口模块</description>
<dependencies>
<!--feign 注解依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
<optional>true</optional>
</dependency>
<!--mybatis 依赖-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-mybatis</artifactId>
</dependency>
<!-- excel 导入导出 https://github.com/pig-mesh/excel-spring-boot-starter -->
<dependency>
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>
package com.pig4cloud.pig.ask.api.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
/**
* 文档分段结果DTO
*
* @author ai
* @date 2024/12/19
*/
@Data
@Schema(description = "文档分段结果")
public class DocumentSegmentResult {
/**
* 文件名
*/
@Schema(description = "文件名")
private String fileName;
/**
* 文档分段列表
*/
@Schema(description = "文档分段列表")
private List<DocumentSegment> segments;
/**
* 总分段数
*/
@Schema(description = "总分段数")
private Integer totalSegments;
/**
* 文档总字符数
*/
@Schema(description = "文档总字符数")
private Integer totalCharacters;
/**
* 文档分段详情
*/
@Data
@Schema(description = "文档分段详情")
public static class DocumentSegment {
/**
* 分段序号
*/
@Schema(description = "分段序号")
private Integer index;
/**
* 分段内容
*/
@Schema(description = "分段内容")
private String content;
/**
* 分段字符数
*/
@Schema(description = "分段字符数")
private Integer charCount;
/**
* 分段token数(预估)
*/
@Schema(description = "分段token数(预估)")
private Integer tokenCount;
}
}
\ No newline at end of file
package com.pig4cloud.pig.ask.api.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class TableDto {
/**
* 表名
*/
@Schema(description = "表名")
private String tableName;
/**
* 表名
*/
@Schema(description = "表注释")
private String tableComment;
}
package com.pig4cloud.pig.ask.api.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class TableParam {
@Schema(description = "数据源名称")
private String dsName;
/**
* 数据源类型
*/
@Schema(description = "数据源类型")
private String dbType;
/**
* 表名
*/
@Schema(description = "表名")
private String tableName;
}
package com.pig4cloud.pig.ask.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.pig4cloud.pig.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 对话记录实体
*
* @author ai
* @date 2024/03/21
*/
@Data
@TableName("ask_chat_conversation")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "对话记录")
public class ChatConversation extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(type = IdType.AUTO)
@Schema(description = "主键ID")
private Long id;
/**
* 会话ID
*/
@Schema(description = "会话ID")
private String conversationId;
/**
* 标题
*/
@Schema(description = "标题")
private String title;
/**
* 智能体ID
*/
@Schema(description = "智能体ID")
private Integer agentId;
/**
* 用户ID
*/
@Schema(description = "用户ID")
private Long userId;
/**
* 删除标记,0未删除,1已删除
*/
@TableLogic
private String delFlag;
}
\ No newline at end of file
package com.pig4cloud.pig.ask.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* AI对话记忆存储实体
*
* @author ai
* @date 2024/03/21
*/
@Data
@TableName("ask_chat_conversation_detail")
@Schema(description = "AI对话记忆存储")
public class ChatConversationDetail {
/**
* 主键ID
*/
@TableId(type = IdType.AUTO)
@Schema(description = "主键ID")
private Long id;
/**
* 会话ID
*/
@Schema(description = "会话ID")
private String conversationId;
/**
* 消息内容
*/
@Schema(description = "消息内容")
private String content;
/**
* 消息类型(user/assistant)
*/
@Schema(description = "消息类型")
private String type;
/**
* 时间戳
*/
@Schema(description = "时间戳")
private LocalDateTime timestamp;
/**
* 删除标记,0未删除,1已删除
*/
@TableLogic
private String delFlag;
}
\ No newline at end of file
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pig.ask.api.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 数据源表
*
* @author lengleng
* @date 2019-03-31 16:00:20
*/
@Data
@TableName("gen_datasource_conf")
@EqualsAndHashCode(callSuper = true)
public class GenDatasourceConf extends Model<GenDatasourceConf> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 名称
*/
private String name;
/**
* 数据库类型
*/
private String dsType;
/**
* 配置类型 (0 主机形式 | 1 url形式)
*/
private Integer confType;
/**
* 主机地址
*/
private String host;
/**
* 端口
*/
private Integer port;
/**
* jdbc-url
*/
private String url;
/**
* 实例
*/
private String instance;
/**
* 数据库名称
*/
private String dsName;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* 修改时间
*/
@TableField(fill = FieldFill.UPDATE)
private LocalDateTime updateTime;
/**
* 0-正常,1-删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
private String delFlag;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pig.ask.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
import java.util.List;
/**
* 列属性
*
* @author pigx code generator
* @date 2023-02-06 20:34:55
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "列属性")
public class GenTable extends Model<GenTable> {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.AUTO)
@Schema(description = "id")
private Long id;
/**
* 数据源名称
*/
@Schema(description = "数据源名称")
private String dsName;
/**
* 数据源类型
*/
@Schema(description = "数据源类型")
private String dbType;
/**
* 表名
*/
@Schema(description = "表名")
private String tableName;
/**
* 类名
*/
@Schema(description = "类名")
private String className;
/**
* 说明
*/
@Schema(description = "说明")
private String tableComment;
/**
* 作者
*/
@Schema(description = "作者")
private String author;
/**
* 邮箱
*/
@Schema(description = "邮箱")
private String email;
/**
* 项目包名
*/
@Schema(description = "项目包名")
private String packageName;
/**
* 项目版本号
*/
@Schema(description = "项目版本号")
private String version;
/**
* 生成方式 0:zip压缩包 1:自定义目录
*/
@Schema(description = "生成方式 0:zip压缩包 1:自定义目录")
private String generatorType;
/**
* 后端生成路径
*/
@Schema(description = "后端生成路径")
private String backendPath;
/**
* 前端生成路径
*/
@Schema(description = "前端生成路径")
private String frontendPath;
/**
* 模块名
*/
@Schema(description = "模块名")
private String moduleName;
/**
* 功能名
*/
@Schema(description = "功能名")
private String functionName;
/**
* 表单布局 1:一列 2:两列
*/
@Schema(description = "表单布局 1:一列 2:两列")
private Integer formLayout;
/**
* 基类ID
*/
@Schema(description = "基类ID")
private Long baseclassId;
/**
* 创建时间
*/
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 代码生成风格
*/
private Long style;
/**
* 子表名称
*/
private String childTableName;
/**
* 主表关联键
*/
private String mainField;
/**
* 子表关联键
*/
private String childField;
// /**
// * 字段列表
// */
// @TableField(exist = false)
// private List<GenTableColumnEntity> fieldList;
//
// /**
// * 子表字段列表
// */
// @TableField(exist = false)
// private List<GenTableColumnEntity> childFieldList;
// /**
// * 代码风格(模版分组信息)
// */
// @TableField(exist = false)
// private List<GenGroupEntity> groupList;
}
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pig.ask.api.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author lengleng
* @date 2023-02-06
*
* 记录表字段的配置信息
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class GenTableColumnEntity extends Model<GenDatasourceConf> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 数据源名
*/
private String dsName;
/**
* 表名称
*/
private String tableName;
/**
* 字段名称
*/
private String fieldName;
/**
* 排序
*/
private Integer sort;
/**
* 字段类型
*/
private String fieldType;
/**
* 字段说明
*/
private String fieldComment;
/**
* 属性名
*/
private String attrName;
/**
* 属性类型
*/
private String attrType;
/**
* 属性包名
*/
private String packageName;
/**
* 自动填充
*/
private String autoFill;
/**
* 主键 0:否 1:是
*/
private String primaryPk;
/**
* 基类字段 0:否 1:是
*/
private String baseField;
/**
* 表单项 0:否 1:是
*/
private String formItem;
/**
* 表单必填 0:否 1:是
*/
private String formRequired;
/**
* 表单类型
*/
private String formType;
/**
* 表单效验
*/
private String formValidator;
/**
* 列表项 0:否 1:是
*/
private String gridItem;
/**
* 列表排序 0:否 1:是
*/
private String gridSort;
/**
* 查询项 0:否 1:是
*/
private String queryItem;
/**
* 查询方式
*/
private String queryType;
/**
* 查询表单类型
*/
private String queryFormType;
/**
* 字段字典类型
*/
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String fieldDict;
}
package com.pig4cloud.pig.ask.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.pig4cloud.pig.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 知识库实体
*
* @author ai
* @date 2024/12/19
*/
@Data
@TableName("ask_knowledge_base")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "知识库")
public class KnowledgeBase extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(type = IdType.AUTO)
@Schema(description = "主键ID")
private Long id;
/**
* 知识库名称
*/
@Schema(description = "知识库名称")
private String name;
/**
* 知识库描述
*/
@Schema(description = "知识库描述")
private String description;
/**
* 删除标记,0未删除,1已删除
*/
@TableLogic
@Schema(description = "删除标记")
private String delFlag;
}
\ No newline at end of file
package com.pig4cloud.pig.ask.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.pig4cloud.pig.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 知识库文档实体
*
* @author ai
* @date 2024/12/19
*/
@Data
@TableName("ask_knowledge_document")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "知识库文档")
public class KnowledgeDocument extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(type = IdType.AUTO)
@Schema(description = "主键ID")
private Long id;
/**
* 知识库ID
*/
@Schema(description = "知识库ID")
private Long knowledgeBaseId;
/**
* 文档名称
*/
@Schema(description = "文档名称")
private String name;
/**
* 原始文件名
*/
@Schema(description = "原始文件名")
private String fileName;
/**
* 文件存储路径
*/
@Schema(description = "文件存储路径")
private String filePath;
/**
* 文件大小(字节)
*/
@Schema(description = "文件大小(字节)")
private Long fileSize;
/**
* 文件类型
*/
@Schema(description = "文件类型")
private String fileType;
/**
* 处理状态:0-待处理,1-处理中,2-处理完成,3-处理失败
*/
@Schema(description = "处理状态:0-待处理,1-处理中,2-处理完成,3-处理失败")
private Integer status;
/**
* 分段数量
*/
@Schema(description = "分段数量")
private Integer segmentCount;
/**
* 总token数量
*/
@Schema(description = "总token数量")
private Integer tokenCount;
/**
* 删除标记,0未删除,1已删除
*/
@TableLogic
@Schema(description = "删除标记")
private String delFlag;
}
\ No newline at end of file
package com.pig4cloud.pig.ask.api.enums;
/**
* 字段自动填充 枚举
*
* @author 阿沐 babamu@126.com
*/
public enum AutoFillEnum {
DEFAULT, INSERT, UPDATE, INSERT_UPDATE, CREATE;
}
package com.pig4cloud.pig.ask.api.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* boolean 类型枚举
*
*/
@Getter
@RequiredArgsConstructor
public enum BoolFillEnum {
/**
* true
*/
TRUE("1"),
/**
* false
*/
FALSE("0");
private final String value;
}
package com.pig4cloud.pig.ask.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author lengleng
* @date 2023/3/12
* <p>
* 通用字段的填充策略和显示策略
*/
@Getter
@AllArgsConstructor
public enum CommonColumnFiledEnum {
/**
* create_by 字段
*/
create_by("0", "0", AutoFillEnum.INSERT.name(), 100),
/**
* create_time 字段
*/
create_time("0", "0", AutoFillEnum.INSERT.name(), 101),
/**
* update_by 字段
*/
update_by("0", "0", AutoFillEnum.INSERT_UPDATE.name(), 102),
/**
* update_time 字段
*/
update_time("0", "0", AutoFillEnum.INSERT_UPDATE.name(), 103),
/**
* del_flag 字段
*/
del_flag("0", "0", AutoFillEnum.DEFAULT.name(), 104),
/**
* tenant_id 字段
*/
tenant_id("0", "0", AutoFillEnum.DEFAULT.name(), 105);
/**
* 表单是否默认显示 1/0
*/
private String formItem;
/**
* 表格是否默认显示 1/0
*/
private String gridItem;
/**
* 自动填充策略
*/
private String autoFill;
/**
* 排序值
*/
private Integer sort;
}
FROM registry.cn-hangzhou.aliyuncs.com/dockerhub_mirror/java:21-anolis
RUN mkdir -p /ask
WORKDIR /ask
ARG JAR_FILE=target/ask-biz.jar
COPY ${JAR_FILE} app.jar
EXPOSE 7001
ENV TZ=Asia/Shanghai JAVA_OPTS="-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom"
CMD sleep 60; java $JAVA_OPTS -jar app.jar
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-ask</artifactId>
<version>${revision}</version>
</parent>
<artifactId>pig-ask-biz</artifactId>
<packaging>jar</packaging>
<description>pig AI智能问答管理模块</description>
<properties>
<spring-ai.version>1.1.0-SNAPSHOT</spring-ai.version>
<anyline.version>8.7.2-jdk17-20240808</anyline.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- ask api、model 模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-ask-api</artifactId>
</dependency>
<!--文件管理-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-oss</artifactId>
</dependency>
<!--feign 调用-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-feign</artifactId>
</dependency>
<!--安全模块-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-security</artifactId>
</dependency>
<!--日志处理-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-log</artifactId>
</dependency>
<!--接口文档-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-swagger</artifactId>
</dependency>
<!-- orm 模块-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
</dependency>
<!--数据操作-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-mybatis</artifactId>
</dependency>
<!--动态数据源 数据操作-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-datasource</artifactId>
</dependency>
<!--mybatis-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- PostgreSQL驱动 -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!--注册中心客户端-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!--配置中心客户端-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- 短信下发 -->
<dependency>
<groupId>org.dromara.sms4j</groupId>
<artifactId>sms4j-spring-boot-starter</artifactId>
</dependency>
<!--xss 过滤-->
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pig-common-xss</artifactId>
</dependency>
<!--undertow容器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<dependency>
<groupId>org.anyline</groupId>
<artifactId>anyline-environment-spring-data-jdbc</artifactId>
<version>${anyline.version}</version>
</dependency>
<dependency>
<groupId>org.anyline</groupId>
<artifactId>anyline-data-jdbc-mysql</artifactId>
<version>${anyline.version}</version>
</dependency>
<!-- AI模块-->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-openai</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-mcp-client-webflux</artifactId>
</dependency>
<!-- RAG-->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-vector-store-pgvector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-advisors-vector-store</artifactId>
</dependency>
<!--RAG相关依赖-->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-rag</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-tika-document-reader</artifactId>
</dependency>
<!-- 对话记忆-->
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-chat-memory-repository-jdbc</artifactId>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<name>Central Portal Snapshots</name>
<id>central-portal-snapshots</id>
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<profiles>
<profile>
<id>boot</id>
</profile>
<profile>
<id>cloud</id>
<activation>
<!-- 默认环境 -->
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.xlsx</exclude>
<exclude>**/*.xls</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.xlsx</include>
<include>**/*.xls</include>
</includes>
</resource>
</resources>
</build>
</project>
package com.pig4cloud.pig.ask;
import com.pig4cloud.pig.common.feign.annotation.EnablePigFeignClients;
import com.pig4cloud.pig.common.security.annotation.EnablePigResourceServer;
import com.pig4cloud.pig.common.swagger.annotation.EnablePigDoc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* @author pig archetype
* <p>
* 项目启动类
*/
@EnablePigDoc(value = "ask")
@EnablePigFeignClients
@EnablePigResourceServer
@EnableDiscoveryClient
@SpringBootApplication
public class AskApplication {
public static void main(String[] args) {
SpringApplication.run(AskApplication.class, args);
}
}
package com.pig4cloud.pig.ask.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 异步配置类
*
* @author ai
* @date 2024/12/19
*/
@Slf4j
@Configuration
@EnableAsync
public class AsyncConfig {
/**
* 向量化任务执行器
*/
@Bean("vectorizeExecutor")
public Executor vectorizeExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2);
executor.setMaxPoolSize(5);
executor.setQueueCapacity(100);
executor.setKeepAliveSeconds(60);
executor.setThreadNamePrefix("vectorize-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.setWaitForTasksToCompleteOnShutdown(true);
executor.setAwaitTerminationSeconds(60);
executor.initialize();
log.info("向量化任务执行器初始化完成");
return executor;
}
}
\ No newline at end of file
package com.pig4cloud.pig.ask.config;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.api.Advisor;
import org.springframework.ai.chat.client.advisor.vectorstore.QuestionAnswerAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.ChatMemoryRepository;
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
import org.springframework.ai.chat.memory.repository.jdbc.JdbcChatMemoryRepository;
import org.springframework.ai.chat.memory.repository.jdbc.PostgresChatMemoryRepositoryDialect;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.ai.rag.advisor.RetrievalAugmentationAdvisor;
import org.springframework.ai.rag.generation.augmentation.ContextualQueryAugmenter;
import org.springframework.ai.rag.retrieval.search.VectorStoreDocumentRetriever;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.vectorstore.SearchRequest;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.List;
@Configuration
public class CommonConfiguration {
@Bean
public ChatMemory chatMemory (JdbcTemplate jdbcTemplate,PostgresChatMemoryDialect postgresChatMemoryDialect) {
ChatMemoryRepository chatMemoryRepository = JdbcChatMemoryRepository.builder()
.jdbcTemplate(jdbcTemplate)
.dialect(postgresChatMemoryDialect)
.build();
return MessageWindowChatMemory.builder()
.chatMemoryRepository(chatMemoryRepository)
.maxMessages(10)
.build();
}
@Bean
public ChatClient chatClient(OpenAiChatModel model, ChatMemory chatMemory) {
List<Advisor> advisors = new ArrayList<>();
Advisor messageChatMemoryAdvisor =MessageChatMemoryAdvisor.builder(chatMemory).build();
advisors.add(messageChatMemoryAdvisor);
return ChatClient.builder(model)
.defaultAdvisors(advisors)
.defaultAdvisors().build();
}
@Bean
public RetrievalAugmentationAdvisor retrievalAugmentationAdvisor(VectorStore vectorStore) {
return RetrievalAugmentationAdvisor.builder()
.documentRetriever(VectorStoreDocumentRetriever.builder()
.similarityThreshold(0.60)
.topK(5)
.vectorStore(vectorStore)
.build())
.queryAugmenter(ContextualQueryAugmenter.builder()
.allowEmptyContext(true)
.build())
.build();
}
}
package com.pig4cloud.pig.ask.config;
import com.pig4cloud.pig.ask.api.entity.GenDatasourceConf;
import com.pig4cloud.pig.ask.service.GenDatasourceConfService;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class InitDataBase implements CommandLineRunner {
@Autowired
private GenDatasourceConfService genDatasourceConfService;
@Autowired
private StringEncryptor stringEncryptor;
@Override
public void run(String... args) throws Exception {
List<GenDatasourceConf> genDatasourceConfList = genDatasourceConfService.list();
genDatasourceConfList.forEach(conf->{
conf.setPassword(stringEncryptor.decrypt(conf.getPassword()));
genDatasourceConfService.addDynamicDataSource(conf);
});
}
}
package com.pig4cloud.pig.ask.config;
import com.pig4cloud.pig.common.security.util.SecurityUtils;
import org.springframework.ai.chat.memory.ChatMemoryRepository;
import org.springframework.ai.chat.memory.repository.jdbc.JdbcChatMemoryRepositoryDialect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class PostgresChatMemoryDialect implements JdbcChatMemoryRepositoryDialect {
@Override
public String getSelectMessagesSql() {
return "SELECT content, type FROM ask_chat_conversation_detail WHERE conversation_id = ? ORDER BY \"timestamp\"";
}
@Override
public String getInsertMessageSql() {
return "INSERT INTO ask_chat_conversation_detail (conversation_id, content, type, \"timestamp\") VALUES ( ?, ?, ?, ?)";
}
@Override
public String getSelectConversationIdsSql() {
return "SELECT DISTINCT conversation_id FROM ask_chat_conversation_detail";
}
@Override
public String getDeleteMessagesSql() {
return "UPDATE ask_chat_conversation_detail set del_flag = '1' WHERE conversation_id = ? ";
}
}
package com.pig4cloud.pig.ask.controller;
import com.alibaba.nacos.common.utils.UuidUtils;
import com.pig4cloud.pig.ask.api.entity.ChatConversation;
import com.pig4cloud.pig.ask.service.ChatConversationService;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.messages.SystemMessage;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.rag.advisor.RetrievalAugmentationAdvisor;
import org.springframework.ai.rag.generation.augmentation.ContextualQueryAugmenter;
import org.springframework.ai.rag.retrieval.search.VectorStoreDocumentRetriever;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.ai.vectorstore.filter.Filter;
import org.springframework.ai.vectorstore.filter.FilterExpressionBuilder;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.Arrays;
import java.util.UUID;
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/chat/ai")
@Tag(description = "ai", name = "AI对话模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ChatController {
private final ChatClient chatClient;
private final ChatConversationService chatConversationService;
private final RetrievalAugmentationAdvisor retrievalAugmentationAdvisor;
/**
* 获取会话ID
* @return 新的会话ID
*/
@Operation(summary = "创建对话", description = "创建对话")
@SysLog("创建对话")
@GetMapping("/create/client")
public R<ChatConversation> getConversationId(@RequestParam Integer agentId) {
ChatConversation chatConversation =new ChatConversation();
String conversationId=UuidUtils.generateUuid().replaceAll("-","");
chatConversation.setConversationId(conversationId);
chatConversation.setAgentId(agentId);
chatConversationService.save(chatConversation);
return R.ok(chatConversation);
}
/**
* 最基本的AI流式输出对话
*
* * @param message
* @return
*/
@Operation(summary = "普通对话", description = "普通对话")
@GetMapping(value = "/chat", produces = "text/html;charset=utf-8")
public Flux<String> chat(String message, String conversationId) {
// 创建系统消息,告诉大模型只返回工具名和参数
Message systemMessage = new SystemMessage("你是一个AI客服助手。请严格按照以下格式回答每个问题:");
// 用户消息
String question = "请严格按以下格式回答:\n" +
"<think>\n" +
"[你的逐步推理过程]\n" +
"</think>\n" +
"<answer>\n" +
"[最终答案]\n" +
"</answer>\n" +
"推理过程不要设计`<think>` 和 `<answer>` \n" +
"问题:"+message+"\n" ;
Message userMessage = new UserMessage(question);
// 创建提示,包含系统消息和用户消息
Prompt prompt = new Prompt(Arrays.asList(systemMessage, userMessage));
// 使用修改后的提示获取响应
return chatClient.prompt(prompt).advisors(a -> a.param(ChatMemory.CONVERSATION_ID, conversationId)).stream().content();
}
/**
* 最基本的AI流式输出对话
*
* * @param message
* @return
*/
@Operation(summary = "知识库对话", description = "知识库对话")
@GetMapping(value = "/rag/chat", produces = "text/html;charset=utf-8")
public Flux<String> ragChat(String message, String conversationId) {
// 创建系统消息,告诉大模型只返回工具名和参数
Message systemMessage = new SystemMessage("你是一个AI客服助手。请严格按照以下格式回答每个问题:");
Message userMessage = new UserMessage(message);
// 创建提示,包含系统消息和用户消息
Prompt prompt = new Prompt(Arrays.asList(systemMessage, userMessage));
// 使用修改后的提示获取响应
FilterExpressionBuilder builder = new FilterExpressionBuilder();
Filter.Expression filter = builder.eq("source","1").build();
return chatClient.prompt(prompt)
.advisors(a -> a.param(ChatMemory.CONVERSATION_ID, conversationId))
.advisors(a -> a.param(VectorStoreDocumentRetriever.FILTER_EXPRESSION, filter))
.advisors(retrievalAugmentationAdvisor)
.stream().content();
}
}
\ No newline at end of file
package com.pig4cloud.pig.ask.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.ask.api.entity.ChatConversation;
import com.pig4cloud.pig.ask.service.ChatConversationService;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
/**
* 对话记录管理
*
* @author ai
* @date 2024/03/21
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/chat/conversation")
@Tag(description = "conversation", name = "对话记录管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ChatConversationController {
private final ChatConversationService chatConversationService;
/**
* 分页查询
* @param page 分页对象
* @param chatConversation 查询条件
* @return 分页数据
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
public R<IPage<ChatConversation>> getPage(Page page, ChatConversation chatConversation) {
return R.ok(chatConversationService.page(page, Wrappers.query(chatConversation)));
}
/**
* 通过id查询对话记录
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
public R<ChatConversation> getById(@PathVariable("id") Long id) {
return R.ok(chatConversationService.getById(id));
}
/**
* 新增对话记录
* @param chatConversation 对话记录
* @return R
*/
@Operation(summary = "新增对话记录", description = "新增对话记录")
@SysLog("新增对话记录")
@PostMapping
public R<Boolean> save(@RequestBody ChatConversation chatConversation) {
return R.ok(chatConversationService.save(chatConversation));
}
/**
* 修改对话记录
* @param chatConversation 对话记录
* @return R
*/
@Operation(summary = "修改对话记录", description = "修改对话记录")
@SysLog("修改对话记录")
@PutMapping
public R<Boolean> updateById(@RequestBody ChatConversation chatConversation) {
return R.ok(chatConversationService.updateById(chatConversation));
}
/**
* 通过id删除对话记录
* @param id id
* @return R
*/
@Operation(summary = "通过id删除对话记录", description = "通过id删除对话记录")
@SysLog("通过id删除对话记录")
@DeleteMapping("/{id}")
public R<Boolean> removeById(@PathVariable Long id) {
return R.ok(chatConversationService.removeById(id));
}
}
\ No newline at end of file
package com.pig4cloud.pig.ask.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.ask.api.entity.ChatConversationDetail;
import com.pig4cloud.pig.ask.service.ChatConversationDetailService;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 对话详细记录管理
*
* @author ai
* @date 2024/03/21
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/chat/conversation/detail")
@Tag(description = "conversation-detail", name = "对话详细记录管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ChatConversationDetailController {
private final ChatConversationDetailService chatConversationDetailService;
/**
* 根据会话ID分页获取对话详情
* @param page 分页对象
* @param conversationId 会话ID
* @return 分页数据
*/
@Operation(summary = "根据会话ID分页获取对话详情", description = "根据会话ID分页获取对话详情")
@GetMapping("/page/{conversationId}")
public R<IPage<ChatConversationDetail>> pageByConversationId(Page page, @PathVariable String conversationId) {
IPage<ChatConversationDetail> result =chatConversationDetailService.page(page,Wrappers.<ChatConversationDetail>lambdaQuery()
.eq(ChatConversationDetail::getConversationId, conversationId)
.orderByAsc(ChatConversationDetail::getTimestamp));
return R.ok(result);
}
/**
* 根据会话ID获取对话详情列表
* @param conversationId 会话ID
* @return 对话详情列表
*/
@Operation(summary = "根据会话ID获取对话详情列表", description = "根据会话ID获取对话详情列表")
@GetMapping("/list/{conversationId}")
public R<List<ChatConversationDetail>> listByConversationId(@PathVariable String conversationId) {
return R.ok(chatConversationDetailService.list(Wrappers.<ChatConversationDetail>lambdaQuery()
.eq(ChatConversationDetail::getConversationId, conversationId)
.orderByAsc(ChatConversationDetail::getTimestamp)));
}
}
\ No newline at end of file
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pig.ask.controller;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.ask.api.entity.GenDatasourceConf;
import com.pig4cloud.pig.ask.service.GenDatasourceConfService;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.core.util.SpringContextHolder;
import com.pig4cloud.pig.common.security.annotation.Inner;
import com.pig4cloud.pig.common.xss.core.XssCleanIgnore;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import javax.sql.DataSource;
/**
* 数据源管理控制器
*
* @author lengleng
* @date 2025/05/31
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/dsconf")
public class GenDsConfController {
private final GenDatasourceConfService datasourceConfService;
/**
* 分页查询数据源配置
* @param page 分页参数对象
* @param datasourceConf 数据源配置查询条件
* @return 分页查询结果
*/
@GetMapping("/page")
public R getDsConfPage(Page page, GenDatasourceConf datasourceConf) {
return R.ok(datasourceConfService.page(page,
Wrappers.<GenDatasourceConf>lambdaQuery()
.like(StrUtil.isNotBlank(datasourceConf.getDsName()), GenDatasourceConf::getDsName,
datasourceConf.getDsName())));
}
/**
* 查询全部数据源列表
* @return 包含全部数据源列表的响应结果
*/
@GetMapping("/list")
@Inner(value = false)
public R listDsConfs() {
return R.ok(datasourceConfService.list());
}
/**
* 根据ID查询数据源表
* @param id 数据源ID
* @return 包含查询结果的响应对象
*/
@GetMapping("/{id}")
public R getDsConfById(@PathVariable("id") Long id) {
return R.ok(datasourceConfService.getById(id));
}
/**
* 新增数据源表
* @param datasourceConf 数据源配置信息
* @return 操作结果
*/
@PostMapping
@XssCleanIgnore
public R saveDsConf(@RequestBody GenDatasourceConf datasourceConf) {
return R.ok(datasourceConfService.saveDsByEnc(datasourceConf));
}
/**
* 修改数据源表
* @param conf 数据源表配置信息
* @return 操作结果
*/
@PutMapping
@XssCleanIgnore
public R updateDsConf(@RequestBody GenDatasourceConf conf) {
return R.ok(datasourceConfService.updateDsByEnc(conf));
}
/**
* 通过id数组删除数据源表
* @param ids 要删除的数据源id数组
* @return 包含操作结果的R对象
*/
@DeleteMapping
public R removeDsConfByIds(@RequestBody Long[] ids) {
return R.ok(datasourceConfService.removeByDsId(ids));
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment