From aa01f52535972b16e4aed9e08885d15956c4cdc7 Mon Sep 17 00:00:00 2001
From: Dallas98 <40557804+Dallas98@users.noreply.github.com>
Date: Tue, 11 Nov 2025 22:13:14 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=8B=89=E5=8F=96=E8=AF=B7?=
=?UTF-8?q?=E6=B1=82=20#74?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* feat: Implement system parameter management with Redis integration
---
README.md | 2 +-
backend/services/main-application/pom.xml | 4 ++
.../main/DataMatePlatformApplication.java | 2 +
.../src/main/resources/application.yml | 23 +++---
.../application/KnowledgeBaseService.java | 2 +-
.../event/DataInsertedEvent.java | 4 +-
.../infrastructure/event/RagEtlService.java | 8 +--
.../indexer/interfaces/dto/AddFilesReq.java | 3 +
backend/services/rag-query-service/pom.xml | 4 --
backend/shared/domain-common/pom.xml | 4 ++
.../ModelConfigApplicationService.java | 17 +++--
.../SysParamApplicationService.java | 70 +++++++++++++++++++
.../domain/entity/ModelConfig.java | 2 +-
.../domain/entity/ModelType.java | 2 +-
.../setting/domain/entity/SysParam.java | 57 +++++++++++++++
.../repository/ModelConfigRepository.java | 6 +-
.../domain/repository/SysParamRepository.java | 13 ++++
.../infrastructure/client/ModelClient.java | 6 +-
.../exception/ModelsErrorCode.java | 2 +-
.../impl/ModelConfigRepositoryImpl.java | 10 +--
.../impl/SysParamRepositoryImpl.java | 17 +++++
.../persistence/mapper/ModelConfigMapper.java | 4 +-
.../persistence/mapper/SysParamMapper.java | 15 ++++
.../rest/ModelConfigController.java | 10 +--
.../interfaces/rest/SysParamController.java | 52 ++++++++++++++
.../rest/dto/CreateModelRequest.java | 4 +-
.../rest/dto/QueryModelRequest.java | 4 +-
deployment/docker/datamate/docker-compose.yml | 9 +++
scripts/db/model-management-init.sql | 19 -----
scripts/db/setting-management-init.sql | 41 +++++++++++
30 files changed, 343 insertions(+), 73 deletions(-)
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/application/ModelConfigApplicationService.java (86%)
create mode 100644 backend/shared/domain-common/src/main/java/com/datamate/common/setting/application/SysParamApplicationService.java
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/domain/entity/ModelConfig.java (94%)
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/domain/entity/ModelType.java (79%)
create mode 100644 backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/SysParam.java
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/domain/repository/ModelConfigRepository.java (71%)
create mode 100644 backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/repository/SysParamRepository.java
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/infrastructure/client/ModelClient.java (91%)
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/infrastructure/exception/ModelsErrorCode.java (91%)
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/infrastructure/persistence/impl/ModelConfigRepositoryImpl.java (78%)
create mode 100644 backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/impl/SysParamRepositoryImpl.java
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/infrastructure/persistence/mapper/ModelConfigMapper.java (66%)
create mode 100644 backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/mapper/SysParamMapper.java
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/interfaces/rest/ModelConfigController.java (87%)
create mode 100644 backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/SysParamController.java
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/interfaces/rest/dto/CreateModelRequest.java (89%)
rename backend/shared/domain-common/src/main/java/com/datamate/common/{models => setting}/interfaces/rest/dto/QueryModelRequest.java (80%)
delete mode 100644 scripts/db/model-management-init.sql
create mode 100644 scripts/db/setting-management-init.sql
diff --git a/README.md b/README.md
index 3dce053..16f1d49 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@



