【feat】 初步完成配置管理模块
This commit is contained in:
parent
a27b121491
commit
5e3e2a4377
@ -0,0 +1,19 @@
|
||||
package com.datai.salesforce.common.constant;
|
||||
|
||||
/**
|
||||
* Salesforce配置常量类
|
||||
* 定义配置相关的常量
|
||||
*/
|
||||
public class SalesforceConfigConstants {
|
||||
/**
|
||||
* Salesforce配置缓存键
|
||||
*/
|
||||
public static final String SALESFORCE_CONFIG_CACHE_KEY = "salesforce_config";
|
||||
|
||||
/**
|
||||
* 私有构造方法,防止实例化
|
||||
*/
|
||||
private SalesforceConfigConstants() {
|
||||
// 私有构造方法,防止实例化
|
||||
}
|
||||
}
|
||||
@ -22,6 +22,11 @@
|
||||
<groupId>com.datai</groupId>
|
||||
<artifactId>datai-salesforce-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.datai</groupId>
|
||||
<artifactId>datai-cache-redis</artifactId>
|
||||
<version>${datai.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,83 @@
|
||||
package com.datai.setting.config;
|
||||
|
||||
import com.datai.common.utils.CacheUtils;
|
||||
import com.datai.salesforce.common.constant.SalesforceConfigConstants;
|
||||
import com.datai.setting.domain.DataiConfiguration;
|
||||
import com.datai.setting.mapper.DataiConfigurationMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Salesforce配置缓存管理器
|
||||
* 负责配置的加载、缓存和更新
|
||||
*
|
||||
* @author datai
|
||||
* @date 2025-12-11
|
||||
*/
|
||||
@Component
|
||||
public class SalesforceConfigCacheManager {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SalesforceConfigCacheManager.class);
|
||||
|
||||
@Autowired
|
||||
private DataiConfigurationMapper configurationMapper;
|
||||
|
||||
/**
|
||||
* 系统启动时初始化配置缓存
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
long startTime = System.currentTimeMillis();
|
||||
logger.info("开始初始化Salesforce配置...");
|
||||
try {
|
||||
loadConfigToCache();
|
||||
long endTime = System.currentTimeMillis();
|
||||
logger.info("Salesforce配置初始化完成,耗时: {}ms", (endTime - startTime));
|
||||
} catch (Exception e) {
|
||||
logger.error("Salesforce配置初始化失败: {}", e.getMessage(), e);
|
||||
throw new RuntimeException("Salesforce配置初始化失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将配置加载到缓存
|
||||
*/
|
||||
public void loadConfigToCache() {
|
||||
// 清空现有缓存
|
||||
CacheUtils.getCache(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY).clear();
|
||||
|
||||
// 查询所有激活的配置
|
||||
DataiConfiguration query = new DataiConfiguration();
|
||||
query.setIsActive(1L); // 只加载激活状态的配置
|
||||
List<DataiConfiguration> configs = configurationMapper.selectDataiConfigurationList(query);
|
||||
|
||||
logger.info("加载配置数量: {}", configs.size());
|
||||
|
||||
// 将配置存入缓存
|
||||
for (DataiConfiguration config : configs) {
|
||||
CacheUtils.getCache(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY).put(config.getConfigKey(), config.getConfigValue());
|
||||
logger.debug("配置加载到缓存: {} = {}", config.getConfigKey(), config.getConfigValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置配置缓存
|
||||
*/
|
||||
public void resetConfigCache() {
|
||||
logger.info("重置Salesforce配置缓存...");
|
||||
loadConfigToCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空配置缓存
|
||||
*/
|
||||
public void clearConfigCache() {
|
||||
logger.info("清空Salesforce配置缓存");
|
||||
CacheUtils.getCache(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY).clear();
|
||||
}
|
||||
}
|
||||
@ -4,14 +4,7 @@ import java.util.List;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.datai.common.annotation.Log;
|
||||
import com.datai.common.core.controller.BaseController;
|
||||
import com.datai.common.core.domain.AjaxResult;
|
||||
@ -110,4 +103,40 @@ public class DataiConfigVersionController extends BaseController
|
||||
{
|
||||
return toAjax(dataiConfigVersionService.deleteDataiConfigVersionByVersionIds(versionIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布配置版本
|
||||
*/
|
||||
@Operation(summary = "发布配置版本")
|
||||
@PreAuthorize("@ss.hasPermi('setting:version:publish')")
|
||||
@Log(title = "配置版本", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{versionId}/publish")
|
||||
public AjaxResult publishVersion(@PathVariable Long versionId)
|
||||
{
|
||||
return toAjax(dataiConfigVersionService.publishConfigVersion(versionId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建配置快照
|
||||
*/
|
||||
@Operation(summary = "创建配置快照")
|
||||
@PreAuthorize("@ss.hasPermi('setting:version:snapshot')")
|
||||
@Log(title = "配置版本", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/snapshot")
|
||||
public AjaxResult createSnapshot(@RequestParam String versionDesc)
|
||||
{
|
||||
return success(dataiConfigVersionService.createVersionSnapshot(versionDesc));
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚到指定版本
|
||||
*/
|
||||
@Operation(summary = "回滚到指定版本")
|
||||
@PreAuthorize("@ss.hasPermi('setting:version:rollback')")
|
||||
@Log(title = "配置版本", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/{versionId}/rollback")
|
||||
public AjaxResult rollbackToVersion(@PathVariable Long versionId)
|
||||
{
|
||||
return toAjax(dataiConfigVersionService.rollbackToVersion(versionId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,4 +110,41 @@ public class DataiConfigurationController extends BaseController
|
||||
{
|
||||
return toAjax(dataiConfigurationService.deleteDataiConfigurationByConfigIds(configIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新配置缓存
|
||||
*/
|
||||
@Operation(summary = "刷新配置缓存")
|
||||
@PreAuthorize("@ss.hasPermi('setting:configuration:refresh')")
|
||||
@Log(title = "配置", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/refresh")
|
||||
public AjaxResult refreshConfigCache()
|
||||
{
|
||||
dataiConfigurationService.resetConfigCache();
|
||||
return success("配置缓存刷新成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配置缓存状态
|
||||
*/
|
||||
@Operation(summary = "查询配置缓存状态")
|
||||
@PreAuthorize("@ss.hasPermi('setting:configuration:cache')")
|
||||
@GetMapping("/cache")
|
||||
public AjaxResult getConfigCacheStatus()
|
||||
{
|
||||
// 这里可以返回更详细的缓存状态信息
|
||||
return success("配置缓存状态正常");
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证配置值合法性
|
||||
*/
|
||||
@Operation(summary = "验证配置值合法性")
|
||||
@PreAuthorize("@ss.hasPermi('setting:configuration:validate')")
|
||||
@PostMapping("/validate")
|
||||
public AjaxResult validateConfig(@RequestBody DataiConfiguration config)
|
||||
{
|
||||
boolean isValid = dataiConfigurationService.validateConfigValue(config);
|
||||
return isValid ? success("配置值验证通过") : error("配置值验证失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.datai.setting.event;
|
||||
|
||||
import com.datai.setting.domain.DataiConfiguration;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* 配置变更事件
|
||||
* 用于在配置更新时发布事件,通知相关服务配置已变更
|
||||
*/
|
||||
public class ConfigChangeEvent extends ApplicationEvent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 配置对象 */
|
||||
private DataiConfiguration config;
|
||||
|
||||
/** 操作类型:CREATE、UPDATE、DELETE */
|
||||
private String operationType;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param source 事件源
|
||||
* @param config 配置对象
|
||||
* @param operationType 操作类型
|
||||
*/
|
||||
public ConfigChangeEvent(Object source, DataiConfiguration config, String operationType) {
|
||||
super(source);
|
||||
this.config = config;
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
public DataiConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public String getOperationType() {
|
||||
return operationType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("ConfigChangeEvent [configKey=%s, operationType=%s]",
|
||||
config.getConfigKey(), operationType);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
package com.datai.setting.event;
|
||||
|
||||
import com.datai.setting.domain.DataiConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 配置变更事件监听器
|
||||
* 用于处理配置更新后的逻辑,实现组件重新初始化机制
|
||||
*/
|
||||
@Component
|
||||
public class ConfigChangeListener {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ConfigChangeListener.class);
|
||||
|
||||
/**
|
||||
* 监听配置变更事件
|
||||
*
|
||||
* @param event 配置变更事件
|
||||
*/
|
||||
@EventListener
|
||||
public void handleConfigChangeEvent(ConfigChangeEvent event) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
logger.info("开始处理配置变更事件: {}", event);
|
||||
|
||||
try {
|
||||
DataiConfiguration config = event.getConfig();
|
||||
String operationType = event.getOperationType();
|
||||
|
||||
// 根据配置键和操作类型执行不同的处理逻辑
|
||||
handleSpecificConfigChange(config, operationType);
|
||||
|
||||
// 通用处理逻辑
|
||||
handleGenericConfigChange(config, operationType);
|
||||
|
||||
long endTime = System.currentTimeMillis();
|
||||
logger.info("配置变更事件处理完成,耗时: {}ms", (endTime - startTime));
|
||||
} catch (Exception e) {
|
||||
logger.error("处理配置变更事件失败: {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理特定配置变更
|
||||
*
|
||||
* @param config 配置对象
|
||||
* @param operationType 操作类型
|
||||
*/
|
||||
private void handleSpecificConfigChange(DataiConfiguration config, String operationType) {
|
||||
String configKey = config.getConfigKey();
|
||||
String configValue = config.getConfigValue();
|
||||
|
||||
// 根据不同的配置键执行不同的处理逻辑
|
||||
switch (configKey) {
|
||||
case "salesforce.api.version":
|
||||
handleApiVersionChange(configValue, operationType);
|
||||
break;
|
||||
case "salesforce.environment.type":
|
||||
handleEnvironmentTypeChange(configValue, operationType);
|
||||
break;
|
||||
case "salesforce.auth.type":
|
||||
handleAuthTypeChange(configValue, operationType);
|
||||
break;
|
||||
// 可以添加更多特定配置的处理逻辑
|
||||
default:
|
||||
logger.debug("没有特定处理逻辑的配置: {}", configKey);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理API版本变更
|
||||
*
|
||||
* @param apiVersion API版本
|
||||
* @param operationType 操作类型
|
||||
*/
|
||||
private void handleApiVersionChange(String apiVersion, String operationType) {
|
||||
logger.info("Salesforce API版本变更: {}, 操作类型: {}", apiVersion, operationType);
|
||||
// 这里可以实现API版本变更后的处理逻辑
|
||||
// 例如:重新初始化API客户端、更新WSDL文件等
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理环境类型变更
|
||||
*
|
||||
* @param environmentType 环境类型
|
||||
* @param operationType 操作类型
|
||||
*/
|
||||
private void handleEnvironmentTypeChange(String environmentType, String operationType) {
|
||||
logger.info("Salesforce环境类型变更: {}, 操作类型: {}", environmentType, operationType);
|
||||
// 这里可以实现环境类型变更后的处理逻辑
|
||||
// 例如:切换服务端点、更新认证配置等
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理认证类型变更
|
||||
*
|
||||
* @param authType 认证类型
|
||||
* @param operationType 操作类型
|
||||
*/
|
||||
private void handleAuthTypeChange(String authType, String operationType) {
|
||||
logger.info("Salesforce认证类型变更: {}, 操作类型: {}", authType, operationType);
|
||||
// 这里可以实现认证类型变更后的处理逻辑
|
||||
// 例如:重新初始化认证客户端、更新认证配置等
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理通用配置变更
|
||||
*
|
||||
* @param config 配置对象
|
||||
* @param operationType 操作类型
|
||||
*/
|
||||
private void handleGenericConfigChange(DataiConfiguration config, String operationType) {
|
||||
logger.debug("通用配置变更处理: {}, 操作类型: {}", config.getConfigKey(), operationType);
|
||||
|
||||
// 这里可以实现通用的配置变更处理逻辑
|
||||
// 例如:更新缓存、通知其他服务等
|
||||
}
|
||||
}
|
||||
@ -58,4 +58,12 @@ public interface DataiConfigVersionMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDataiConfigVersionByVersionIds(Long[] versionIds);
|
||||
|
||||
/**
|
||||
* 根据日期查询版本数量
|
||||
*
|
||||
* @param date 日期
|
||||
* @return 版本数量
|
||||
*/
|
||||
public int countVersionsByDate(String date);
|
||||
}
|
||||
|
||||
@ -58,4 +58,11 @@ public interface DataiConfigurationMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDataiConfigurationByConfigIds(Long[] configIds);
|
||||
|
||||
/**
|
||||
* 删除所有配置
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAllConfigurations();
|
||||
}
|
||||
|
||||
@ -58,4 +58,35 @@ public interface IDataiConfigVersionService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDataiConfigVersionByVersionId(Long versionId);
|
||||
|
||||
/**
|
||||
* 创建配置版本快照
|
||||
*
|
||||
* @param versionDesc 版本描述
|
||||
* @return 配置版本
|
||||
*/
|
||||
public DataiConfigVersion createVersionSnapshot(String versionDesc);
|
||||
|
||||
/**
|
||||
* 发布配置版本
|
||||
*
|
||||
* @param versionId 版本ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int publishConfigVersion(Long versionId);
|
||||
|
||||
/**
|
||||
* 回滚到指定版本
|
||||
*
|
||||
* @param versionId 版本ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int rollbackToVersion(Long versionId);
|
||||
|
||||
/**
|
||||
* 获取当前生效版本
|
||||
*
|
||||
* @return 当前生效版本
|
||||
*/
|
||||
public DataiConfigVersion getCurrentActiveVersion();
|
||||
}
|
||||
|
||||
@ -19,6 +19,14 @@ public interface IDataiConfigurationService
|
||||
*/
|
||||
public DataiConfiguration selectDataiConfigurationByConfigId(Long configId);
|
||||
|
||||
/**
|
||||
* 根据配置键查询配置值
|
||||
*
|
||||
* @param configKey 配置键
|
||||
* @return 配置值
|
||||
*/
|
||||
public String selectConfigValueByKey(String configKey);
|
||||
|
||||
/**
|
||||
* 查询配置列表
|
||||
*
|
||||
@ -58,4 +66,27 @@ public interface IDataiConfigurationService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDataiConfigurationByConfigId(Long configId);
|
||||
|
||||
/**
|
||||
* 加载配置到缓存
|
||||
*/
|
||||
public void loadingConfigCache();
|
||||
|
||||
/**
|
||||
* 清空配置缓存
|
||||
*/
|
||||
public void clearConfigCache();
|
||||
|
||||
/**
|
||||
* 重置配置缓存
|
||||
*/
|
||||
public void resetConfigCache();
|
||||
|
||||
/**
|
||||
* 验证配置值合法性
|
||||
*
|
||||
* @param dataiConfiguration 配置
|
||||
* @return 验证结果
|
||||
*/
|
||||
public boolean validateConfigValue(DataiConfiguration dataiConfiguration);
|
||||
}
|
||||
|
||||
@ -1,16 +1,24 @@
|
||||
package com.datai.setting.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.datai.common.core.domain.model.LoginUser;
|
||||
import com.datai.common.utils.DateUtils;
|
||||
import com.datai.common.utils.SecurityUtils;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.datai.common.utils.SecurityUtils;
|
||||
import com.datai.setting.domain.DataiConfigVersion;
|
||||
import com.datai.setting.domain.DataiConfiguration;
|
||||
import com.datai.setting.mapper.DataiConfigVersionMapper;
|
||||
import com.datai.setting.mapper.DataiConfigurationMapper;
|
||||
import com.datai.setting.service.IDataiConfigVersionService;
|
||||
import com.datai.setting.service.IDataiConfigurationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.datai.setting.mapper.DataiConfigVersionMapper;
|
||||
import com.datai.setting.domain.DataiConfigVersion;
|
||||
import com.datai.setting.service.IDataiConfigVersionService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 配置版本Service业务层处理
|
||||
@ -20,8 +28,16 @@ import com.datai.setting.service.IDataiConfigVersionService;
|
||||
*/
|
||||
@Service
|
||||
public class DataiConfigVersionServiceImpl implements IDataiConfigVersionService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DataiConfigVersionServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private DataiConfigVersionMapper dataiConfigVersionMapper;
|
||||
|
||||
@Autowired
|
||||
private DataiConfigurationMapper dataiConfigurationMapper;
|
||||
|
||||
@Autowired
|
||||
private IDataiConfigurationService dataiConfigurationService;
|
||||
|
||||
/**
|
||||
* 查询配置版本
|
||||
@ -59,11 +75,11 @@ public class DataiConfigVersionServiceImpl implements IDataiConfigVersionService
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String username = loginUser.getUsername();
|
||||
|
||||
dataiConfigVersion.setCreateTime(DateUtils.getNowDate());
|
||||
dataiConfigVersion.setUpdateTime(DateUtils.getNowDate());
|
||||
dataiConfigVersion.setCreateBy(username);
|
||||
dataiConfigVersion.setUpdateBy(username);
|
||||
return dataiConfigVersionMapper.insertDataiConfigVersion(dataiConfigVersion);
|
||||
dataiConfigVersion.setCreateTime(DateUtils.getNowDate());
|
||||
dataiConfigVersion.setUpdateTime(DateUtils.getNowDate());
|
||||
dataiConfigVersion.setCreateBy(username);
|
||||
dataiConfigVersion.setUpdateBy(username);
|
||||
return dataiConfigVersionMapper.insertDataiConfigVersion(dataiConfigVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,8 +94,8 @@ public class DataiConfigVersionServiceImpl implements IDataiConfigVersionService
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String username = loginUser.getUsername();
|
||||
|
||||
dataiConfigVersion.setUpdateTime(DateUtils.getNowDate());
|
||||
dataiConfigVersion.setUpdateBy(username);
|
||||
dataiConfigVersion.setUpdateTime(DateUtils.getNowDate());
|
||||
dataiConfigVersion.setUpdateBy(username);
|
||||
return dataiConfigVersionMapper.updateDataiConfigVersion(dataiConfigVersion);
|
||||
}
|
||||
|
||||
@ -106,4 +122,184 @@ public class DataiConfigVersionServiceImpl implements IDataiConfigVersionService
|
||||
{
|
||||
return dataiConfigVersionMapper.deleteDataiConfigVersionByVersionId(versionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建配置版本快照
|
||||
*
|
||||
* @param versionDesc 版本描述
|
||||
* @return 配置版本
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public DataiConfigVersion createVersionSnapshot(String versionDesc) {
|
||||
logger.info("开始创建配置版本快照,描述: {}", versionDesc);
|
||||
|
||||
// 查询当前所有激活的配置
|
||||
DataiConfiguration query = new DataiConfiguration();
|
||||
query.setIsActive(1L); // 只包含激活状态的配置
|
||||
List<DataiConfiguration> allConfigs = dataiConfigurationMapper.selectDataiConfigurationList(query);
|
||||
logger.info("当前激活配置数量: {}", allConfigs.size());
|
||||
|
||||
// 生成快照内容
|
||||
String snapshotContent = JSON.toJSONString(allConfigs);
|
||||
|
||||
// 创建配置版本
|
||||
DataiConfigVersion version = new DataiConfigVersion();
|
||||
version.setVersionNumber(generateVersionNumber());
|
||||
version.setVersionDesc(versionDesc);
|
||||
version.setSnapshotId(UUID.randomUUID().toString());
|
||||
version.setSnapshotContent(snapshotContent);
|
||||
version.setStatus("CREATED");
|
||||
|
||||
// 设置审计信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String username = loginUser.getUsername();
|
||||
version.setCreateTime(DateUtils.getNowDate());
|
||||
version.setUpdateTime(DateUtils.getNowDate());
|
||||
version.setCreateBy(username);
|
||||
version.setUpdateBy(username);
|
||||
|
||||
// 保存到数据库
|
||||
int result = dataiConfigVersionMapper.insertDataiConfigVersion(version);
|
||||
if (result > 0) {
|
||||
logger.info("配置版本快照创建成功,版本号: {}", version.getVersionNumber());
|
||||
return version;
|
||||
} else {
|
||||
logger.error("配置版本快照创建失败");
|
||||
throw new RuntimeException("配置版本快照创建失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布配置版本
|
||||
*
|
||||
* @param versionId 版本ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int publishConfigVersion(Long versionId) {
|
||||
logger.info("开始发布配置版本,版本ID: {}", versionId);
|
||||
|
||||
// 查询版本信息
|
||||
DataiConfigVersion version = dataiConfigVersionMapper.selectDataiConfigVersionByVersionId(versionId);
|
||||
if (version == null) {
|
||||
logger.error("配置版本不存在,版本ID: {}", versionId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 更新版本状态为已发布
|
||||
version.setStatus("PUBLISHED");
|
||||
version.setPublishTime(LocalDate.now());
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String username = loginUser.getUsername();
|
||||
version.setUpdateTime(DateUtils.getNowDate());
|
||||
version.setUpdateBy(username);
|
||||
|
||||
int result = dataiConfigVersionMapper.updateDataiConfigVersion(version);
|
||||
if (result > 0) {
|
||||
logger.info("配置版本发布成功,版本号: {}", version.getVersionNumber());
|
||||
} else {
|
||||
logger.error("配置版本发布失败,版本ID: {}", versionId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚到指定版本
|
||||
*
|
||||
* @param versionId 版本ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int rollbackToVersion(Long versionId) {
|
||||
logger.info("开始回滚配置到版本,版本ID: {}", versionId);
|
||||
|
||||
// 查询版本信息
|
||||
DataiConfigVersion version = dataiConfigVersionMapper.selectDataiConfigVersionByVersionId(versionId);
|
||||
if (version == null) {
|
||||
logger.error("配置版本不存在,版本ID: {}", versionId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 解析快照内容
|
||||
List<DataiConfiguration> snapshotConfigs = JSON.parseArray(version.getSnapshotContent(), DataiConfiguration.class);
|
||||
if (snapshotConfigs == null || snapshotConfigs.isEmpty()) {
|
||||
logger.error("配置版本快照内容为空,版本ID: {}", versionId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 清空当前所有配置
|
||||
dataiConfigurationMapper.deleteAllConfigurations();
|
||||
logger.info("已清空当前所有配置");
|
||||
|
||||
// 重新插入快照中的配置
|
||||
int insertedCount = 0;
|
||||
for (DataiConfiguration config : snapshotConfigs) {
|
||||
// 重置ID和时间戳
|
||||
config.setConfigId(null);
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String username = loginUser.getUsername();
|
||||
config.setCreateTime(DateUtils.getNowDate());
|
||||
config.setUpdateTime(DateUtils.getNowDate());
|
||||
config.setCreateBy(username);
|
||||
config.setUpdateBy(username);
|
||||
|
||||
int result = dataiConfigurationMapper.insertDataiConfiguration(config);
|
||||
if (result > 0) {
|
||||
insertedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("回滚配置成功,插入配置数量: {}", insertedCount);
|
||||
|
||||
// 重置配置缓存
|
||||
dataiConfigurationService.resetConfigCache();
|
||||
|
||||
return insertedCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前生效版本
|
||||
*
|
||||
* @return 当前生效版本
|
||||
*/
|
||||
@Override
|
||||
public DataiConfigVersion getCurrentActiveVersion() {
|
||||
// 查询最新发布的版本
|
||||
DataiConfigVersion query = new DataiConfigVersion();
|
||||
query.setStatus("PUBLISHED");
|
||||
List<DataiConfigVersion> versions = dataiConfigVersionMapper.selectDataiConfigVersionList(query);
|
||||
|
||||
if (versions.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 返回最新的已发布版本(按创建时间倒序排序)
|
||||
return versions.stream()
|
||||
.max((v1, v2) -> v1.getCreateTime().compareTo(v2.getCreateTime()))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成版本号
|
||||
* 格式:YYYY.MM.DD.N (如 2025.12.14.1)
|
||||
*
|
||||
* @return 版本号
|
||||
*/
|
||||
private String generateVersionNumber() {
|
||||
// 获取当前日期
|
||||
String dateStr = DateUtils.getDate();
|
||||
dateStr = dateStr.replace("-", ".");
|
||||
|
||||
// 查询当天已生成的版本数量
|
||||
int count = dataiConfigVersionMapper.countVersionsByDate(DateUtils.getDate());
|
||||
|
||||
// 生成版本号
|
||||
return dateStr + "." + (count + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,16 +1,21 @@
|
||||
package com.datai.setting.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.datai.common.utils.CacheUtils;
|
||||
import com.datai.common.core.domain.model.LoginUser;
|
||||
import com.datai.common.utils.DateUtils;
|
||||
import com.datai.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.datai.setting.mapper.DataiConfigurationMapper;
|
||||
import com.datai.common.utils.SecurityUtils;
|
||||
import com.datai.salesforce.common.constant.SalesforceConfigConstants;
|
||||
import com.datai.setting.config.SalesforceConfigCacheManager;
|
||||
import com.datai.setting.domain.DataiConfiguration;
|
||||
import com.datai.setting.mapper.DataiConfigurationMapper;
|
||||
import com.datai.setting.service.IDataiConfigurationService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 配置Service业务层处理
|
||||
@ -20,8 +25,16 @@ import com.datai.setting.service.IDataiConfigurationService;
|
||||
*/
|
||||
@Service
|
||||
public class DataiConfigurationServiceImpl implements IDataiConfigurationService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DataiConfigurationServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private DataiConfigurationMapper dataiConfigurationMapper;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@Autowired
|
||||
private SalesforceConfigCacheManager SalesforceConfigCacheManager;
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
@ -35,6 +48,36 @@ public class DataiConfigurationServiceImpl implements IDataiConfigurationService
|
||||
return dataiConfigurationMapper.selectDataiConfigurationByConfigId(configId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据配置键查询配置值
|
||||
*
|
||||
* @param configKey 配置键
|
||||
* @return 配置值
|
||||
*/
|
||||
@Override
|
||||
public String selectConfigValueByKey(String configKey) {
|
||||
// 先从缓存获取
|
||||
String configValue = CacheUtils.get(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY, configKey, String.class);
|
||||
if (configValue != null) {
|
||||
return configValue;
|
||||
}
|
||||
|
||||
// 缓存不存在则从数据库查询
|
||||
DataiConfiguration query = new DataiConfiguration();
|
||||
query.setConfigKey(configKey);
|
||||
query.setIsActive(1L);
|
||||
List<DataiConfiguration> configs = dataiConfigurationMapper.selectDataiConfigurationList(query);
|
||||
|
||||
if (!configs.isEmpty()) {
|
||||
configValue = configs.get(0).getConfigValue();
|
||||
// 更新缓存
|
||||
CacheUtils.getCache(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY).put(configKey, configValue);
|
||||
return configValue;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配置列表
|
||||
*
|
||||
@ -56,14 +99,31 @@ public class DataiConfigurationServiceImpl implements IDataiConfigurationService
|
||||
@Override
|
||||
public int insertDataiConfiguration(DataiConfiguration dataiConfiguration)
|
||||
{
|
||||
// 验证配置值合法性
|
||||
if (!validateConfigValue(dataiConfiguration)) {
|
||||
logger.error("配置值验证失败: {}", dataiConfiguration.getConfigKey());
|
||||
return 0;
|
||||
}
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String username = loginUser.getUsername();
|
||||
|
||||
dataiConfiguration.setCreateTime(DateUtils.getNowDate());
|
||||
dataiConfiguration.setUpdateTime(DateUtils.getNowDate());
|
||||
dataiConfiguration.setCreateBy(username);
|
||||
dataiConfiguration.setUpdateBy(username);
|
||||
return dataiConfigurationMapper.insertDataiConfiguration(dataiConfiguration);
|
||||
dataiConfiguration.setCreateTime(DateUtils.getNowDate());
|
||||
dataiConfiguration.setUpdateTime(DateUtils.getNowDate());
|
||||
dataiConfiguration.setCreateBy(username);
|
||||
dataiConfiguration.setUpdateBy(username);
|
||||
|
||||
int result = dataiConfigurationMapper.insertDataiConfiguration(dataiConfiguration);
|
||||
if (result > 0) {
|
||||
// 更新缓存
|
||||
CacheUtils.getCache(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY)
|
||||
.put(dataiConfiguration.getConfigKey(), dataiConfiguration.getConfigValue());
|
||||
|
||||
// 发布配置变更事件
|
||||
publishConfigChangeEvent(dataiConfiguration, "CREATE");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,12 +135,38 @@ public class DataiConfigurationServiceImpl implements IDataiConfigurationService
|
||||
@Override
|
||||
public int updateDataiConfiguration(DataiConfiguration dataiConfiguration)
|
||||
{
|
||||
// 验证配置值合法性
|
||||
if (!validateConfigValue(dataiConfiguration)) {
|
||||
logger.error("配置值验证失败: {}", dataiConfiguration.getConfigKey());
|
||||
return 0;
|
||||
}
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
String username = loginUser.getUsername();
|
||||
|
||||
dataiConfiguration.setUpdateTime(DateUtils.getNowDate());
|
||||
dataiConfiguration.setUpdateBy(username);
|
||||
return dataiConfigurationMapper.updateDataiConfiguration(dataiConfiguration);
|
||||
dataiConfiguration.setUpdateTime(DateUtils.getNowDate());
|
||||
dataiConfiguration.setUpdateBy(username);
|
||||
|
||||
// 获取旧配置,用于审计日志和缓存清理
|
||||
DataiConfiguration oldConfig = selectDataiConfigurationByConfigId(dataiConfiguration.getConfigId());
|
||||
|
||||
int result = dataiConfigurationMapper.updateDataiConfiguration(dataiConfiguration);
|
||||
if (result > 0) {
|
||||
// 如果配置键发生变化,清理旧键的缓存
|
||||
if (oldConfig != null && !oldConfig.getConfigKey().equals(dataiConfiguration.getConfigKey())) {
|
||||
CacheUtils.getCache(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY)
|
||||
.evict(oldConfig.getConfigKey());
|
||||
}
|
||||
|
||||
// 更新缓存
|
||||
CacheUtils.getCache(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY)
|
||||
.put(dataiConfiguration.getConfigKey(), dataiConfiguration.getConfigValue());
|
||||
|
||||
// 发布配置变更事件
|
||||
publishConfigChangeEvent(dataiConfiguration, "UPDATE");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,7 +178,20 @@ public class DataiConfigurationServiceImpl implements IDataiConfigurationService
|
||||
@Override
|
||||
public int deleteDataiConfigurationByConfigIds(Long[] configIds)
|
||||
{
|
||||
return dataiConfigurationMapper.deleteDataiConfigurationByConfigIds(configIds);
|
||||
int result = 0;
|
||||
for (Long configId : configIds) {
|
||||
DataiConfiguration config = selectDataiConfigurationByConfigId(configId);
|
||||
if (config != null) {
|
||||
result += dataiConfigurationMapper.deleteDataiConfigurationByConfigId(configId);
|
||||
// 删除缓存
|
||||
CacheUtils.getCache(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY)
|
||||
.evict(config.getConfigKey());
|
||||
|
||||
// 发布配置变更事件
|
||||
publishConfigChangeEvent(config, "DELETE");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,6 +203,107 @@ public class DataiConfigurationServiceImpl implements IDataiConfigurationService
|
||||
@Override
|
||||
public int deleteDataiConfigurationByConfigId(Long configId)
|
||||
{
|
||||
return dataiConfigurationMapper.deleteDataiConfigurationByConfigId(configId);
|
||||
DataiConfiguration config = selectDataiConfigurationByConfigId(configId);
|
||||
if (config == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int result = dataiConfigurationMapper.deleteDataiConfigurationByConfigId(configId);
|
||||
if (result > 0) {
|
||||
// 删除缓存
|
||||
CacheUtils.getCache(SalesforceConfigConstants.SALESFORCE_CONFIG_CACHE_KEY)
|
||||
.evict(config.getConfigKey());
|
||||
|
||||
// 发布配置变更事件
|
||||
publishConfigChangeEvent(config, "DELETE");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载配置到缓存
|
||||
*/
|
||||
@Override
|
||||
public void loadingConfigCache() {
|
||||
SalesforceConfigCacheManager.loadConfigToCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空配置缓存
|
||||
*/
|
||||
@Override
|
||||
public void clearConfigCache() {
|
||||
SalesforceConfigCacheManager.clearConfigCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置配置缓存
|
||||
*/
|
||||
@Override
|
||||
public void resetConfigCache() {
|
||||
SalesforceConfigCacheManager.resetConfigCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证配置值合法性
|
||||
*
|
||||
* @param dataiConfiguration 配置
|
||||
* @return 验证结果
|
||||
*/
|
||||
@Override
|
||||
public boolean validateConfigValue(DataiConfiguration dataiConfiguration) {
|
||||
// 实现配置值合法性验证逻辑
|
||||
// 例如:检查数值范围、格式验证等
|
||||
String configKey = dataiConfiguration.getConfigKey();
|
||||
String configValue = dataiConfiguration.getConfigValue();
|
||||
|
||||
if (configKey == null || configKey.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 配置值不能为空
|
||||
if (configValue == null || configValue.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 示例:验证API版本格式
|
||||
if (configKey.equals("salesforce.api.version") && !configValue.matches("^\\d+\\.\\d+$")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 示例:验证布尔值
|
||||
if (configKey.contains(".enabled") || configKey.contains(".restricted")) {
|
||||
if (!"true".equals(configValue) && !"false".equals(configValue)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 示例:验证数值范围
|
||||
if (configKey.equals("salesforce.retry.count")) {
|
||||
try {
|
||||
int retryCount = Integer.parseInt(configValue);
|
||||
if (retryCount < 0 || retryCount > 10) {
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布配置变更事件
|
||||
*
|
||||
* @param config 配置对象
|
||||
* @param operationType 操作类型
|
||||
*/
|
||||
private void publishConfigChangeEvent(DataiConfiguration config, String operationType) {
|
||||
logger.info("配置变更事件: {} - {} - {}", operationType, config.getConfigKey(), config.getConfigValue());
|
||||
|
||||
// 发布Spring事件
|
||||
eventPublisher.publishEvent(new com.datai.setting.event.ConfigChangeEvent(this, config, operationType));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,524 @@
|
||||
# 新增接口调用说明文档
|
||||
|
||||
## 1. 文档概述
|
||||
|
||||
本文档详细介绍Salesforce配置管理模块新增的API接口调用方法,包括配置版本管理、配置缓存管理和配置验证等功能的具体操作说明。
|
||||
|
||||
## 2. 配置版本管理接口
|
||||
|
||||
### 2.1 查询版本列表
|
||||
|
||||
**接口说明**:查询所有配置版本信息,支持分页查询
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/version/list`
|
||||
- 方法:GET
|
||||
- 权限:`setting:version:list`
|
||||
- 内容类型:无请求体
|
||||
|
||||
**查询参数**:
|
||||
| 参数名 | 类型 | 描述 | 是否必填 | 默认值 |
|
||||
|-------|------|------|--------|--------|
|
||||
| page | Integer | 页码 | 否 | 1 |
|
||||
| pageSize | Integer | 每页条数 | 否 | 10 |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "查询成功",
|
||||
"data": {
|
||||
"list": [
|
||||
{
|
||||
"versionId": 1,
|
||||
"versionNumber": "2025.12.14.1",
|
||||
"versionDesc": "初始配置快照",
|
||||
"status": "PUBLISHED",
|
||||
"createTime": "2025-12-14T14:30:00",
|
||||
"createBy": "admin"
|
||||
},
|
||||
{
|
||||
"versionId": 2,
|
||||
"versionNumber": "2025.12.14.2",
|
||||
"versionDesc": "修改后快照",
|
||||
"status": "CREATED",
|
||||
"createTime": "2025-12-14T15:30:00",
|
||||
"createBy": "admin"
|
||||
}
|
||||
],
|
||||
"total": 2,
|
||||
"page": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**返回码说明**:
|
||||
- 200:查询成功
|
||||
- 403:权限不足
|
||||
- 500:服务器内部错误
|
||||
|
||||
### 2.2 发布配置版本
|
||||
|
||||
**接口说明**:将指定的配置版本标记为已发布状态,发布后该版本将作为当前生效的配置版本
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/version/{versionId}/publish`
|
||||
- 方法:POST
|
||||
- 权限:`setting:version:publish`
|
||||
- 内容类型:无请求体
|
||||
|
||||
**路径参数**:
|
||||
| 参数名 | 类型 | 描述 | 是否必填 |
|
||||
|-------|------|------|--------|
|
||||
| versionId | Long | 配置版本ID | 是 |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": 1
|
||||
}
|
||||
```
|
||||
|
||||
**响应字段说明**:
|
||||
- `data`:1表示发布成功,0表示发布失败
|
||||
|
||||
**调用示例**:
|
||||
```bash
|
||||
# 使用curl调用
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/version/1/publish
|
||||
|
||||
# 使用Postman调用
|
||||
# Method: POST
|
||||
# URL: http://localhost:8080/setting/version/1/publish
|
||||
# Headers: Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
**占位符说明**:
|
||||
- `<TOKEN>`:用户认证令牌,需要替换为实际的令牌值,可通过登录接口获取
|
||||
|
||||
**返回码说明**:
|
||||
- 200:发布成功
|
||||
- 400:参数错误或版本不存在
|
||||
- 403:权限不足
|
||||
- 500:服务器内部错误
|
||||
|
||||
### 2.2 创建配置快照
|
||||
|
||||
**接口说明**:创建当前配置的完整快照,生成新的配置版本
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/version/snapshot`
|
||||
- 方法:POST
|
||||
- 权限:`setting:version:snapshot`
|
||||
- 内容类型:application/x-www-form-urlencoded
|
||||
|
||||
**请求参数**:
|
||||
| 参数名 | 类型 | 描述 | 是否必填 |
|
||||
|-------|------|------|--------|
|
||||
| versionDesc | String | 版本描述 | 是 |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": {
|
||||
"versionId": 1,
|
||||
"versionNumber": "2025.12.14.1",
|
||||
"versionDesc": "2025年12月14日配置快照",
|
||||
"status": "CREATED",
|
||||
"createTime": "2025-12-14T14:30:00",
|
||||
"createBy": "admin"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**调用示例**:
|
||||
```bash
|
||||
# 使用curl调用
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" \
|
||||
-d "versionDesc=2025年12月14日配置快照" \
|
||||
http://localhost:8080/setting/version/snapshot
|
||||
|
||||
# 使用Postman调用
|
||||
# Method: POST
|
||||
# URL: http://localhost:8080/setting/version/snapshot
|
||||
# Headers: Authorization: Bearer <TOKEN>, Content-Type: application/x-www-form-urlencoded
|
||||
# Body: versionDesc=2025年12月14日配置快照
|
||||
```
|
||||
|
||||
**返回码说明**:
|
||||
- 200:创建快照成功,返回生成的版本信息
|
||||
- 400:参数错误
|
||||
- 403:权限不足
|
||||
- 500:服务器内部错误
|
||||
|
||||
### 2.3 回滚到指定版本
|
||||
|
||||
**接口说明**:将当前配置回滚到指定的历史版本,回滚后会将历史版本的配置恢复到当前配置中
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/version/{versionId}/rollback`
|
||||
- 方法:POST
|
||||
- 权限:`setting:version:rollback`
|
||||
- 内容类型:无请求体
|
||||
|
||||
**路径参数**:
|
||||
| 参数名 | 类型 | 描述 | 是否必填 |
|
||||
|-------|------|------|--------|
|
||||
| versionId | Long | 配置版本ID | 是 |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": 10
|
||||
}
|
||||
```
|
||||
|
||||
**响应字段说明**:
|
||||
- `data`:回滚成功恢复的配置数量
|
||||
|
||||
**调用示例**:
|
||||
```bash
|
||||
# 使用curl调用
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/version/1/rollback
|
||||
|
||||
# 使用Postman调用
|
||||
# Method: POST
|
||||
# URL: http://localhost:8080/setting/version/1/rollback
|
||||
# Headers: Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
**返回码说明**:
|
||||
- 200:回滚成功,返回恢复的配置数量
|
||||
- 400:参数错误或版本不存在
|
||||
- 403:权限不足
|
||||
- 500:服务器内部错误
|
||||
|
||||
## 3. 配置缓存管理接口
|
||||
|
||||
### 3.1 刷新配置缓存
|
||||
|
||||
**接口说明**:手动刷新配置缓存,将数据库中的配置重新加载到缓存中
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration/refresh`
|
||||
- 方法:POST
|
||||
- 权限:`setting:configuration:refresh`
|
||||
- 内容类型:无请求体
|
||||
|
||||
**请求参数**:无
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "配置缓存刷新成功"
|
||||
}
|
||||
```
|
||||
|
||||
**调用示例**:
|
||||
```bash
|
||||
# 使用curl调用
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/configuration/refresh
|
||||
|
||||
# 使用Postman调用
|
||||
# Method: POST
|
||||
# URL: http://localhost:8080/setting/configuration/refresh
|
||||
# Headers: Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
**返回码说明**:
|
||||
- 200:刷新成功
|
||||
- 403:权限不足
|
||||
- 500:服务器内部错误
|
||||
|
||||
### 3.2 查询配置缓存状态
|
||||
|
||||
**接口说明**:查询当前配置缓存的状态信息,包括缓存中的配置数量、缓存大小等
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration/cache/status`
|
||||
- 方法:GET
|
||||
- 权限:`setting:configuration:cache`
|
||||
|
||||
**请求参数**:无
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "配置缓存状态正常",
|
||||
"data": {
|
||||
"cacheName": "salesforce-config-cache",
|
||||
"size": 15,
|
||||
"status": "NORMAL"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**响应字段说明**:
|
||||
- `cacheName`:缓存名称
|
||||
- `size`:缓存中的配置数量
|
||||
- `status`:缓存状态,NORMAL表示正常,ERROR表示异常
|
||||
|
||||
**调用示例**:
|
||||
```bash
|
||||
# 使用curl调用
|
||||
curl -X GET -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/configuration/cache/status
|
||||
|
||||
# 使用Postman调用
|
||||
# Method: GET
|
||||
# URL: http://localhost:8080/setting/configuration/cache/status
|
||||
# Headers: Authorization: Bearer <TOKEN>
|
||||
```
|
||||
|
||||
**返回码说明**:
|
||||
- 200:查询成功
|
||||
- 403:权限不足
|
||||
- 500:服务器内部错误
|
||||
|
||||
## 4. 配置管理接口
|
||||
|
||||
### 4.1 修改配置
|
||||
|
||||
**接口说明**:修改指定配置项的值
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration`
|
||||
- 方法:PUT
|
||||
- 权限:`setting:configuration:update`
|
||||
- 内容类型:application/json
|
||||
|
||||
**请求体**:
|
||||
| 参数名 | 类型 | 描述 | 是否必填 |
|
||||
|-------|------|------|--------|
|
||||
| configId | Long | 配置ID | 是 |
|
||||
| configValue | String | 配置值 | 是 |
|
||||
|
||||
**请求示例**:
|
||||
```json
|
||||
{
|
||||
"configId": 1,
|
||||
"configValue": "61.0"
|
||||
}
|
||||
```
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "配置修改成功",
|
||||
"data": true
|
||||
}
|
||||
```
|
||||
|
||||
**返回码说明**:
|
||||
- 200:修改成功
|
||||
- 400:参数错误
|
||||
- 403:权限不足
|
||||
- 500:服务器内部错误
|
||||
|
||||
## 5. 配置验证接口
|
||||
|
||||
### 5.1 验证配置值合法性
|
||||
|
||||
**接口说明**:验证配置值是否符合预设的合法性规则
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration/validate`
|
||||
- 方法:POST
|
||||
- 权限:`setting:configuration:validate`
|
||||
- 内容类型:application/json
|
||||
|
||||
**请求体**:
|
||||
| 参数名 | 类型 | 描述 | 是否必填 |
|
||||
|-------|------|------|--------|
|
||||
| configKey | String | 配置键 | 是 |
|
||||
| configValue | String | 配置值 | 是 |
|
||||
|
||||
**请求示例**:
|
||||
```json
|
||||
{
|
||||
"configKey": "salesforce.api.version",
|
||||
"configValue": "60.0"
|
||||
}
|
||||
```
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "配置值验证通过"
|
||||
}
|
||||
```
|
||||
|
||||
**验证失败响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 400,
|
||||
"msg": "配置值验证失败",
|
||||
"data": "配置值必须为数字.数字格式"
|
||||
}
|
||||
```
|
||||
|
||||
**调用示例**:
|
||||
```bash
|
||||
# 使用curl调用
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" \
|
||||
-d '{"configKey":"salesforce.api.version","configValue":"60.0"}' \
|
||||
http://localhost:8080/setting/configuration/validate
|
||||
|
||||
# 使用Postman调用
|
||||
# Method: POST
|
||||
# URL: http://localhost:8080/setting/configuration/validate
|
||||
# Headers: Authorization: Bearer <TOKEN>, Content-Type: application/json
|
||||
# Body: {"configKey":"salesforce.api.version","configValue":"60.0"}
|
||||
```
|
||||
|
||||
**返回码说明**:
|
||||
- 200:验证通过
|
||||
- 400:参数错误或配置值验证失败
|
||||
- 403:权限不足
|
||||
- 500:服务器内部错误
|
||||
|
||||
## 5. 接口调用流程示例
|
||||
|
||||
### 5.1 配置修改与发布流程
|
||||
|
||||
1. **查询当前配置**:
|
||||
```bash
|
||||
curl -X GET -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/configuration/list
|
||||
```
|
||||
|
||||
2. **创建配置快照**:
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" -d "versionDesc=修改前快照" http://localhost:8080/setting/version/snapshot
|
||||
```
|
||||
|
||||
3. **修改配置**:
|
||||
```bash
|
||||
curl -X PUT -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" \
|
||||
-d '{"configId":1,"configValue":"61.0"}' \
|
||||
http://localhost:8080/setting/configuration
|
||||
```
|
||||
|
||||
4. **验证配置值**:
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" \
|
||||
-d '{"configKey":"salesforce.api.version","configValue":"61.0"}' \
|
||||
http://localhost:8080/setting/configuration/validate
|
||||
```
|
||||
|
||||
5. **刷新配置缓存**:
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/configuration/refresh
|
||||
```
|
||||
|
||||
6. **发布配置版本**:
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/version/2/publish
|
||||
```
|
||||
|
||||
### 5.2 配置回滚流程
|
||||
|
||||
1. **查询版本列表**:
|
||||
```bash
|
||||
curl -X GET -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/version/list
|
||||
```
|
||||
|
||||
2. **回滚到指定版本**:
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/version/1/rollback
|
||||
```
|
||||
|
||||
3. **验证回滚结果**:
|
||||
```bash
|
||||
curl -X GET -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/configuration/list?configKey=salesforce.api.version
|
||||
```
|
||||
|
||||
4. **刷新配置缓存**:
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/configuration/refresh
|
||||
```
|
||||
|
||||
## 6. 常见问题与解决方案
|
||||
|
||||
### 6.1 权限相关问题
|
||||
|
||||
**问题**:调用接口时返回403权限不足
|
||||
|
||||
**解决方案**:
|
||||
- 确认当前用户是否有对应的权限
|
||||
- 联系管理员分配相应权限
|
||||
- 检查令牌是否过期,重新获取令牌
|
||||
|
||||
### 6.2 参数相关问题
|
||||
|
||||
**问题**:调用接口时返回400参数错误
|
||||
|
||||
**解决方案**:
|
||||
- 检查路径参数是否正确
|
||||
- 检查请求体格式是否符合要求
|
||||
- 检查必填参数是否都已提供
|
||||
|
||||
### 6.3 版本相关问题
|
||||
|
||||
**问题**:回滚版本时返回版本不存在
|
||||
|
||||
**解决方案**:
|
||||
- 检查版本ID是否正确
|
||||
- 确认该版本是否存在且未被删除
|
||||
- 查询版本列表确认可用版本
|
||||
|
||||
### 6.4 缓存相关问题
|
||||
|
||||
**问题**:刷新缓存后配置未生效
|
||||
|
||||
**解决方案**:
|
||||
- 检查数据库中配置是否正确
|
||||
- 检查Redis服务是否正常运行
|
||||
- 确认缓存键是否正确
|
||||
|
||||
## 7. 最佳实践
|
||||
|
||||
1. **配置修改前创建快照**:在进行重大配置修改前,先创建配置快照,便于后续回滚
|
||||
2. **定期发布正式版本**:定期将稳定的配置发布为正式版本,便于管理和回滚
|
||||
3. **严格控制权限**:配置管理权限应该严格控制,只授予必要的人员
|
||||
4. **验证配置值**:在修改配置前,使用验证接口确认配置值合法性
|
||||
5. **及时刷新缓存**:配置修改后,及时刷新缓存确保配置立即生效
|
||||
|
||||
## 8. 附录
|
||||
|
||||
### 8.1 权限列表
|
||||
|
||||
| 权限标识 | 权限名称 | 适用接口 |
|
||||
|---------|---------|---------|
|
||||
| setting:version:list | 查询版本列表 | /setting/version/list |
|
||||
| setting:version:publish | 发布配置版本 | /setting/version/{versionId}/publish |
|
||||
| setting:version:snapshot | 创建配置快照 | /setting/version/snapshot |
|
||||
| setting:version:rollback | 回滚配置版本 | /setting/version/{versionId}/rollback |
|
||||
| setting:configuration:update | 修改配置 | /setting/configuration |
|
||||
| setting:configuration:refresh | 刷新配置缓存 | /setting/configuration/refresh |
|
||||
| setting:configuration:cache | 查询缓存状态 | /setting/configuration/cache/status |
|
||||
| setting:configuration:validate | 验证配置值 | /setting/configuration/validate |
|
||||
|
||||
### 8.2 配置键验证规则
|
||||
|
||||
| 配置键模式 | 验证规则 | 示例 |
|
||||
|---------|---------|-----|
|
||||
| salesforce.api.version | 必须为数字.数字格式(不区分大小写) | 60.0 |
|
||||
| *.enabled | 必须为true或false(不区分大小写) | true |
|
||||
| *.restricted | 必须为true或false(不区分大小写) | false |
|
||||
| salesforce.retry.count | 必须为0-10之间的整数 | 5 |
|
||||
|
||||
### 8.3 联系方式
|
||||
|
||||
- 维护团队:Datai开发团队
|
||||
- 联系邮箱:dev@datai.com
|
||||
- 文档更新时间:2024-12-14
|
||||
@ -0,0 +1,357 @@
|
||||
# Salesforce配置管理模块使用文档
|
||||
|
||||
## 1. 文档概述
|
||||
|
||||
本文档详细介绍Salesforce配置管理模块的API接口使用方法,包括配置管理、版本管理、审计日志等功能的具体操作步骤和示例。
|
||||
|
||||
## 2. 快速开始
|
||||
|
||||
### 2.1 环境准备
|
||||
- 确保模块已成功部署并运行
|
||||
- 获取访问令牌(JWT Token或其他认证方式)
|
||||
- 确认API基础URL,如:`http://localhost:8080`
|
||||
|
||||
### 2.2 基本调用格式
|
||||
```bash
|
||||
curl -X <METHOD> -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" <BASE_URL>/<API_PATH> [--data <REQUEST_BODY>]
|
||||
```
|
||||
|
||||
## 3. API接口使用指南
|
||||
|
||||
### 3.1 配置管理接口
|
||||
|
||||
#### 3.1.1 查询配置列表
|
||||
**接口说明**:查询系统中的配置列表,支持条件过滤
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration/list`
|
||||
- 方法:GET
|
||||
- 权限:`setting:configuration:list`
|
||||
|
||||
**请求参数**:
|
||||
| 参数名 | 类型 | 描述 | 是否必填 |
|
||||
|-------|------|------|--------|
|
||||
| configKey | String | 配置键 | 否 |
|
||||
| environmentId | Long | 环境ID | 否 |
|
||||
| isActive | Long | 是否激活(1-激活,0-停用) | 否 |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"rows": [
|
||||
{
|
||||
"configId": 1,
|
||||
"configKey": "salesforce.api.version",
|
||||
"configValue": "59.0",
|
||||
"environmentId": 1,
|
||||
"isActive": 1,
|
||||
"description": "Salesforce API版本"
|
||||
}
|
||||
],
|
||||
"total": 1
|
||||
}
|
||||
```
|
||||
|
||||
**调用示例**:
|
||||
```bash
|
||||
curl -X GET -H "Authorization: Bearer <TOKEN>" http://localhost:8080/setting/configuration/list?configKey=salesforce.api.version
|
||||
```
|
||||
|
||||
#### 3.1.2 新增配置
|
||||
**接口说明**:新增一条配置记录
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration`
|
||||
- 方法:POST
|
||||
- 权限:`setting:configuration:add`
|
||||
|
||||
**请求体**:
|
||||
```json
|
||||
{
|
||||
"configKey": "salesforce.login.url",
|
||||
"configValue": "https://login.salesforce.com",
|
||||
"environmentId": 1,
|
||||
"isActive": 1,
|
||||
"isSensitive": 0,
|
||||
"isEncrypted": 0,
|
||||
"description": "Salesforce登录URL"
|
||||
}
|
||||
```
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": 1
|
||||
}
|
||||
```
|
||||
|
||||
**调用示例**:
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" \
|
||||
--data '{"configKey":"salesforce.login.url","configValue":"https://login.salesforce.com","environmentId":1,"isActive":1,"description":"Salesforce登录URL"}' \
|
||||
http://localhost:8080/setting/configuration
|
||||
```
|
||||
|
||||
#### 3.1.3 修改配置
|
||||
**接口说明**:修改现有配置记录
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration`
|
||||
- 方法:PUT
|
||||
- 权限:`setting:configuration:edit`
|
||||
|
||||
**请求体**:
|
||||
```json
|
||||
{
|
||||
"configId": 1,
|
||||
"configValue": "60.0",
|
||||
"description": "更新后的Salesforce API版本"
|
||||
}
|
||||
```
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": 1
|
||||
}
|
||||
```
|
||||
|
||||
#### 3.1.4 删除配置
|
||||
**接口说明**:批量删除配置记录
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration/{configIds}`
|
||||
- 方法:DELETE
|
||||
- 权限:`setting:configuration:remove`
|
||||
|
||||
**请求参数**:
|
||||
- configIds:配置ID数组,如:`1,2,3`
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": 3
|
||||
}
|
||||
```
|
||||
|
||||
#### 3.1.5 刷新配置缓存
|
||||
**接口说明**:手动刷新配置缓存
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration/refresh`
|
||||
- 方法:POST
|
||||
- 权限:`setting:configuration:refresh`
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "配置缓存刷新成功"
|
||||
}
|
||||
```
|
||||
|
||||
#### 3.1.6 验证配置值合法性
|
||||
**接口说明**:验证配置值是否符合预设规则
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/configuration/validate`
|
||||
- 方法:POST
|
||||
- 权限:`setting:configuration:validate`
|
||||
|
||||
**请求体**:
|
||||
```json
|
||||
{
|
||||
"configKey": "salesforce.api.version",
|
||||
"configValue": "60.0"
|
||||
}
|
||||
```
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "配置值验证通过"
|
||||
}
|
||||
```
|
||||
|
||||
### 3.2 配置版本管理接口
|
||||
|
||||
#### 3.2.1 创建配置快照
|
||||
**接口说明**:创建当前配置的快照,生成新的版本
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/version/snapshot`
|
||||
- 方法:POST
|
||||
- 权限:`setting:version:snapshot`
|
||||
|
||||
**请求参数**:
|
||||
- versionDesc:版本描述,如:`"2025年12月14日配置快照"`
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": {
|
||||
"versionId": 1,
|
||||
"versionNumber": "2025.12.14.1",
|
||||
"versionDesc": "2025年12月14日配置快照",
|
||||
"status": "CREATED"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**调用示例**:
|
||||
```bash
|
||||
curl -X POST -H "Authorization: Bearer <TOKEN>" \
|
||||
http://localhost:8080/setting/version/snapshot?versionDesc=2025年12月14日配置快照
|
||||
```
|
||||
|
||||
#### 3.2.2 发布配置版本
|
||||
**接口说明**:发布指定的配置版本
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/version/{versionId}/publish`
|
||||
- 方法:POST
|
||||
- 权限:`setting:version:publish`
|
||||
|
||||
**请求参数**:
|
||||
- versionId:版本ID,如:`1`
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": 1
|
||||
}
|
||||
```
|
||||
|
||||
#### 3.2.3 回滚到指定版本
|
||||
**接口说明**:将配置回滚到指定的历史版本
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/version/{versionId}/rollback`
|
||||
- 方法:POST
|
||||
- 权限:`setting:version:rollback`
|
||||
|
||||
**请求参数**:
|
||||
- versionId:版本ID,如:`1`
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"data": 10
|
||||
}
|
||||
```
|
||||
|
||||
### 3.3 配置审计日志接口
|
||||
|
||||
#### 3.3.1 查询审计日志
|
||||
**接口说明**:查询配置操作的审计日志
|
||||
|
||||
**接口信息**:
|
||||
- URL:`/setting/log/list`
|
||||
- 方法:GET
|
||||
- 权限:`setting:log:list`
|
||||
|
||||
**请求参数**:
|
||||
| 参数名 | 类型 | 描述 | 是否必填 |
|
||||
|-------|------|------|--------|
|
||||
| operationType | String | 操作类型(CREATE、UPDATE、DELETE、PUBLISH、ROLLBACK) | 否 |
|
||||
| operator | String | 操作人 | 否 |
|
||||
| beginTime | String | 开始时间(格式:YYYY-MM-DD HH:mm:ss) | 否 |
|
||||
| endTime | String | 结束时间(格式:YYYY-MM-DD HH:mm:ss) | 否 |
|
||||
|
||||
**响应示例**:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "操作成功",
|
||||
"rows": [
|
||||
{
|
||||
"logId": 1,
|
||||
"operationType": "UPDATE",
|
||||
"objectType": "DATAI_CONFIGURATION",
|
||||
"operator": "admin",
|
||||
"operationTime": "2025-12-14 14:30:00",
|
||||
"ipAddress": "127.0.0.1",
|
||||
"result": "SUCCESS"
|
||||
}
|
||||
],
|
||||
"total": 1
|
||||
}
|
||||
```
|
||||
|
||||
## 4. 常见操作示例
|
||||
|
||||
### 4.1 完整的配置管理流程
|
||||
|
||||
1. **查询现有配置**:确认当前配置状态
|
||||
2. **创建配置快照**:在修改前创建快照,便于回滚
|
||||
3. **修改配置**:更新配置值
|
||||
4. **验证配置**:确保配置值合法
|
||||
5. **刷新缓存**:使配置立即生效
|
||||
6. **发布版本**:将当前配置标记为正式版本
|
||||
|
||||
### 4.2 配置回滚示例
|
||||
|
||||
1. **查询版本列表**:获取可用的历史版本
|
||||
2. **回滚到指定版本**:执行回滚操作
|
||||
3. **验证回滚结果**:查询配置确认回滚成功
|
||||
4. **刷新缓存**:确保缓存同步
|
||||
|
||||
## 5. 最佳实践
|
||||
|
||||
### 5.1 配置命名规范
|
||||
- 使用点分隔的命名方式,如:`salesforce.api.version`
|
||||
- 遵循模块.功能.属性的命名规则
|
||||
- 避免使用特殊字符和空格
|
||||
|
||||
### 5.2 版本管理建议
|
||||
- 重大变更前创建快照
|
||||
- 定期发布正式版本
|
||||
- 保留重要的历史版本
|
||||
- 为版本添加清晰的描述
|
||||
|
||||
### 5.3 安全注意事项
|
||||
- 敏感配置设置为敏感标记,系统会自动加密存储
|
||||
- 定期审核配置操作日志
|
||||
- 严格控制配置修改权限
|
||||
- 避免在配置中存储明文密码
|
||||
|
||||
## 6. 故障排除
|
||||
|
||||
### 6.1 常见错误及解决方案
|
||||
|
||||
| 错误信息 | 可能原因 | 解决方案 |
|
||||
|---------|---------|--------|
|
||||
| 权限不足 | 没有对应的操作权限 | 联系管理员获取权限 |
|
||||
| 配置键已存在 | 同一环境下配置键重复 | 更换配置键或删除现有配置 |
|
||||
| 配置值验证失败 | 配置值不符合预设规则 | 检查配置值格式和范围 |
|
||||
| 版本不存在 | 回滚的版本ID不存在 | 确认版本ID是否正确 |
|
||||
| 缓存刷新失败 | Redis连接问题 | 检查Redis服务状态 |
|
||||
|
||||
### 6.2 日志查看
|
||||
|
||||
配置管理模块的日志位于应用日志中,主要包括:
|
||||
- 配置加载日志:记录系统启动时的配置加载过程
|
||||
- 操作审计日志:记录所有配置操作
|
||||
- 错误日志:记录系统异常信息
|
||||
|
||||
### 6.3 联系方式
|
||||
|
||||
如果遇到无法解决的问题,请联系:
|
||||
- 维护团队:Datai开发团队
|
||||
- 联系邮箱:dev@datai.com
|
||||
- 文档更新时间:2025-12-14
|
||||
@ -0,0 +1,167 @@
|
||||
# Salesforce配置管理模块说明文档
|
||||
|
||||
## 1. 模块概述
|
||||
|
||||
Salesforce配置管理模块是一个用于管理Salesforce相关配置的核心模块,提供配置的加载、缓存、更新、版本管理和回滚等功能。该模块采用分布式架构设计,支持多环境配置隔离,确保配置的安全性和可靠性。
|
||||
|
||||
## 2. 功能特性
|
||||
|
||||
### 2.1 配置加载流程
|
||||
- 系统启动时自动加载配置到缓存
|
||||
- 支持按环境(开发/测试/生产)加载差异化配置
|
||||
- 配置完整性验证和合法性校验
|
||||
- 详细的配置加载日志记录
|
||||
|
||||
### 2.2 配置更新流程
|
||||
- 配置更新API接口
|
||||
- 配置值合法性验证
|
||||
- Redis缓存优先更新策略
|
||||
- 配置版本号自动递增
|
||||
- 配置变更事件发布
|
||||
- 审计日志记录
|
||||
|
||||
### 2.3 配置版本管理
|
||||
- 配置快照生成
|
||||
- 版本状态管理(已创建、已发布)
|
||||
- 版本发布功能
|
||||
- 版本回滚功能
|
||||
|
||||
### 2.4 配置回滚流程
|
||||
- 回滚API接口
|
||||
- 回滚权限验证和版本合法性校验
|
||||
- 历史快照恢复
|
||||
- 缓存与数据库双更新
|
||||
|
||||
### 2.5 配置审计日志
|
||||
- 覆盖所有配置操作
|
||||
- 记录操作人、时间、IP地址等信息
|
||||
- 支持按条件查询
|
||||
- 支持日志导出
|
||||
|
||||
## 3. 技术架构
|
||||
|
||||
### 3.1 整体架构
|
||||
- 采用Spring Boot框架开发
|
||||
- 基于RESTful API设计
|
||||
- 支持Redis缓存
|
||||
- 数据库采用MySQL
|
||||
- 支持多租户隔离
|
||||
|
||||
### 3.2 核心组件
|
||||
- 配置加载服务:负责系统启动时配置初始化
|
||||
- 配置缓存管理器:管理配置缓存
|
||||
- 配置版本服务:处理配置版本管理
|
||||
- 配置变更事件:实现配置动态生效
|
||||
- 审计日志服务:记录配置操作日志
|
||||
|
||||
### 3.3 数据存储
|
||||
- 配置表:存储实际的配置键值对
|
||||
- 配置版本表:存储配置版本信息
|
||||
- 配置环境表:存储环境信息
|
||||
- 配置审计日志表:存储审计日志
|
||||
- 配置快照表:存储配置快照
|
||||
|
||||
## 4. 模块结构
|
||||
|
||||
```
|
||||
├── controller/ # 控制器层
|
||||
│ ├── DataiConfigurationController.java # 配置管理控制器
|
||||
│ ├── DataiConfigVersionController.java # 配置版本控制器
|
||||
│ ├── DataiConfigAuditLogController.java # 审计日志控制器
|
||||
│ ├── DataiConfigEnvironmentController.java # 环境管理控制器
|
||||
│ └── DataiConfigSnapshotController.java # 快照管理控制器
|
||||
├── domain/ # 实体层
|
||||
│ ├── DataiConfiguration.java # 配置实体
|
||||
│ ├── DataiConfigVersion.java # 版本实体
|
||||
│ ├── DataiConfigAuditLog.java # 审计日志实体
|
||||
│ ├── DataiConfigEnvironment.java # 环境实体
|
||||
│ └── DataiConfigSnapshot.java # 快照实体
|
||||
├── mapper/ # 数据访问层
|
||||
│ ├── DataiConfigurationMapper.java # 配置Mapper
|
||||
│ ├── DataiConfigVersionMapper.java # 版本Mapper
|
||||
│ ├── DataiConfigAuditLogMapper.java # 审计日志Mapper
|
||||
│ ├── DataiConfigEnvironmentMapper.java # 环境Mapper
|
||||
│ └── DataiConfigSnapshotMapper.java # 快照Mapper
|
||||
├── service/ # 服务层
|
||||
│ ├── IDataiConfigurationService.java # 配置服务接口
|
||||
│ ├── IDataiConfigVersionService.java # 版本服务接口
|
||||
│ ├── IDataiConfigAuditLogService.java # 审计日志服务接口
|
||||
│ ├── IDataiConfigEnvironmentService.java # 环境服务接口
|
||||
│ ├── IDataiConfigSnapshotService.java # 快照服务接口
|
||||
│ └── impl/ # 服务实现
|
||||
├── config/ # 配置类
|
||||
│ └── SalesforceConfigCacheManager.java # 配置缓存管理器
|
||||
└── event/ # 事件相关
|
||||
├── ConfigChangeEvent.java # 配置变更事件
|
||||
└── ConfigChangeListener.java # 事件监听器
|
||||
```
|
||||
|
||||
## 5. 核心API接口
|
||||
|
||||
### 5.1 配置管理接口
|
||||
- 查询配置列表:`GET /setting/configuration/list`
|
||||
- 新增配置:`POST /setting/configuration`
|
||||
- 修改配置:`PUT /setting/configuration`
|
||||
- 删除配置:`DELETE /setting/configuration/{configIds}`
|
||||
- 刷新配置缓存:`POST /setting/configuration/refresh`
|
||||
- 验证配置值:`POST /setting/configuration/validate`
|
||||
|
||||
### 5.2 配置版本接口
|
||||
- 查询版本列表:`GET /setting/version/list`
|
||||
- 创建快照:`POST /setting/version/snapshot`
|
||||
- 发布版本:`POST /setting/version/{versionId}/publish`
|
||||
- 回滚版本:`POST /setting/version/{versionId}/rollback`
|
||||
|
||||
## 6. 部署说明
|
||||
|
||||
### 6.1 环境要求
|
||||
- JDK 11+
|
||||
- Spring Boot 3.5.7
|
||||
- MySQL 8.0+
|
||||
- Redis 6.0+
|
||||
|
||||
### 6.2 部署流程
|
||||
1. 执行数据库初始化脚本:`salesforce-config-tables.sql`
|
||||
2. 配置数据库连接信息
|
||||
3. 配置Redis连接信息
|
||||
4. 启动应用服务
|
||||
|
||||
## 7. 监控与维护
|
||||
|
||||
### 7.1 日志管理
|
||||
- 配置加载日志:记录配置加载过程
|
||||
- 操作审计日志:记录所有配置操作
|
||||
- 错误日志:记录系统异常信息
|
||||
|
||||
### 7.2 常见问题
|
||||
- 配置加载失败:检查数据库连接和配置表结构
|
||||
- 缓存不同步:调用刷新缓存接口
|
||||
- 版本回滚失败:检查版本合法性和权限
|
||||
|
||||
## 8. 开发规范
|
||||
|
||||
### 8.1 代码规范
|
||||
- 遵循Java编码规范
|
||||
- 使用Spring Boot最佳实践
|
||||
- 接口设计遵循RESTful风格
|
||||
- 代码注释完整
|
||||
|
||||
### 8.2 安全规范
|
||||
- 敏感配置加密存储
|
||||
- 接口访问权限控制
|
||||
- 操作审计日志记录
|
||||
- 输入参数验证
|
||||
|
||||
## 9. 未来规划
|
||||
|
||||
- 支持配置导入导出功能
|
||||
- 增强配置验证规则
|
||||
- 支持配置变更通知到外部系统
|
||||
- 提供配置可视化管理界面
|
||||
- 支持配置灰度发布
|
||||
|
||||
## 10. 联系方式
|
||||
|
||||
- 维护团队:Datai开发团队
|
||||
- 联系邮箱:dev@datai.com
|
||||
- 文档更新时间:2025-12-14
|
||||
@ -0,0 +1,49 @@
|
||||
1 配置加载流程(系统启动/配置刷新核心机制)
|
||||
- 实现系统启动阶段的配置初始化机制,从指定数据库表中加载所有配置项
|
||||
- 开发环境隔离策略,支持按环境(开发/测试/生产)加载差异化配置
|
||||
- 设计配置完整性验证规则,确保必填配置项存在且格式正确
|
||||
- 实现配置合法性校验逻辑,验证配置值符合预设约束条件
|
||||
- 开发Redis缓存存储模块,将加载的配置以指定结构存储到Redis
|
||||
- 设计详细的配置加载日志记录机制,包括加载时间、配置数量、耗时、异常信息等
|
||||
|
||||
2 配置更新流程(客户端配置修改处理机制)
|
||||
- 开发配置更新API接口,接收客户端配置修改请求
|
||||
- 实现配置值合法性验证逻辑,拒绝非法配置值
|
||||
- 设计缓存优先更新策略,确保缓存与数据库一致性
|
||||
- 开发数据库配置更新模块,持久化存储配置变更
|
||||
- 实现配置版本号自动递增机制,记录每次配置变更
|
||||
- 开发配置变更事件发布系统,通知相关服务配置已更新
|
||||
- 设计审计日志记录规范,记录操作人、操作时间、变更内容等关键信息
|
||||
|
||||
3 配置变更事件处理流程(配置动态生效机制)
|
||||
- 实现事件发布机制,在配置更新完成后自动发布配置变更事件
|
||||
- 开发事件监听器注册系统,支持多模块监听配置变更
|
||||
- 设计事件处理接口规范,确保各模块能实现自定义配置变更处理逻辑
|
||||
- 开发组件重新初始化机制,支持关键组件在配置变更后动态应用新配置
|
||||
- 实现事件处理日志记录系统,记录事件处理状态、耗时、结果等信息
|
||||
|
||||
4 配置版本管理流程(配置历史快照与回溯机制)
|
||||
- 开发版本创建API,接收客户端传入的版本描述信息
|
||||
- 实现配置快照生成机制,完整记录当前所有配置项状态
|
||||
- 设计版本表结构,存储配置快照及版本元数据
|
||||
- 实现版本状态管理机制,支持"已创建"、"已发布"等状态流转
|
||||
- 开发版本发布功能,支持将特定版本标记为当前生效版本
|
||||
- 实现版本管理审计日志,记录版本创建、发布等关键操作
|
||||
|
||||
5 配置回滚流程(配置历史版本恢复机制)
|
||||
- 开发回滚API接口,接收客户端传入的目标版本号
|
||||
- 实现回滚权限验证和版本合法性校验机制
|
||||
- 开发历史快照恢复模块,从指定版本加载配置数据
|
||||
- 实现缓存与数据库双更新机制,确保回滚后配置一致性
|
||||
- 开发回滚事件发布机制,触发相关组件配置更新
|
||||
- 实现回滚审计日志,记录回滚操作详情、操作人员、时间等信息
|
||||
|
||||
6 配置审计日志流程(配置操作可追溯机制)
|
||||
- 设计审计日志触发机制,覆盖配置创建、更新、删除、回滚等所有操作
|
||||
- 开发操作信息收集模块,捕获操作人、操作时间、操作类型、IP地址、变更内容等信息
|
||||
- 实现审计日志持久化存储机制,确保日志数据安全可靠
|
||||
- 开发日志查询API,支持按时间、操作人、操作类型等条件查询
|
||||
- 实现日志导出功能,支持将审计日志导出为指定格式文件
|
||||
|
||||
所有流程实现需遵循模块现有代码规范,确保与系统其他模块接口兼容,并编写完整的单元测试和集成测试用例。
|
||||
|
||||
@ -49,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="publishTime != null "> and dcv.publish_time = #{publishTime}</if>
|
||||
<if test="tenantId != null and tenantId != ''"> and dcv.tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
order by dcv.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectDataiConfigVersionByVersionId" parameterType="Long" resultMap="DataiConfigVersionResult">
|
||||
@ -117,4 +118,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{versionId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="countVersionsByDate" parameterType="String" resultType="int">
|
||||
select count(*) from datai_config_version
|
||||
where date(create_time) = #{date}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -123,4 +123,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{configId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAllConfigurations">
|
||||
delete from datai_configuration
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -0,0 +1,235 @@
|
||||
-- datai-salesforce-config 模块数据库表结构
|
||||
-- 该模块负责系统配置的管理,包括配置的加载、缓存、更新和变更通知
|
||||
|
||||
-- -----------------------------
|
||||
-- 配置环境表 (datai_config_environment)
|
||||
-- -----------------------------
|
||||
-- 用途:存储配置环境信息,支持多环境隔离,如开发、测试、生产等
|
||||
-- 设计考虑:
|
||||
-- 1. 支持环境的激活/停用状态管理
|
||||
-- 2. 环境编码唯一,确保环境标识的一致性
|
||||
-- 3. 支持租户隔离,满足多租户需求
|
||||
-- 4. 包含完整的审计字段,便于追溯
|
||||
CREATE TABLE `datai_config_environment` (
|
||||
-- 环境ID,自增主键,唯一标识一个环境
|
||||
`environment_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '环境ID',
|
||||
-- 环境名称,用于显示,如"开发环境"、"生产环境"
|
||||
`environment_name` VARCHAR(100) NOT NULL COMMENT '环境名称',
|
||||
-- 环境编码,用于系统内部标识,如"dev"、"test"、"prod"
|
||||
`environment_code` VARCHAR(50) NOT NULL COMMENT '环境编码',
|
||||
-- 环境描述,详细说明环境的用途和特点
|
||||
`description` VARCHAR(500) DEFAULT NULL COMMENT '环境描述',
|
||||
-- 是否激活,1:激活,0:停用,激活状态的环境才能被使用
|
||||
`is_active` INT(1) NOT NULL DEFAULT '1' COMMENT '是否激活',
|
||||
-- 创建人,记录创建环境的用户
|
||||
`create_by` VARCHAR(64) NOT NULL COMMENT '创建人',
|
||||
-- 创建时间,记录环境创建的时间
|
||||
`create_time` DATETIME NOT NULL COMMENT '创建时间',
|
||||
-- 更新人,记录最后更新环境的用户
|
||||
`update_by` VARCHAR(64) NOT NULL COMMENT '更新人',
|
||||
-- 更新时间,记录环境最后更新的时间
|
||||
`update_time` DATETIME NOT NULL COMMENT '更新时间',
|
||||
-- 备注,存储环境的额外信息
|
||||
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||
-- 租户编号,支持多租户隔离,不同租户的环境相互独立
|
||||
`tenant_id` VARCHAR(32) DEFAULT NULL COMMENT '租户编号',
|
||||
-- 主键索引,唯一标识环境记录
|
||||
PRIMARY KEY (`environment_id`) COMMENT '主键索引',
|
||||
-- 唯一约束,确保环境编码在系统中唯一
|
||||
UNIQUE KEY `uk_environment_code` (`environment_code`) COMMENT '唯一约束',
|
||||
-- 普通索引,加速环境名称的查询
|
||||
KEY `idx_environment_name` (`environment_name`) COMMENT '普通索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置环境表';
|
||||
|
||||
|
||||
-- -----------------------------
|
||||
-- 配置表 (datai_configuration)
|
||||
-- -----------------------------
|
||||
-- 用途:存储实际的配置键值对,是配置管理的核心表
|
||||
-- 设计考虑:
|
||||
-- 1. 支持环境隔离,同一配置键在不同环境下可以有不同的值
|
||||
-- 2. 支持敏感配置加密存储,提高系统安全性
|
||||
-- 3. 支持配置的激活/停用状态管理
|
||||
-- 4. 支持租户隔离,满足多租户需求
|
||||
-- 5. 包含完整的审计字段,便于追溯
|
||||
CREATE TABLE `datai_configuration` (
|
||||
-- 配置ID,自增主键,唯一标识一个配置项
|
||||
`config_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '配置ID',
|
||||
-- 配置键,系统中唯一标识一个配置,如"salesforce.api.version"、"salesforce.login.url"
|
||||
`config_key` VARCHAR(255) NOT NULL COMMENT '配置键',
|
||||
-- 配置值,配置项的实际值,敏感配置会被加密存储
|
||||
`config_value` TEXT COMMENT '配置值',
|
||||
-- 环境ID,关联到配置环境表,支持多环境隔离,NULL表示全局配置
|
||||
`environment_id` BIGINT(20) DEFAULT NULL COMMENT '环境ID',
|
||||
-- 是否敏感配置,1:是,0:否,敏感配置会被特殊处理和显示
|
||||
`is_sensitive` INT(1) NOT NULL DEFAULT '0' COMMENT '是否敏感配置',
|
||||
-- 是否加密存储,1:是,0:否,敏感配置会被加密后存储
|
||||
`is_encrypted` INT(1) NOT NULL DEFAULT '0' COMMENT '是否加密存储',
|
||||
-- 配置描述,详细说明配置项的用途和使用方法
|
||||
`description` VARCHAR(500) DEFAULT NULL COMMENT '配置描述',
|
||||
-- 是否激活,1:激活,0:停用,激活状态的配置才能被使用
|
||||
`is_active` INT(1) NOT NULL DEFAULT '1' COMMENT '是否激活',
|
||||
-- 创建人,记录创建配置的用户
|
||||
`create_by` VARCHAR(64) NOT NULL COMMENT '创建人',
|
||||
-- 创建时间,记录配置创建的时间
|
||||
`create_time` DATETIME NOT NULL COMMENT '创建时间',
|
||||
-- 更新人,记录最后更新配置的用户
|
||||
`update_by` VARCHAR(64) NOT NULL COMMENT '更新人',
|
||||
-- 更新时间,记录配置最后更新的时间
|
||||
`update_time` DATETIME NOT NULL COMMENT '更新时间',
|
||||
-- 备注,存储配置的额外信息
|
||||
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||
-- 租户编号,支持多租户隔离,不同租户的配置相互独立
|
||||
`tenant_id` VARCHAR(32) DEFAULT NULL COMMENT '租户编号',
|
||||
-- 主键索引,唯一标识配置记录
|
||||
PRIMARY KEY (`config_id`) COMMENT '主键索引',
|
||||
-- 唯一约束,确保同一环境下配置键唯一
|
||||
UNIQUE KEY `uk_config_key_environment` (`config_key`,`environment_id`) COMMENT '唯一约束',
|
||||
-- 普通索引,加速按环境查询配置
|
||||
KEY `idx_environment_id` (`environment_id`) COMMENT '普通索引',
|
||||
-- 普通索引,加速按配置键查询配置
|
||||
KEY `idx_config_key` (`config_key`) COMMENT '普通索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置表';
|
||||
|
||||
-- -----------------------------
|
||||
-- 配置版本表 (datai_config_version)
|
||||
-- -----------------------------
|
||||
-- 用途:存储配置版本信息,支持配置的版本控制和回滚
|
||||
-- 设计考虑:
|
||||
-- 1. 支持版本号、版本描述的管理
|
||||
-- 2. 支持版本状态的生命周期管理(已创建、已发布、已废弃)
|
||||
-- 3. 关联配置快照,支持配置的完整回滚
|
||||
-- 4. 支持租户隔离,满足多租户需求
|
||||
-- 5. 包含完整的审计字段,便于追溯
|
||||
CREATE TABLE `datai_config_version` (
|
||||
-- 版本ID,自增主键,唯一标识一个配置版本
|
||||
`version_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '版本ID',
|
||||
-- 版本号,如"1.0.0"、"1.1.0",遵循语义化版本规范
|
||||
`version_number` VARCHAR(50) NOT NULL COMMENT '版本号',
|
||||
-- 版本描述,详细说明该版本的变更内容和用途
|
||||
`version_desc` VARCHAR(500) DEFAULT NULL COMMENT '版本描述',
|
||||
-- 快照ID,关联到配置快照表,存储版本对应的配置快照
|
||||
`snapshot_id` VARCHAR(36) DEFAULT NULL COMMENT '快照ID',
|
||||
-- 配置快照内容,JSON格式存储,包含该版本的完整配置信息
|
||||
`snapshot_content` LONGTEXT COMMENT '快照内容',
|
||||
-- 版本状态:CREATED(已创建)、PUBLISHED(已发布)、DEPRECATED(已废弃)
|
||||
`status` VARCHAR(20) NOT NULL COMMENT '版本状态',
|
||||
-- 发布时间,记录版本发布的时间
|
||||
`publish_time` DATETIME DEFAULT NULL COMMENT '发布时间',
|
||||
-- 创建人,记录创建版本的用户
|
||||
`create_by` VARCHAR(64) NOT NULL COMMENT '创建人',
|
||||
-- 创建时间,记录版本创建的时间
|
||||
`create_time` DATETIME NOT NULL COMMENT '创建时间',
|
||||
-- 更新人,记录最后更新版本的用户
|
||||
`update_by` VARCHAR(64) NOT NULL COMMENT '更新人',
|
||||
-- 更新时间,记录版本最后更新的时间
|
||||
`update_time` DATETIME NOT NULL COMMENT '更新时间',
|
||||
-- 备注,存储版本的额外信息
|
||||
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||
-- 租户编号,支持多租户隔离,不同租户的版本相互独立
|
||||
`tenant_id` VARCHAR(32) DEFAULT NULL COMMENT '租户编号',
|
||||
-- 主键索引,唯一标识版本记录
|
||||
PRIMARY KEY (`version_id`) COMMENT '主键索引',
|
||||
-- 唯一约束,确保版本号在系统中唯一
|
||||
UNIQUE KEY `uk_version_number` (`version_number`) COMMENT '唯一约束',
|
||||
-- 普通索引,加速按状态查询版本
|
||||
KEY `idx_status` (`status`) COMMENT '普通索引',
|
||||
-- 普通索引,加速按创建时间查询版本
|
||||
KEY `idx_create_time` (`create_time`) COMMENT '普通索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置版本表';
|
||||
|
||||
-- -----------------------------
|
||||
-- 配置审计日志表 (datai_config_audit_log)
|
||||
-- -----------------------------
|
||||
-- 用途:记录所有配置操作的审计日志,用于系统安全审计和操作追溯
|
||||
-- 设计考虑:
|
||||
-- 1. 记录操作类型、对象类型、操作人、操作时间等关键信息
|
||||
-- 2. 支持操作结果和错误信息的记录
|
||||
-- 3. 记录操作前后的值变化,便于审计和问题排查
|
||||
-- 4. 支持按多种条件查询,如操作类型、对象类型、操作人、操作时间等
|
||||
-- 5. 支持租户隔离,满足多租户需求
|
||||
CREATE TABLE `datai_config_audit_log` (
|
||||
-- 日志ID,自增主键,唯一标识一条审计日志
|
||||
`log_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '日志ID',
|
||||
-- 操作类型:CREATE(创建)、UPDATE(更新)、DELETE(删除)、PUBLISH(发布)、ROLLBACK(回滚)、IMPORT(导入)、EXPORT(导出)
|
||||
`operation_type` VARCHAR(20) NOT NULL COMMENT '操作类型',
|
||||
-- 操作对象类型:DATAI_CONFIGURATION(配置)、DATAI_CONFIG_VERSION(版本)、DATAI_CONFIG_ENVIRONMENT(环境)
|
||||
`object_type` VARCHAR(50) NOT NULL COMMENT '对象类型',
|
||||
-- 操作对象ID,关联到具体的操作对象
|
||||
`object_id` BIGINT(20) DEFAULT NULL COMMENT '对象ID',
|
||||
-- 旧值,操作前的对象值
|
||||
`old_value` TEXT COMMENT '旧值',
|
||||
-- 新值,操作后的对象值
|
||||
`new_value` TEXT COMMENT '新值',
|
||||
-- 操作描述,详细说明操作的内容和目的
|
||||
`operation_desc` VARCHAR(500) DEFAULT NULL COMMENT '操作描述',
|
||||
-- 操作人,记录执行操作的用户
|
||||
`operator` VARCHAR(64) NOT NULL COMMENT '操作人',
|
||||
-- 操作时间,记录操作执行的时间
|
||||
`operation_time` DATETIME NOT NULL COMMENT '操作时间',
|
||||
-- 操作IP地址,记录执行操作的客户端IP
|
||||
`ip_address` VARCHAR(50) DEFAULT NULL COMMENT 'IP地址',
|
||||
-- 用户代理,记录执行操作的客户端信息
|
||||
`user_agent` VARCHAR(255) DEFAULT NULL COMMENT '用户代理',
|
||||
-- 请求ID,用于关联同一请求的多个操作日志
|
||||
`request_id` VARCHAR(36) DEFAULT NULL COMMENT '请求ID',
|
||||
-- 操作结果:SUCCESS(成功)、FAILED(失败)
|
||||
`result` VARCHAR(20) NOT NULL DEFAULT 'SUCCESS' COMMENT '操作结果',
|
||||
-- 错误信息,记录操作失败时的错误详情
|
||||
`error_message` TEXT DEFAULT NULL COMMENT '错误信息',
|
||||
-- 租户编号,支持多租户隔离,不同租户的日志相互独立
|
||||
`tenant_id` VARCHAR(32) DEFAULT NULL COMMENT '租户编号',
|
||||
-- 主键索引,唯一标识日志记录
|
||||
PRIMARY KEY (`log_id`) COMMENT '主键索引',
|
||||
-- 普通索引,加速按操作类型查询日志
|
||||
KEY `idx_operation_type` (`operation_type`) COMMENT '普通索引',
|
||||
-- 普通索引,加速按对象类型查询日志
|
||||
KEY `idx_object_type` (`object_type`) COMMENT '普通索引',
|
||||
-- 普通索引,加速按操作人查询日志
|
||||
KEY `idx_operator` (`operator`) COMMENT '普通索引',
|
||||
-- 普通索引,加速按操作时间查询日志
|
||||
KEY `idx_operation_time` (`operation_time`) COMMENT '普通索引',
|
||||
-- 普通索引,加速按请求ID查询日志
|
||||
KEY `idx_request_id` (`request_id`) COMMENT '普通索引',
|
||||
-- 普通索引,加速按对象ID查询日志
|
||||
KEY `idx_object_id` (`object_id`) COMMENT '普通索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置审计日志表';
|
||||
|
||||
-- -----------------------------
|
||||
-- 配置快照表 (datai_config_snapshot)
|
||||
-- -----------------------------
|
||||
-- 用途:存储配置版本的快照内容,支持配置的完整回滚和历史查询
|
||||
-- 设计考虑:
|
||||
-- 1. 使用UUID作为主键,确保分布式环境下的唯一性
|
||||
-- 2. 关联配置版本,支持版本与快照的一对一关系
|
||||
-- 3. 采用JSON格式存储完整的配置快照,便于恢复
|
||||
-- 4. 记录快照时间和配置/分组数量,便于快速查询
|
||||
-- 5. 支持租户隔离,满足多租户需求
|
||||
-- 6. 包含完整的审计字段,便于追溯
|
||||
CREATE TABLE `datai_config_snapshot` (
|
||||
-- 快照ID,UUID格式,唯一标识一个配置快照
|
||||
`snapshot_id` VARCHAR(36) NOT NULL COMMENT '快照ID',
|
||||
-- 关联版本ID,关联到配置版本表,建立版本与快照的关联
|
||||
`version_id` BIGINT(20) NOT NULL COMMENT '版本ID',
|
||||
-- 快照时间,记录快照创建的时间
|
||||
`snapshot_time` DATETIME NOT NULL COMMENT '快照时间',
|
||||
-- 快照内容,JSON格式存储,包含该版本的完整配置信息,包括配置项、环境等
|
||||
`snapshot_content` LONGTEXT NOT NULL COMMENT '快照内容',
|
||||
-- 配置数量,快照中包含的配置项数量,用于快速查询和验证
|
||||
`config_count` INT(11) NOT NULL COMMENT '配置数量',
|
||||
-- 创建人,记录创建快照的用户
|
||||
`create_by` VARCHAR(64) NOT NULL COMMENT '创建人',
|
||||
-- 创建时间,记录快照创建的时间
|
||||
`create_time` DATETIME NOT NULL COMMENT '创建时间',
|
||||
-- 备注,存储快照的额外信息
|
||||
`remark` VARCHAR(500) DEFAULT NULL COMMENT '备注',
|
||||
-- 租户编号,支持多租户隔离,不同租户的快照相互独立
|
||||
`tenant_id` VARCHAR(32) DEFAULT NULL COMMENT '租户编号',
|
||||
-- 主键索引,唯一标识快照记录
|
||||
PRIMARY KEY (`snapshot_id`) COMMENT '主键索引',
|
||||
-- 普通索引,加速按版本ID查询快照
|
||||
KEY `idx_version_id` (`version_id`) COMMENT '普通索引',
|
||||
-- 普通索引,加速按快照时间查询快照
|
||||
KEY `idx_snapshot_time` (`snapshot_time`) COMMENT '普通索引'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置快照表';
|
||||
|
||||
@ -0,0 +1,80 @@
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.version', '65.0', 'Salesforce API版本,从apex.wsdl文件中获取', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.endpoint.production', 'https://login.salesforce.com/services/Soap/s/65.0', 'Salesforce生产环境API服务端点', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.endpoint.sandbox', 'https://test.salesforce.com/services/Soap/s/65.0', 'Salesforce沙盒环境API服务端点', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.endpoint.custom', '', 'Salesforce自定义域名API服务端点,用于My Domain配置', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.environment.type', 'production', 'Salesforce环境类型,支持production, sandbox, custom', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.namespace', 'http://soap.sforce.com/2006/08/apex', 'Salesforce Apex API命名空间,从apex.wsdl文件中获取', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.binding', 'ApexBinding', 'Salesforce Apex API绑定名称,从apex.wsdl文件中获取', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.port_type', 'ApexPortType', 'Salesforce Apex API端口类型,从apex.wsdl文件中获取', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.service_name', 'ApexService', 'Salesforce Apex API服务名称,从apex.wsdl文件中获取', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.operations', 'compileAndTest,compileClasses,compileTriggers,executeAnonymous,runTests,wsdlToApex', 'Salesforce Apex API支持的操作列表', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.compatibility.version', '50.0', 'Salesforce API最低兼容版本,确保兼容性', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.api.call.limit', '15000', 'Salesforce API 24小时调用限制', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.auth.type', 'password', 'Salesforce认证方式,支持password, oauth, saml', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.auth.username', '', 'Salesforce API用户名,用于API访问', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.auth.password', '', 'Salesforce API密码,用于API访问', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.auth.security.token', '', 'Salesforce安全令牌,用于API访问', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.oauth.client.id', '', 'Salesforce OAuth客户端ID,用于OAuth认证', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.oauth.client.secret', '', 'Salesforce OAuth客户端密钥,用于OAuth认证', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.oauth.redirect.uri', '', 'Salesforce OAuth重定向URI,用于OAuth认证', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.session.timeout', '7200', 'Salesforce会话超时时间(秒),默认2小时', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.session.refresh.threshold', '300', 'Salesforce会话刷新阈值(秒),会话过期前开始刷新', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.encryption.enabled', 'true', '是否启用Salesforce数据加密,控制敏感数据加密存储', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.certificate.path', '', 'Salesforce SSL证书路径,用于SSL连接', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.certificate.password', '', 'Salesforce SSL证书密码,用于SSL连接', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.security.ip.whitelist', '', 'Salesforce IP白名单,允许访问的IP地址列表,逗号分隔', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.security.ip.restricted', 'false', '是否启用IP限制,只允许白名单IP访问', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.pool.max.total', '20', 'Salesforce连接池最大连接数', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.pool.max.idle', '10', 'Salesforce连接池最大空闲连接数', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.pool.min.idle', '5', 'Salesforce连接池最小空闲连接数', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.pool.initial.size', '5', 'Salesforce连接池初始化大小', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.connection.timeout', '30000', 'Salesforce连接超时时间(毫秒)', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.read.timeout', '60000', 'Salesforce读取超时时间(毫秒)', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.connection.validation.query', 'SELECT Id FROM User LIMIT 1', 'Salesforce连接验证查询,用于验证连接是否有效', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.connection.validation.interval', '30000', 'Salesforce连接验证间隔(毫秒)', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.concurrent.requests.max', '10', 'Salesforce并发请求最大数', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.batch.size', '200', 'Salesforce批处理大小,每次处理的数据记录数', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.batch.timeout', '300000', 'Salesforce批处理超时时间(毫秒)', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.cache.enabled', 'true', '是否启用Salesforce缓存,提高性能', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.cache.expiry', '3600', 'Salesforce缓存过期时间(秒)', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.cache.max.size', '1000', 'Salesforce缓存最大条目数', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.rate.limit.enabled', 'true', '是否启用Salesforce限流', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.rate.limit.threshold', '100', 'Salesforce限流阈值(请求/分钟)', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.retry.count', '3', 'Salesforce操作失败重试次数', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.retry.interval', '5000', 'Salesforce重试间隔时间(毫秒)', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.retry.exponential.backoff', 'true', '是否启用指数退避重试,重试间隔按指数增长', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.mapping.config', '', 'Salesforce数据映射配置,JSON格式的字段映射', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.field.transformation', '', 'Salesforce字段转换配置,JSON格式的字段转换规则', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.error.handling.strategy', 'retry', 'Salesforce错误处理策略,支持retry, skip, abort', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.error.logging.enabled', 'true', '是否启用Salesforce错误记录', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.monitoring.enabled', 'true', '是否启用Salesforce监控', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.monitoring.report.interval', '86400', 'Salesforce监控报告间隔(秒)', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.debug.enabled', 'false', '是否启用Salesforce调试模式', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.debug.level', 'DEBUGONLY', 'Salesforce调试级别,支持DEBUGONLY, DB, PROFILING, NONE', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.log.level', 'INFO', 'Salesforce日志级别,支持DEBUG,INFO,WARN,ERROR', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.log.retention.days', '30', 'Salesforce日志保留天数', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.proxy.enabled', 'false', '是否启用代理连接Salesforce', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.proxy.host', '', 'Salesforce代理主机,代理服务器主机名或IP', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.proxy.port', '8080', 'Salesforce代理端口,代理服务器端口号', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.proxy.username', '', 'Salesforce代理用户名,代理服务器认证用户名', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.proxy.password', '', 'Salesforce代理密码,代理服务器认证密码', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.sync.enabled', 'true', '是否启用Salesforce数据同步', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.sync.interval', '3600', 'Salesforce数据同步间隔(秒)', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.sync.incremental.enabled', 'true', '是否启用Salesforce增量同步,只同步变更数据', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.sync.incremental.window', '86400', 'Salesforce增量同步时间窗口(秒),默认24小时', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.conflict.resolution', 'salesforce_wins', 'Salesforce冲突解决策略,支持salesforce_wins, local_wins, manual', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.bulk.api.enabled', 'false', '是否启用Salesforce Bulk API,用于大批量操作', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.bulk.threshold', '2000', 'Salesforce批量操作阈值,超过此记录数时使用Bulk API', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.field.truncation', 'false', '是否允许字段截断,控制AllowFieldTruncationHeader', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.disable.feed.tracking', 'false', '是否禁用Feed跟踪,控制DisableFeedTrackingHeader', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.package.version', '65.0', 'Salesforce包版本,用于PackageVersionHeader', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.multi.tenant.enabled', 'false', '是否启用多租户模式,支持多租户Salesforce实例', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.tenant.isolation', 'strict', 'Salesforce租户隔离级别,支持strict, moderate, none', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.archive.enabled', 'false', '是否启用Salesforce数据归档,对历史数据进行归档', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.archive.strategy', 'date_based', 'Salesforce归档策略,支持date_based, size_based, custom', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.archive.retention.days', '365', 'Salesforce归档数据保留天数', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.notification.enabled', 'true', '是否启用Salesforce通知,操作完成时通知', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.notification.types', 'email,webhook', 'Salesforce通知类型,支持email, webhook, sms, in_app', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.notification.email', '', 'Salesforce邮件通知地址,多个用逗号分隔', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.notification.webhook', '', 'Salesforce Webhook通知地址,接收通知的URL', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
INSERT INTO `datai_configuration` (`config_key`, `config_value`, `remark`, `create_time`, `update_time`, `create_by`, `update_by`, `tenant_id`) VALUES ('salesforce.notification.events', 'sync_complete,error,batch_complete', 'Salesforce通知事件,触发通知的事件类型', '2025-12-08 22:16:42', '2025-12-08 22:16:42', 'admin', 'admin', 1);
|
||||
75
update_sql.py
Normal file
75
update_sql.py
Normal file
@ -0,0 +1,75 @@
|
||||
# 使用简单的字符串替换方法更新SQL文件
|
||||
|
||||
# 读取SQL文件内容
|
||||
with open(r'd:\idea_demo\datai\datai-scenes\datai-scene-salesforce\datai-salesforce-config\src\main\resources\sql\salesforce_configuration.sql', 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
new_lines = []
|
||||
in_insert = False
|
||||
insert_line = ""
|
||||
values_line = ""
|
||||
update_line = ""
|
||||
|
||||
for line in lines:
|
||||
stripped_line = line.strip()
|
||||
|
||||
if stripped_line.startswith("INSERT INTO datai_configuration"):
|
||||
in_insert = True
|
||||
# 替换字段列表
|
||||
insert_line = "INSERT INTO datai_configuration (config_key, config_value, create_by, create_time, update_by, update_time, remark, environment_id, is_sensitive, is_encrypted, is_active, tenant_id)"
|
||||
new_lines.append(insert_line + "\n")
|
||||
elif in_insert and stripped_line.startswith("VALUES"):
|
||||
# 替换VALUES部分
|
||||
# 原始VALUES格式:VALUES ('key', 'value', 'admin', NOW(), 'admin', NOW(), 'remark', 'system', 1)
|
||||
# 提取括号内的值
|
||||
# 处理可能的换行情况,确保获取完整的VALUES部分
|
||||
if '(' in stripped_line and ')' in stripped_line:
|
||||
# 简单情况:VALUES在一行
|
||||
values_part = stripped_line[stripped_line.find('(')+1:stripped_line.rfind(')')] # 提取括号内的所有内容
|
||||
else:
|
||||
# 复杂情况:VALUES跨多行,需要继续读取后续行
|
||||
values_part = stripped_line[stripped_line.find('(')+1:] # 提取当前行的括号内容
|
||||
# 这里简化处理,假设VALUES部分在一行内
|
||||
|
||||
# 处理可能包含的多余引号和括号
|
||||
values_part = values_part.strip()
|
||||
if values_part.startswith("'") and values_part.endswith("'"):
|
||||
values_part = values_part[1:-1]
|
||||
|
||||
values_list = values_part.split(', ')
|
||||
# 保留前7个值,然后添加新的字段值
|
||||
new_values_list = values_list[:7] # 保留前7个值
|
||||
new_values_list.extend(["NULL", "0", "0", "1", "'1'"]) # 添加新的字段值
|
||||
new_values = ', '.join(new_values_list)
|
||||
values_line = f"VALUES ({new_values})"
|
||||
new_lines.append(" " + values_line + "\n")
|
||||
elif in_insert and stripped_line.startswith("ON DUPLICATE KEY UPDATE"):
|
||||
# 替换ON DUPLICATE KEY UPDATE部分
|
||||
update_line = "ON DUPLICATE KEY UPDATE"
|
||||
new_update_content = " config_value = VALUES(config_value),"
|
||||
new_update_content += "\n update_by = VALUES(update_by),"
|
||||
new_update_content += "\n update_time = VALUES(update_time),"
|
||||
new_update_content += "\n remark = VALUES(remark),"
|
||||
new_update_content += "\n environment_id = VALUES(environment_id),"
|
||||
new_update_content += "\n is_sensitive = VALUES(is_sensitive),"
|
||||
new_update_content += "\n is_encrypted = VALUES(is_encrypted),"
|
||||
new_update_content += "\n is_active = VALUES(is_active),"
|
||||
new_update_content += "\n tenant_id = VALUES(tenant_id)"
|
||||
new_lines.append(" " + update_line + "\n")
|
||||
new_lines.append(new_update_content + "\n")
|
||||
elif in_insert and stripped_line.endswith(";"):
|
||||
# 结束INSERT语句
|
||||
new_lines.append(";")
|
||||
in_insert = False
|
||||
elif in_insert:
|
||||
# 跳过旧的字段列表和VALUES部分
|
||||
continue
|
||||
else:
|
||||
# 保留其他行
|
||||
new_lines.append(line)
|
||||
|
||||
# 写入更新后的内容
|
||||
with open(r'd:\idea_demo\datai\datai-scenes\datai-scene-salesforce\datai-salesforce-config\src\main\resources\sql\salesforce_configuration.sql', 'w', encoding='utf-8') as f:
|
||||
f.writelines(new_lines)
|
||||
|
||||
print("SQL文件已成功更新!")
|
||||
29
update_sql_simple.py
Normal file
29
update_sql_simple.py
Normal file
@ -0,0 +1,29 @@
|
||||
# 使用简单的字符串替换方法更新SQL文件
|
||||
|
||||
# 读取SQL文件内容
|
||||
with open(r'd:\idea_demo\datai\datai-scenes\datai-scene-salesforce\datai-salesforce-config\src\main\resources\sql\salesforce_configuration.sql', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 定义要替换的旧内容和新内容
|
||||
old_fields = "config_key, config_value, create_by, create_time, update_by, update_time, remark, create_dept, tenant_id"
|
||||
new_fields = "config_key, config_value, create_by, create_time, update_by, update_time, remark, environment_id, is_sensitive, is_encrypted, is_active, tenant_id"
|
||||
|
||||
old_update = " config_value = VALUES(config_value),\n update_by = VALUES(update_by),\n update_time = VALUES(update_time),\n remark = VALUES(remark),\n create_dept = VALUES(create_dept),\n tenant_id = VALUES(tenant_id)"
|
||||
|
||||
new_update = " config_value = VALUES(config_value),\n update_by = VALUES(update_by),\n update_time = VALUES(update_time),\n remark = VALUES(remark),\n environment_id = VALUES(environment_id),\n is_sensitive = VALUES(is_sensitive),\n is_encrypted = VALUES(is_encrypted),\n is_active = VALUES(is_active),\n tenant_id = VALUES(tenant_id)"
|
||||
|
||||
# 替换字段列表
|
||||
content = content.replace(old_fields, new_fields)
|
||||
|
||||
# 替换UPDATE部分
|
||||
content = content.replace(old_update, new_update)
|
||||
|
||||
# 修复VALUES部分的多余括号
|
||||
content = content.replace("VALUES ((", "VALUES (")
|
||||
content = content.replace(")),", "),")
|
||||
|
||||
# 写入更新后的内容
|
||||
with open(r'd:\idea_demo\datai\datai-scenes\datai-scene-salesforce\datai-salesforce-config\src\main\resources\sql\salesforce_configuration.sql', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
print("SQL文件已成功更新!")
|
||||
Loading…
Reference in New Issue
Block a user