日志修复

This commit is contained in:
2026-01-08 17:59:07 +08:00
parent 54599f28d1
commit f948362d1b
4 changed files with 22 additions and 9 deletions

View File

@@ -797,7 +797,7 @@ CLICKZETTA_VECTOR_DISTANCE_FUNCTION=cosine_distance
# ------------------------------
# Upload file size limit, default 15M.
UPLOAD_FILE_SIZE_LIMIT=15
UPLOAD_FILE_SIZE_LIMIT=100
# The maximum number of files that can be uploaded at a time, default 5.
UPLOAD_FILE_BATCH_LIMIT=5

View File

@@ -267,10 +267,16 @@ public class DifyApiClient {
try {
// 构建 data JSON 字符串(包含所有元数据)
Map<String, Object> dataMap = new HashMap<>();
if (uploadRequest.getName() != null) {
// name 字段:如果提供则使用,否则使用文件名
if (uploadRequest.getName() != null && !uploadRequest.getName().trim().isEmpty()) {
dataMap.put("name", uploadRequest.getName());
} else {
dataMap.put("name", originalFilename);
}
if (uploadRequest.getIndexingTechnique() != null) {
// indexing_technique 字段:只有在明确提供且非空时才添加
if (uploadRequest.getIndexingTechnique() != null && !uploadRequest.getIndexingTechnique().trim().isEmpty()) {
dataMap.put("indexing_technique", uploadRequest.getIndexingTechnique());
}
@@ -284,9 +290,6 @@ public class DifyApiClient {
dataMap.put("process_rule", defaultProcessRule);
}
// 只保留官方支持的参数
// doc_form 和 doc_language 不是请求参数,移除
String dataJson = JSON.toJSONString(dataMap);
logger.info("上传文档到知识库: datasetId={}, file={}, data={}", datasetId, originalFilename, dataJson);

View File

@@ -39,7 +39,7 @@ public class KnowledgeFileLogServiceImpl implements KnowledgeFileLogService{
knowledgeFileLog.setOptsn(IdUtil.getOptsn());
knowledgeFileLog.setLogId(IdUtil.generateID());
ValidationResult rt = ValidationUtils.validate(knowledgeFileLog, Arrays.asList(
ValidationUtils.requiredString("fileId", "文件id")
));
if(!rt.isValid()){
return ResultDomain.failure("日志参数校验失败");

View File

@@ -26,8 +26,18 @@
optsn, log_id, knowledge_id, file_root_id, file_id, file_name, version,
action, service, creator, creator_name, create_time
) VALUES (
#{optsn}, #{logId}, #{knowledgeId}, #{fileRootId}, #{fileId}, #{fileName}, #{version},
#{action}, #{service}, #{creator}, #{creatorName}, NOW()
#{optsn}, #{logId}, #{knowledgeId}, #{fileRootId}, #{fileId},
<choose>
<!-- action为delete时查询历史fileName无数据则填空字符串 -->
<when test="action == 'delete'">
(SELECT COALESCE(file_name, '') FROM ai.tb_knowledge_file_log WHERE file_id = #{fileId} LIMIT 1)
</when>
<!-- 其他操作直接使用传入的fileName -->
<otherwise>
#{fileName}
</otherwise>
</choose>,
#{version}, #{action}, #{service}, #{creator}, #{creatorName}, NOW()
)
</insert>