-
+
**DataMate is an enterprise-level data processing platform for model fine-tuning and RAG retrieval, supporting core
functions such as data collection, data management, operator marketplace, data cleaning, data synthesis, data
diff --git a/backend/services/main-application/pom.xml b/backend/services/main-application/pom.xml
index 4f180de..23a72d4 100644
--- a/backend/services/main-application/pom.xml
+++ b/backend/services/main-application/pom.xml
@@ -134,6 +134,10 @@
org.springframework.boot
spring-boot-autoconfigure
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
diff --git a/backend/services/main-application/src/main/java/com/datamate/main/DataMatePlatformApplication.java b/backend/services/main-application/src/main/java/com/datamate/main/DataMatePlatformApplication.java
index 3cf215c..f570ff3 100644
--- a/backend/services/main-application/src/main/java/com/datamate/main/DataMatePlatformApplication.java
+++ b/backend/services/main-application/src/main/java/com/datamate/main/DataMatePlatformApplication.java
@@ -3,6 +3,7 @@ package com.datamate.main;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@EnableAsync
@EnableScheduling
+@EnableCaching
public class DataMatePlatformApplication {
public static void main(String[] args) {
SpringApplication.run(DataMatePlatformApplication.class, args);
diff --git a/backend/services/main-application/src/main/resources/application.yml b/backend/services/main-application/src/main/resources/application.yml
index f70a819..b6fed0d 100644
--- a/backend/services/main-application/src/main/resources/application.yml
+++ b/backend/services/main-application/src/main/resources/application.yml
@@ -22,14 +22,6 @@ spring:
idle-timeout: 600000
max-lifetime: 1800000
- # Elasticsearch配置
- elasticsearch:
- uris: ${ES_URIS:http://localhost:9200}
- username: ${ES_USERNAME:}
- password: ${ES_PASSWORD:}
- connection-timeout: 10s
- socket-timeout: 30s
-
# Jackson配置
jackson:
time-zone: Asia/Shanghai
@@ -61,6 +53,21 @@ spring:
- classpath:config/application-datacollection.yml
- classpath:config/application-datamanagement.yml
+ # Redis配置
+ data:
+ redis:
+ host: datamate-redis
+ port: 6379
+ timeout: 2000
+ password: ${REDIS_PASSWORD:password}
+ lettuce:
+ pool:
+ max-active: 20
+ max-idle: 10
+ min-idle: 5
+ max-wait: 1000ms
+
+
# MyBatis配置(需在顶层,不在 spring 下)
mybatis-plus:
configuration:
diff --git a/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/application/KnowledgeBaseService.java b/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/application/KnowledgeBaseService.java
index 0c10cfd..1d97a84 100644
--- a/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/application/KnowledgeBaseService.java
+++ b/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/application/KnowledgeBaseService.java
@@ -99,7 +99,7 @@ public class KnowledgeBaseService {
return ragFile;
}).toList();
ragFileRepository.saveBatch(ragFiles, 100);
- eventPublisher.publishEvent(new DataInsertedEvent(knowledgeBase, request.getProcessType()));
+ eventPublisher.publishEvent(new DataInsertedEvent(knowledgeBase, request));
}
public PagedResponse listFiles(String knowledgeBaseId, RagFileReq request) {
diff --git a/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/infrastructure/event/DataInsertedEvent.java b/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/infrastructure/event/DataInsertedEvent.java
index af749b2..a4c75ec 100644
--- a/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/infrastructure/event/DataInsertedEvent.java
+++ b/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/infrastructure/event/DataInsertedEvent.java
@@ -1,7 +1,7 @@
package com.datamate.rag.indexer.infrastructure.event;
import com.datamate.rag.indexer.domain.model.KnowledgeBase;
-import com.datamate.rag.indexer.interfaces.dto.ProcessType;
+import com.datamate.rag.indexer.interfaces.dto.AddFilesReq;
/**
* 数据插入事件
@@ -9,5 +9,5 @@ import com.datamate.rag.indexer.interfaces.dto.ProcessType;
* @author dallas
* @since 2025-10-29
*/
-public record DataInsertedEvent(KnowledgeBase knowledgeBase, ProcessType processType) {
+public record DataInsertedEvent(KnowledgeBase knowledgeBase, AddFilesReq addFilesReq) {
}
diff --git a/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/infrastructure/event/RagEtlService.java b/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/infrastructure/event/RagEtlService.java
index ad883dd..fc1743e 100644
--- a/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/infrastructure/event/RagEtlService.java
+++ b/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/infrastructure/event/RagEtlService.java
@@ -1,8 +1,8 @@
package com.datamate.rag.indexer.infrastructure.event;
-import com.datamate.common.models.domain.entity.ModelConfig;
-import com.datamate.common.models.domain.repository.ModelConfigRepository;
-import com.datamate.common.models.infrastructure.client.ModelClient;
+import com.datamate.common.setting.domain.entity.ModelConfig;
+import com.datamate.common.setting.domain.repository.ModelConfigRepository;
+import com.datamate.common.setting.infrastructure.client.ModelClient;
import com.datamate.rag.indexer.domain.model.FileStatus;
import com.datamate.rag.indexer.domain.model.RagFile;
import com.datamate.rag.indexer.domain.repository.RagFileRepository;
@@ -109,7 +109,7 @@ public class RagEtlService {
document = new HtmlToTextDocumentTransformer().transform(document);
}
// 使用文档分块器对文档进行分块
- DocumentSplitter splitter = documentSplitter(event.processType());
+ DocumentSplitter splitter = documentSplitter(event.addFilesReq().getProcessType());
List split = splitter.split(document);
// 更新分块数量
diff --git a/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/interfaces/dto/AddFilesReq.java b/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/interfaces/dto/AddFilesReq.java
index 5edd578..bb0f64d 100644
--- a/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/interfaces/dto/AddFilesReq.java
+++ b/backend/services/rag-indexer-service/src/main/java/com/datamate/rag/indexer/interfaces/dto/AddFilesReq.java
@@ -16,6 +16,9 @@ import java.util.List;
public class AddFilesReq {
private String knowledgeBaseId;
private ProcessType processType;
+ private Integer chunkSize;
+ private Integer overlapSize;
+ private String customSeparator;
private List files;
public record FileInfo(String id, String name) {
diff --git a/backend/services/rag-query-service/pom.xml b/backend/services/rag-query-service/pom.xml
index 209b5e4..79c527e 100644
--- a/backend/services/rag-query-service/pom.xml
+++ b/backend/services/rag-query-service/pom.xml
@@ -26,10 +26,6 @@
org.springframework.boot
spring-boot-starter-web
-
- org.springframework.boot
- spring-boot-starter-data-elasticsearch
-
com.mysql
mysql-connector-j
diff --git a/backend/shared/domain-common/pom.xml b/backend/shared/domain-common/pom.xml
index 6cb2b22..50166d2 100644
--- a/backend/shared/domain-common/pom.xml
+++ b/backend/shared/domain-common/pom.xml
@@ -38,5 +38,9 @@
langchain4j-open-ai
1.8.0
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/application/ModelConfigApplicationService.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/application/ModelConfigApplicationService.java
similarity index 86%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/application/ModelConfigApplicationService.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/application/ModelConfigApplicationService.java
index 1c3435b..d25494c 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/application/ModelConfigApplicationService.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/application/ModelConfigApplicationService.java
@@ -1,15 +1,14 @@
-package com.datamate.common.models.application;
+package com.datamate.common.setting.application;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.datamate.common.infrastructure.exception.BusinessAssert;
import com.datamate.common.interfaces.PagedResponse;
-import com.datamate.common.models.domain.entity.ModelConfig;
-import com.datamate.common.models.domain.repository.ModelConfigRepository;
-import com.datamate.common.models.infrastructure.client.ModelClient;
-import com.datamate.common.models.infrastructure.exception.ModelsErrorCode;
-import com.datamate.common.models.interfaces.rest.dto.CreateModelRequest;
-import com.datamate.common.models.interfaces.rest.dto.QueryModelRequest;
-import dev.langchain4j.model.chat.ChatModel;
+import com.datamate.common.setting.domain.entity.ModelConfig;
+import com.datamate.common.setting.domain.repository.ModelConfigRepository;
+import com.datamate.common.setting.infrastructure.client.ModelClient;
+import com.datamate.common.setting.infrastructure.exception.ModelsErrorCode;
+import com.datamate.common.setting.interfaces.rest.dto.CreateModelRequest;
+import com.datamate.common.setting.interfaces.rest.dto.QueryModelRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -33,7 +32,7 @@ public class ModelConfigApplicationService {
providers.add(ModelConfig.builder().provider("ModelEngine").baseUrl("http://localhost:9981").build());
providers.add(ModelConfig.builder().provider("Ollama").baseUrl("http://localhost:11434").build());
providers.add(ModelConfig.builder().provider("OpenAI").baseUrl("https://api.openai.com/v1").build());
- providers.add(ModelConfig.builder().provider("DeepSeek").baseUrl("https://api.deepseek.cn/v1").build());
+ providers.add(ModelConfig.builder().provider("DeepSeek").baseUrl("https://api.deepseek.com/v1").build());
providers.add(ModelConfig.builder().provider("火山方舟").baseUrl("https://ark.cn-beijing.volces.com/api/v3").build());
providers.add(ModelConfig.builder().provider("阿里云百炼").baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1").build());
providers.add(ModelConfig.builder().provider("硅基流动").baseUrl("https://api.siliconflow.cn/v1").build());
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/setting/application/SysParamApplicationService.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/application/SysParamApplicationService.java
new file mode 100644
index 0000000..9e6404c
--- /dev/null
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/application/SysParamApplicationService.java
@@ -0,0 +1,70 @@
+package com.datamate.common.setting.application;
+
+import com.datamate.common.infrastructure.exception.BusinessAssert;
+import com.datamate.common.infrastructure.exception.SystemErrorCode;
+import com.datamate.common.setting.domain.entity.SysParam;
+import com.datamate.common.setting.domain.repository.SysParamRepository;
+import jakarta.annotation.PostConstruct;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 系统参数应用服务
+ *
+ * @author dallas
+ * @since 2025-11-04
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class SysParamApplicationService {
+ private final SysParamRepository sysParamRepository;
+ private final StringRedisTemplate redisTemplate;
+
+ /**
+ * 列表查询系统参数
+ *
+ * @return 系统参数列表
+ */
+ public List list() {
+ return sysParamRepository.list();
+ }
+
+ /**
+ * 根据参数id修改系统参数值
+ *
+ * @param paramId 参数id
+ * @param paramValue 参数值
+ */
+ public void updateParamValueById(String paramId, String paramValue) {
+ SysParam sysParam = sysParamRepository.getById(paramId);
+ BusinessAssert.notNull(sysParam, SystemErrorCode.RESOURCE_NOT_FOUND);
+ sysParam.setParamValue(paramValue);
+ sysParamRepository.updateById(sysParam);
+ redisTemplate.opsForValue().set(sysParam.getParamKey(), paramValue);
+ }
+
+ public void deleteParamById(String paramId) {
+ SysParam sysParam = sysParamRepository.getById(paramId);
+ BusinessAssert.notNull(sysParam, SystemErrorCode.RESOURCE_NOT_FOUND);
+ sysParamRepository.removeById(paramId);
+ redisTemplate.delete(sysParam.getParamKey());
+ }
+
+ /**
+ * 初始化系统参数到Redis
+ */
+ @PostConstruct
+ public void init() {
+ try {
+ List sysParams = sysParamRepository.list();
+ sysParams.forEach(sysParam -> redisTemplate.opsForValue().set(sysParam.getParamKey(), sysParam.getParamValue()));
+ } catch (Exception e) {
+ log.error("Init sys params to redis error", e);
+ }
+ }
+}
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/domain/entity/ModelConfig.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/ModelConfig.java
similarity index 94%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/domain/entity/ModelConfig.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/ModelConfig.java
index 1d4cc62..76fba30 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/domain/entity/ModelConfig.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/ModelConfig.java
@@ -1,4 +1,4 @@
-package com.datamate.common.models.domain.entity;
+package com.datamate.common.setting.domain.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.datamate.common.domain.model.base.BaseEntity;
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/domain/entity/ModelType.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/ModelType.java
similarity index 79%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/domain/entity/ModelType.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/ModelType.java
index 7b05672..555fddb 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/domain/entity/ModelType.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/ModelType.java
@@ -1,4 +1,4 @@
-package com.datamate.common.models.domain.entity;
+package com.datamate.common.setting.domain.entity;
/**
* 模型类型枚举类
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/SysParam.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/SysParam.java
new file mode 100644
index 0000000..8d526ca
--- /dev/null
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/entity/SysParam.java
@@ -0,0 +1,57 @@
+package com.datamate.common.setting.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.datamate.common.domain.model.base.BaseEntity;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 系统参数设置实体类
+ *
+ * @author dallas
+ * @since 2025-10-27
+ */
+@Setter
+@Getter
+@TableName("t_sys_param")
+public class SysParam extends BaseEntity {
+ /**
+ * 设置项键(唯一)
+ */
+ private String paramKey;
+
+ /**
+ * 设置项值
+ */
+ private String paramValue;
+
+ /**
+ * 设置项类型(如 string、integer、boolean)
+ */
+ private String paramType;
+
+ /**
+ * 选项列表(JSON格式,仅对enum类型有效)
+ */
+ private String optionList;
+
+ /**
+ * 设置项描述
+ */
+ private String description;
+
+ /**
+ * 是否内置:1-是,0-否
+ */
+ private Boolean isBuiltIn;
+
+ /**
+ * 是否可修改:1-可修改,0-不可修改
+ */
+ private Boolean canModify;
+
+ /**
+ * 是否启用:1-启用,0-禁用
+ */
+ private Boolean isEnabled;
+}
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/domain/repository/ModelConfigRepository.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/repository/ModelConfigRepository.java
similarity index 71%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/domain/repository/ModelConfigRepository.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/repository/ModelConfigRepository.java
index 2c70b34..27ac3c2 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/domain/repository/ModelConfigRepository.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/repository/ModelConfigRepository.java
@@ -1,9 +1,9 @@
-package com.datamate.common.models.domain.repository;
+package com.datamate.common.setting.domain.repository;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.repository.IRepository;
-import com.datamate.common.models.domain.entity.ModelConfig;
-import com.datamate.common.models.interfaces.rest.dto.QueryModelRequest;
+import com.datamate.common.setting.domain.entity.ModelConfig;
+import com.datamate.common.setting.interfaces.rest.dto.QueryModelRequest;
/**
* 模型配置仓库接口
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/repository/SysParamRepository.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/repository/SysParamRepository.java
new file mode 100644
index 0000000..79cde45
--- /dev/null
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/domain/repository/SysParamRepository.java
@@ -0,0 +1,13 @@
+package com.datamate.common.setting.domain.repository;
+
+import com.baomidou.mybatisplus.extension.repository.IRepository;
+import com.datamate.common.setting.domain.entity.SysParam;
+
+/**
+ * 系统参数仓库接口
+ *
+ * @author dallas
+ * @since 2025-11-04
+ */
+public interface SysParamRepository extends IRepository {
+}
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/client/ModelClient.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/client/ModelClient.java
similarity index 91%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/client/ModelClient.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/client/ModelClient.java
index 26ddf73..196da0a 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/client/ModelClient.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/client/ModelClient.java
@@ -1,8 +1,8 @@
-package com.datamate.common.models.infrastructure.client;
+package com.datamate.common.setting.infrastructure.client;
import com.datamate.common.infrastructure.exception.BusinessException;
-import com.datamate.common.models.domain.entity.ModelConfig;
-import com.datamate.common.models.infrastructure.exception.ModelsErrorCode;
+import com.datamate.common.setting.domain.entity.ModelConfig;
+import com.datamate.common.setting.infrastructure.exception.ModelsErrorCode;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/exception/ModelsErrorCode.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/exception/ModelsErrorCode.java
similarity index 91%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/exception/ModelsErrorCode.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/exception/ModelsErrorCode.java
index 48501a1..3477927 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/exception/ModelsErrorCode.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/exception/ModelsErrorCode.java
@@ -1,4 +1,4 @@
-package com.datamate.common.models.infrastructure.exception;
+package com.datamate.common.setting.infrastructure.exception;
import com.datamate.common.infrastructure.exception.ErrorCode;
import lombok.AllArgsConstructor;
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/persistence/impl/ModelConfigRepositoryImpl.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/impl/ModelConfigRepositoryImpl.java
similarity index 78%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/persistence/impl/ModelConfigRepositoryImpl.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/impl/ModelConfigRepositoryImpl.java
index 0d4239f..00ee35f 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/persistence/impl/ModelConfigRepositoryImpl.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/impl/ModelConfigRepositoryImpl.java
@@ -1,13 +1,13 @@
-package com.datamate.common.models.infrastructure.persistence.impl;
+package com.datamate.common.setting.infrastructure.persistence.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.repository.CrudRepository;
-import com.datamate.common.models.domain.entity.ModelConfig;
-import com.datamate.common.models.domain.repository.ModelConfigRepository;
-import com.datamate.common.models.infrastructure.persistence.mapper.ModelConfigMapper;
-import com.datamate.common.models.interfaces.rest.dto.QueryModelRequest;
+import com.datamate.common.setting.domain.entity.ModelConfig;
+import com.datamate.common.setting.domain.repository.ModelConfigRepository;
+import com.datamate.common.setting.infrastructure.persistence.mapper.ModelConfigMapper;
+import com.datamate.common.setting.interfaces.rest.dto.QueryModelRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/impl/SysParamRepositoryImpl.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/impl/SysParamRepositoryImpl.java
new file mode 100644
index 0000000..f0b9373
--- /dev/null
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/impl/SysParamRepositoryImpl.java
@@ -0,0 +1,17 @@
+package com.datamate.common.setting.infrastructure.persistence.impl;
+
+import com.baomidou.mybatisplus.extension.repository.CrudRepository;
+import com.datamate.common.setting.domain.entity.SysParam;
+import com.datamate.common.setting.domain.repository.SysParamRepository;
+import com.datamate.common.setting.infrastructure.persistence.mapper.SysParamMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 系统参数仓储实现类
+ *
+ * @author dallas
+ * @since 2025-11-04
+ */
+@Repository
+public class SysParamRepositoryImpl extends CrudRepository implements SysParamRepository {
+}
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/persistence/mapper/ModelConfigMapper.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/mapper/ModelConfigMapper.java
similarity index 66%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/persistence/mapper/ModelConfigMapper.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/mapper/ModelConfigMapper.java
index 970f3fa..7f12a2b 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/infrastructure/persistence/mapper/ModelConfigMapper.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/mapper/ModelConfigMapper.java
@@ -1,7 +1,7 @@
-package com.datamate.common.models.infrastructure.persistence.mapper;
+package com.datamate.common.setting.infrastructure.persistence.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.datamate.common.models.domain.entity.ModelConfig;
+import com.datamate.common.setting.domain.entity.ModelConfig;
import org.apache.ibatis.annotations.Mapper;
/**
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/mapper/SysParamMapper.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/mapper/SysParamMapper.java
new file mode 100644
index 0000000..99dc848
--- /dev/null
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/infrastructure/persistence/mapper/SysParamMapper.java
@@ -0,0 +1,15 @@
+package com.datamate.common.setting.infrastructure.persistence.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.datamate.common.setting.domain.entity.SysParam;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 系统参数映射器
+ *
+ * @author dallas
+ * @since 2025-11-04
+ */
+@Mapper
+public interface SysParamMapper extends BaseMapper {
+}
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/interfaces/rest/ModelConfigController.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/ModelConfigController.java
similarity index 87%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/interfaces/rest/ModelConfigController.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/ModelConfigController.java
index 20eacf8..b747139 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/interfaces/rest/ModelConfigController.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/ModelConfigController.java
@@ -1,11 +1,11 @@
-package com.datamate.common.models.interfaces.rest;
+package com.datamate.common.setting.interfaces.rest;
import com.datamate.common.interfaces.PagedResponse;
-import com.datamate.common.models.application.ModelConfigApplicationService;
-import com.datamate.common.models.domain.entity.ModelConfig;
-import com.datamate.common.models.interfaces.rest.dto.CreateModelRequest;
-import com.datamate.common.models.interfaces.rest.dto.QueryModelRequest;
+import com.datamate.common.setting.application.ModelConfigApplicationService;
+import com.datamate.common.setting.domain.entity.ModelConfig;
+import com.datamate.common.setting.interfaces.rest.dto.CreateModelRequest;
+import com.datamate.common.setting.interfaces.rest.dto.QueryModelRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/SysParamController.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/SysParamController.java
new file mode 100644
index 0000000..f3904e5
--- /dev/null
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/SysParamController.java
@@ -0,0 +1,52 @@
+package com.datamate.common.setting.interfaces.rest;
+
+import com.datamate.common.setting.application.SysParamApplicationService;
+import com.datamate.common.setting.domain.entity.SysParam;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 系统参数控制器
+ *
+ * @author dallas
+ * @since 2025-11-04
+ */
+@RestController
+@RequestMapping("/sys-param")
+@RequiredArgsConstructor
+public class SysParamController {
+ private final SysParamApplicationService sysParamApplicationService;
+
+ /**
+ * 获取系统参数列表
+ *
+ * @return 系统参数列表
+ */
+ @GetMapping("/list")
+ public List list() {
+ return sysParamApplicationService.list();
+ }
+
+ /**
+ * 根据参数id修改系统参数值
+ *
+ * @param paramId 参数id
+ * @param paramValue 参数值
+ */
+ @PutMapping("/{paramId}")
+ public void updateParamValueById(@PathVariable("paramId") String paramId, @RequestBody String paramValue) {
+ sysParamApplicationService.updateParamValueById(paramId, paramValue);
+ }
+
+ /**
+ * 根据参数id删除系统参数
+ *
+ * @param paramId 参数id
+ */
+ @DeleteMapping("/{paramId}")
+ public void deleteParamById(@PathVariable("paramId") String paramId) {
+ sysParamApplicationService.deleteParamById(paramId);
+ }
+}
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/interfaces/rest/dto/CreateModelRequest.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/dto/CreateModelRequest.java
similarity index 89%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/interfaces/rest/dto/CreateModelRequest.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/dto/CreateModelRequest.java
index 54678e5..eb2e916 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/interfaces/rest/dto/CreateModelRequest.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/dto/CreateModelRequest.java
@@ -1,6 +1,6 @@
-package com.datamate.common.models.interfaces.rest.dto;
+package com.datamate.common.setting.interfaces.rest.dto;
-import com.datamate.common.models.domain.entity.ModelType;
+import com.datamate.common.setting.domain.entity.ModelType;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
diff --git a/backend/shared/domain-common/src/main/java/com/datamate/common/models/interfaces/rest/dto/QueryModelRequest.java b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/dto/QueryModelRequest.java
similarity index 80%
rename from backend/shared/domain-common/src/main/java/com/datamate/common/models/interfaces/rest/dto/QueryModelRequest.java
rename to backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/dto/QueryModelRequest.java
index 5c17c0f..373d79f 100644
--- a/backend/shared/domain-common/src/main/java/com/datamate/common/models/interfaces/rest/dto/QueryModelRequest.java
+++ b/backend/shared/domain-common/src/main/java/com/datamate/common/setting/interfaces/rest/dto/QueryModelRequest.java
@@ -1,7 +1,7 @@
-package com.datamate.common.models.interfaces.rest.dto;
+package com.datamate.common.setting.interfaces.rest.dto;
import com.datamate.common.interfaces.PagingQuery;
-import com.datamate.common.models.domain.entity.ModelType;
+import com.datamate.common.setting.domain.entity.ModelType;
import lombok.Getter;
import lombok.Setter;
diff --git a/deployment/docker/datamate/docker-compose.yml b/deployment/docker/datamate/docker-compose.yml
index 207ec04..9c6ca1c 100644
--- a/deployment/docker/datamate/docker-compose.yml
+++ b/deployment/docker/datamate/docker-compose.yml
@@ -113,6 +113,15 @@ services:
networks: [ datamate ]
profiles: [ mineru ]
+ # 5) redis
+ datamate-redis:
+ container_name: datamate-redis
+ image: redis:8.2.3
+ restart: on-failure
+ ports:
+ - "6379:6379"
+ networks: [ datamate ]
+
volumes:
dataset_volume:
name: datamate-dataset-volume
diff --git a/scripts/db/model-management-init.sql b/scripts/db/model-management-init.sql
deleted file mode 100644
index 26f70ef..0000000
--- a/scripts/db/model-management-init.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-USE datamate;
-
-CREATE TABLE t_model_config
-(
- id VARCHAR(36) PRIMARY KEY COMMENT '主键ID',
- model_name VARCHAR(100) NOT NULL COMMENT '模型名称(如 qwen2)',
- provider VARCHAR(50) NOT NULL COMMENT '模型提供商(如 Ollama、OpenAI、DeepSeek)',
- base_url VARCHAR(255) NOT NULL COMMENT 'API 基础地址',
- api_key VARCHAR(512) DEFAULT '' COMMENT 'API 密钥(无密钥则为空)',
- type VARCHAR(50) NOT NULL COMMENT '模型类型(如 chat、embedding)',
- is_enabled TINYINT DEFAULT 1 COMMENT '是否启用:1-启用,0-禁用',
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
- updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- created_by VARCHAR(255) COMMENT '创建者',
- updated_by VARCHAR(255) COMMENT '更新者',
- UNIQUE KEY uk_model_provider (model_name, provider) COMMENT '避免同一提供商下模型名称重复'
-) ENGINE = InnoDB
- DEFAULT CHARSET = utf8mb4 COMMENT ='模型配置表';
-
diff --git a/scripts/db/setting-management-init.sql b/scripts/db/setting-management-init.sql
new file mode 100644
index 0000000..9ef288d
--- /dev/null
+++ b/scripts/db/setting-management-init.sql
@@ -0,0 +1,41 @@
+USE datamate;
+
+CREATE TABLE IF NOT EXISTS t_model_config
+(
+ id VARCHAR(36) PRIMARY KEY COMMENT '主键ID',
+ model_name VARCHAR(100) NOT NULL COMMENT '模型名称(如 qwen2)',
+ provider VARCHAR(50) NOT NULL COMMENT '模型提供商(如 Ollama、OpenAI、DeepSeek)',
+ base_url VARCHAR(255) NOT NULL COMMENT 'API 基础地址',
+ api_key VARCHAR(512) DEFAULT '' COMMENT 'API 密钥(无密钥则为空)',
+ type VARCHAR(50) NOT NULL COMMENT '模型类型(如 chat、embedding)',
+ is_enabled TINYINT DEFAULT 1 COMMENT '是否启用:1-启用,0-禁用',
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ created_by VARCHAR(255) COMMENT '创建者',
+ updated_by VARCHAR(255) COMMENT '更新者',
+ UNIQUE KEY uk_model_provider (model_name, provider) COMMENT '避免同一提供商下模型名称重复'
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4 COMMENT ='模型配置表';
+
+CREATE TABLE IF NOT EXISTS t_sys_param
+(
+ id VARCHAR(36) PRIMARY KEY COMMENT '主键ID',
+ param_key VARCHAR(100) NOT NULL COMMENT '设置项键',
+ param_value TEXT NOT NULL COMMENT '设置项值',
+ param_type VARCHAR(50) DEFAULT 'string' COMMENT '设置项类型(如 string、integer、boolean)',
+ option_list TEXT COMMENT '选项列表(如 JSON 格式,仅对 enum 类型有效)',
+ description VARCHAR(255) DEFAULT '' COMMENT '设置项描述',
+ is_built_in TINYINT DEFAULT 0 COMMENT '是否内置:1-是,0-否',
+ can_modify TINYINT DEFAULT 1 COMMENT '是否可修改:1-可修改,0-不可修改',
+ is_enabled TINYINT DEFAULT 1 COMMENT '是否启用:1-启用,0-禁用',
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ created_by VARCHAR(255) COMMENT '创建者',
+ updated_by VARCHAR(255) COMMENT '更新者',
+ UNIQUE KEY uk_sys_param (param_key) COMMENT '避免设置项键重复'
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4 COMMENT ='设置管理表';
+
+insert into t_sys_param (id, param_key, param_value, param_type, option_list, description, is_built_in, can_modify,
+ is_enabled, created_by, updated_by)
+values ('1', 'sys.knowledge.base.count', '200', 'integer', '', '知识库最大数量', 1, 1, 1, 'system', 'system');