Merge pull request #2317 from xinnan-tech/hot-fix

fix:python config api no need maskSensitive
This commit is contained in:
欣南科技
2025-10-08 22:45:22 +08:00
committed by GitHub
3 changed files with 21 additions and 61 deletions
@@ -377,7 +377,7 @@ public class ConfigServiceImpl implements ConfigService {
continue;
}
// 关键:第三个参数传false,确保获取原始密钥
ModelConfigEntity model = modelConfigService.getModelById(modelIds[i], isCache, false);
ModelConfigEntity model = modelConfigService.getModelByIdFromCache(modelIds[i]);
if (model == null) {
continue;
}
@@ -426,7 +426,7 @@ public class ConfigServiceImpl implements ConfigService {
if (StringUtils.isNotBlank(intentLLMModelId)) {
if (!typeConfig.containsKey(intentLLMModelId)) {
// 修改这里:添加isMaskSensitive=false参数
ModelConfigEntity intentLLM = modelConfigService.getModelById(intentLLMModelId, isCache, false);
ModelConfigEntity intentLLM = modelConfigService.getModelByIdFromCache(intentLLMModelId);
typeConfig.put(intentLLM.getId(), intentLLM.getConfigJson());
}
}
@@ -434,7 +434,7 @@ public class ConfigServiceImpl implements ConfigService {
if (!typeConfig.containsKey(memLocalShortLLMModelId)) {
// 修改这里:添加isMaskSensitive=false参数
ModelConfigEntity memLocalShortLLM = modelConfigService
.getModelById(memLocalShortLLMModelId, isCache, false);
.getModelByIdFromCache(memLocalShortLLMModelId);
typeConfig.put(memLocalShortLLM.getId(), memLocalShortLLM.getConfigJson());
}
}
@@ -36,27 +36,16 @@ public interface ModelConfigService extends BaseService<ModelConfigEntity> {
/**
* 根据ID获取模型配置
*
* @param id 模型ID
* @param isCache 是否缓存
* @param isMaskSensitive 是否掩码敏感信息
* @param id 模型ID
* @return 模型配置实体
*/
ModelConfigEntity getModelById(String id, boolean isCache, boolean isMaskSensitive);
/**
* 根据ID获取模型配置(默认掩码敏感信息)
*
* @param id 模型ID
* @param isCache 是否缓存
* @return 模型配置实体
*/
ModelConfigEntity getModelById(String id, boolean isCache);
ModelConfigEntity getModelByIdFromCache(String id);
/**
* 设置默认模型
*
* @param modelType 模型类型
* @param isDefault 是否默认(1:是,0:否)
* @param modelType 模型类型
* @param isDefault 是否默认(1:是,0:否)
*/
void setDefaultModel(String modelType, int isDefault);
@@ -211,44 +211,15 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
}
@Override
public ModelConfigEntity getModelById(String id, boolean isCache) {
return getModelById(id, isCache, true);
}
@Override
public ModelConfigEntity getModelById(String id, boolean isCache, boolean isMaskSensitive) {
public ModelConfigEntity getModelByIdFromCache(String id) {
if (StringUtils.isBlank(id)) {
return null;
}
ModelConfigEntity entity = null;
String cacheKey = RedisKeys.getModelConfigById(id);
if (isCache) {
// 从缓存获取
entity = (ModelConfigEntity) redisUtils.get(cacheKey);
ModelConfigEntity entity = (ModelConfigEntity) redisUtils.get(cacheKey);
if (entity == null) {
entity = modelConfigDao.selectById(id);
if (entity != null) {
// 修改:根据isMaskSensitive参数重新处理敏感信息
if (!isMaskSensitive && entity.getConfigJson() != null) {
// 如果需要获取原始配置,但缓存的是掩码后的配置,则从数据库重新获取
ModelConfigEntity originalEntity = modelConfigDao.selectById(id);
if (originalEntity != null) {
entity.setConfigJson(originalEntity.getConfigJson());
}
}
return entity;
}
}
// 从数据库获取数据
entity = modelConfigDao.selectById(id);
if (entity != null) {
// 根据isMaskSensitive参数决定是否掩码敏感信息
if (isMaskSensitive && entity.getConfigJson() != null) {
entity.setConfigJson(maskSensitiveFields(entity.getConfigJson()));
}
if (isCache) {
redisUtils.set(cacheKey, entity);
}
}