datai/datai-scenes/datai-scene-salesforce/docs/Authentication.canvas
Kris 517284b614 feat: 实现Salesforce Pub/Sub API实时数据同步
主要变更:
- 新增PubSubConnectionFactory连接工厂,提供Pub/Sub API连接管理
- 新增PubSubEventSubscriberImpl实现,支持Pub/Sub API事件订阅
- 更新EventProcessorImpl,添加事件批次处理能力
- 更新RealtimeSyncService,使用Pub/Sub API替代CDC实现
- 更新Authentication.canvas架构文档,添加Pub/Sub组件
- 优化同步配置管理和实时同步日志功能

技术改进:
- 提升实时同步性能和可靠性
- 支持批量事件处理,提高吞吐量
- 完善连接工厂模式,统一管理连接生命周期
2026-01-12 10:31:25 +08:00

73 lines
35 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"nodes":[
{"id":"node_login_strategy","type":"text","text":"## [[LoginStrategy]]\n> [!info] 职责描述\n> 登录策略接口,定义不同登录方式的通用方法\n\n### 🛠️ 核心方法\n- `login()`: 执行登录操作\n- `refreshToken()`: 刷新Token\n- `logout()`: 执行登出操作\n- `getLoginType()`: 获取登录类型\n\n### 策略实现\n- [[OAuth2LoginStrategy]]: OAuth 2.0登录策略\n- [[LegacyCredentialLoginStrategy]]: 传统凭证登录策略\n- [[SalesforceCliLoginStrategy]]: Salesforce CLI登录策略\n- [[SessionIdLoginStrategy]]: Session ID登录策略\n\n### 策略工厂\n- [[LoginStrategyFactory]]: 登录策略工厂,负责创建不同的登录策略\n\n```mermaid\nclassDiagram\n LoginStrategy <|-- OAuth2LoginStrategy\n LoginStrategy <|-- LegacyCredentialLoginStrategy\n LoginStrategy <|-- SalesforceCliLoginStrategy\n LoginStrategy <|-- SessionIdLoginStrategy\n LoginStrategyFactory ..> LoginStrategy\n```","parentNode":"group_auth","x":-1000,"y":2650,"width":600,"height":350,"color":"5"},
{"id":"node_auth_mapper","type":"text","text":"## 认证Mapper\n> [!info] 职责描述\n> 处理认证相关数据的持久化操作\n\n### 核心Mapper\n- [[DataiSfLoginHistoryMapper]]: 登录历史Mapper\n- [[DataiSfLoginSessionMapper]]: 登录会话Mapper\n\n**设计意图**:提供数据访问层,处理数据库操作","parentNode":"group_auth","x":-400,"y":2000,"width":500,"height":200,"color":"6"},
{"id":"node_integration_task","type":"text","text":"## 集成任务\n> [!info] 职责描述\n> 处理Salesforce的定时同步和限流重置等任务\n\n### 核心任务\n- [[RateLimitResetTask]]: 限流重置任务\n- [[SalesforceSyncTask]]: Salesforce同步任务\n\n### 🛠️ 核心方法\n- `execute()`: 执行定时任务\n- `resetRateLimits()`: 重置限流\n- `syncData()`: 同步数据\n\n**设计意图**通过定时任务处理Salesforce的周期性操作确保系统的正常运行和数据的同步更新","parentNode":"group_integration","x":0,"y":3000,"width":500,"height":200,"color":"4"},
{"id":"node_setting_utils","type":"text","text":"## 配置工具\n> [!info] 职责描述\n> 提供配置相关的工具方法\n\n### 核心工具\n- [[AuditLogObjectNameResolver]]: 审计日志对象名解析器\n\n### 核心功能\n- **对象名解析**: 解析审计日志中的对象名\n- **工具方法**: 提供配置管理所需的其他工具方法\n\n**设计意图**:提供配置管理所需的工具方法,简化代码实现,提高系统的可维护性","parentNode":"group_setting","x":1300,"y":3000,"width":600,"height":150,"color":"6"},
{"id":"node_auth_model","type":"text","text":"## 认证模型\n> [!info] 职责描述\n> 定义认证相关的数据模型\n\n### 领域模型\n- [[DataiSfLoginHistory]]: 登录历史记录\n- [[DataiSfLoginSession]]: 登录会话信息\n- [[SalesforceLoginRequest]]: 登录请求\n- [[SalesforceLoginResult]]: 登录结果\n\n### DTO\n- [[DataiSfLoginHistoryDto]]: 登录历史DTO\n- [[DataiSfLoginSessionDto]]: 登录会话DTO\n\n### VO\n- [[DataiSfLoginHistoryVo]]: 登录历史VO\n- [[DataiSfLoginSessionVo]]: 登录会话VO\n\n**设计意图**定义清晰的数据模型分离领域模型、DTO和VO提高代码可维护性","parentNode":"group_auth","x":-950,"y":3150,"width":500,"height":300,"color":"1"},
{"id":"node_common_constant","type":"text","text":"## 通用常量\n> [!info] 职责描述\n> 定义Salesforce相关的常量\n\n### 核心常量类\n- [[SalesforceConstants]]: Salesforce核心常量\n- [[SalesforceConfigConstants]]: Salesforce配置常量\n- [[SalesforceConnectionConstants]]: Salesforce连接常量\n\n### 常量分类\n- **API版本**: REST API、Bulk API v1、Bulk API v2版本号\n- **连接端点**: 各种API的端点后缀\n- **连接类型**: SOAP、REST、Bulk API v1、Bulk API v2\n- **HTTP相关**: HTTP方法、内容类型、授权头\n- **日期格式**: Salesforce日期时间格式\n- **批量操作**: Bulk API相关常量\n\n**设计意图**集中管理所有Salesforce相关常量提高代码的可维护性和可读性","parentNode":"group_common","x":950,"y":300,"width":500,"height":300,"color":"6"},
{"id":"node_common_exception","type":"text","text":"## 通用异常\n> [!info] 职责描述\n> 定义Salesforce相关的异常类\n\n### 核心异常类\n- [[SalesforceAuthException]]: Salesforce认证异常\n- [[SalesforceLoginException]]: Salesforce登录异常\n- [[SalesforceOAuthException]]: Salesforce OAuth异常\n- [[ExtractException]]: 数据提取异常\n- [[LoadException]]: 数据加载异常\n- [[NotLoggedInException]]: 未登录异常\n- [[OperationException]]: 操作异常\n- [[RateLimitExceededException]]: 限流异常\n- [[PasswordExpiredException]]: 密码过期异常\n\n### 异常特点\n- **错误代码**: 大多数异常都包含错误代码字段\n- **层次结构**: 基于RuntimeException便于异常处理\n- **详细信息**: 提供详细的错误信息,便于调试\n\n**设计意图**:定义统一的异常处理机制,提高代码的可维护性和错误处理能力","parentNode":"group_common","x":950,"y":800,"width":500,"height":300,"color":"1"},
{"id":"node_common_util","type":"text","text":"## 通用工具\n> [!info] 职责描述\n> 提供Salesforce相关的工具方法\n\n### 核心工具类\n- [[SoqlBuilder]]: SOQL查询构建器\n- [[SoqlUtil]]: SOQL工具类\n- [[ApiListUtils]]: API列表工具\n- [[IdUtils]]: ID工具\n- [[ValidationUtils]]: 验证工具\n\n### SoqlBuilder 核心功能\n- **查询构建**: 支持SELECT、FROM、WHERE、GROUP BY、HAVING、ORDER BY、LIMIT、OFFSET\n- **条件操作**: 支持=、!=、>、>=、<、<=、LIKE、IN、NOT IN、= NULL、!= NULL\n- **值格式化**: 自动格式化不同类型的值,包括字符串、日期、布尔值等\n- **安全处理**: 防止SQL注入自动转义单引号\n- **COUNT查询**: 支持构建COUNT查询语句\n\n```mermaid\nflowchart TD\n A[创建SoqlBuilder] --> B[设置SELECT字段]\n B --> C[设置FROM对象]\n C --> D[添加WHERE条件]\n D --> E[添加ORDER BY]\n E --> F[设置LIMIT]\n F --> G[构建SOQL语句]\n```","parentNode":"group_common","x":950,"y":1300,"width":500,"height":350,"color":"6"},
{"id":"node_common_param","type":"text","text":"## 通用参数\n> [!info] 职责描述\n> 定义Salesforce相关的参数类\n\n### 核心参数类\n- [[SalesforceParam]]: Salesforce基础参数\n- [[SalesforceStockParam]]: Salesforce库存参数\n- [[SalesforceIncrementParam]]: Salesforce增量参数\n\n**设计意图**:定义统一的参数类,提高代码的可维护性和参数传递的规范性","parentNode":"group_common","x":950,"y":1750,"width":500,"height":200,"color":"5"},
{"id":"node_warning","type":"text","text":"## ⚠️ 注意事项\n\n### 潜在问题\n1. **会话管理**:需要注意会话过期和自动重连的处理\n2. **错误处理**需要完善各种Salesforce API错误的处理机制\n3. **性能优化**对于大量数据操作需要合理使用Bulk API\n4. **安全性**OAuth2流程需要确保PKCE的正确实现\n5. **SOQL限制**注意SOQL的各种限制如查询返回记录数、OFFSET上限等\n\n### 建议\n- 增加更多的监控和日志\n- 实现更细粒度的错误处理\n- 优化连接管理减少不必要的API调用\n- 合理使用SOQL构建器避免手动拼接SOQL语句","x":950,"y":2100,"width":500,"height":250,"color":"3"},
{"id":"node_common_converter","type":"text","text":"## 类型转换器\n> [!info] 职责描述\n> 提供Salesforce相关的类型转换功能\n\n### 核心转换器\n- [[SalesforceDataTypeConverter]]: Salesforce数据类型转换器\n- [[BooleanConverter]]: Boolean转换器\n\n**设计意图**提供类型转换功能支持Salesforce数据类型与Java类型之间的转换","parentNode":"group_common","x":950,"y":2500,"width":500,"height":200,"color":"6"},
{"id":"node_integration_mapper","type":"text","text":"## 集成Mapper\n> [!info] 职责描述\n> 处理集成相关数据的持久化操作\n\n### 核心Mapper\n- [[CustomMapper]]: 自定义Mapper\n- [[SalesforceMapper]]: Salesforce Mapper\n- [[DataiIntegrationApiCallLogMapper]]: API调用日志Mapper\n- [[DataiIntegrationBatchMapper]]: 批处理任务Mapper\n- [[DataiIntegrationFieldMapper]]: 字段映射Mapper\n- [[DataiIntegrationObjectMapper]]: 对象映射Mapper\n- [[DataiIntegrationRateLimitMapper]]: 限流记录Mapper\n- [[DataiIntegrationSyncLogMapper]]: 同步日志Mapper\n- [[DataiIntegrationRealtimeSyncLogMapper]]: 实时同步日志Mapper\n\n**设计意图**:提供集成数据的访问层,处理数据库操作,为服务层提供数据支持","parentNode":"group_integration","x":0,"y":3450,"width":500,"height":200,"color":"6"},
{"id":"node_realtime_sync","type":"text","text":"## 实时数据同步\n> [!info] 职责描述\n> 实现Salesforce Pub/Sub API事件订阅和处理支持实时数据同步\n\n### 核心组件\n- [[EventSubscriber]]: 事件订阅器订阅Salesforce Event Bus事件\n- [[PubSubEventSubscriberImpl]]: Pub/Sub API事件订阅器实现\n- [[EventProcessor]]: 事件处理器,解析和处理捕获的变更事件\n- [[DataSynchronizer]]: 数据同步器,将变更数据同步至本地数据库\n- [[ObjectRegistry]]: 对象注册表,管理所有启用实时同步的对象\n\n### 🛠️ 核心方法\n- `startSubscription()`: 启动Salesforce Event Bus订阅\n- `processEvent()`: 处理捕获的变更事件\n- `processEventBatch()`: 处理Pub/Sub API事件批次\n- `synchronizeData()`: 同步数据至本地数据库\n- `registerObject()`: 注册启用实时同步的对象\n\n**设计意图**实现Salesforce Pub/Sub API实时同步功能通过订阅Event Bus实时捕获数据变更并同步至本地数据库提供高性能、高可靠性的实时数据同步能力","parentNode":"group_integration","x":0,"y":2150,"width":500,"height":350,"color":"4"},
{"id":"node_realtime_sync_log","type":"text","text":"## 实时同步日志\n> [!info] 职责描述\n> 记录实时同步操作的详细信息\n\n### 核心组件\n- [[DataiIntegrationRealtimeSyncLog]]: 实时同步日志实体类\n- [[DataiIntegrationRealtimeSyncLogController]]: 实时同步日志控制器\n- [[DataiIntegrationRealtimeSyncLogService]]: 实时同步日志服务\n\n### 🛠️ 核心方法\n- `recordSyncLog()`: 记录同步操作日志\n- `querySyncLogs()`: 查询同步操作日志\n- `exportSyncLogs()`: 导出同步操作日志\n\n**设计意图**:记录实时同步操作的详细信息,支持日志查询、导出和分析功能","parentNode":"group_integration","x":850,"y":2600,"width":500,"height":300,"color":"4"},
{"id":"node_integration_connections","type":"text","text":"## Salesforce连接类型\n> [!info] 职责描述\n> 提供与Salesforce的各种连接方式\n\n### 连接类型\n- **Bulk API v1**:批量数据操作\n- **Bulk API v2**:更高效的批量操作\n- **Partner API**:元数据和复杂操作\n- **REST API**标准REST接口\n\n### 连接管理\n- 会话管理\n- 连接池\n- 错误处理\n\n**设计意图**:提供多种连接方式,满足不同场景的需求","parentNode":"group_integration","x":360,"y":2600,"width":500,"height":300,"color":"4"},
{"id":"node_integration_core","type":"text","text":"## 集成核心\n> [!info] 职责描述\n> 提供与Salesforce的各种连接方式\n\n### 连接接口\n- [[IBulkV1Connection]]: Bulk API v1连接接口\n- [[IBulkV2Connection]]: Bulk API v2连接接口\n- [[IPartnerV1Connection]]: Partner API连接接口\n- [[IRESTConnection]]: REST API连接接口\n\n### 连接实现\n- [[BulkV1Connection]]: Bulk API v1连接实现\n- [[BulkV2Connection]]: Bulk API v2连接实现\n- [[PartnerV1Connection]]: Partner API连接实现\n- [[RESTConnection]]: REST API连接实现\n- [[PubSubClient]]: Pub/Sub API客户端实现\n\n### 会话管理\n- [[SessionManager]]: 会话管理器\n\n### 连接工厂\n- [[ISalesforceConnectionFactory]]: 连接工厂接口\n- [[AbstractConnectionFactory]]: 抽象连接工厂\n- [[BulkV1ConnectionFactory]]: Bulk API v1连接工厂\n- [[BulkV2ConnectionFactory]]: Bulk API v2连接工厂\n- [[RESTConnectionFactory]]: REST API连接工厂\n- [[SOAPConnectionFactory]]: SOAP连接工厂\n- [[PubSubConnectionFactory]]: Pub/Sub API连接工厂\n\n```mermaid\nclassDiagram\n IBulkV1Connection <|-- BulkV1Connection\n IBulkV2Connection <|-- BulkV2Connection\n IPartnerV1Connection <|-- PartnerV1Connection\n IRESTConnection <|-- RESTConnection\n ISalesforceConnectionFactory <|-- AbstractConnectionFactory\n AbstractConnectionFactory <|-- BulkV1ConnectionFactory\n AbstractConnectionFactory <|-- BulkV2ConnectionFactory\n AbstractConnectionFactory <|-- RESTConnectionFactory\n AbstractConnectionFactory <|-- SOAPConnectionFactory\n AbstractConnectionFactory <|-- PubSubConnectionFactory\n BulkV1ConnectionFactory ..> BulkV1Connection\n BulkV2ConnectionFactory ..> BulkV2Connection\n RESTConnectionFactory ..> RESTConnection\n PubSubConnectionFactory ..> PubSubClient\n SessionManager ..> RESTConnection\n```\n\n**设计意图**提供与Salesforce的多种连接方式支持不同API的交互需求通过工厂模式统一管理连接的创建和生命周期包括新增的Pub/Sub API连接支持
{"id":"node_session_manager_detail","type":"text","text":"## [[SessionManager]]\n> [!info] 职责描述\n> 会话管理类用于获取Salesforce会话信息支持会话失效时自动重新登录\n\n### 🛠️ 核心方法\n- `getCurrentLoginResult()`: 获取当前登录结果\n- `autoLogin()`: 自动重新登录\n- `getCurrentSession()`: 获取当前Session ID\n- `getInstanceUrl()`: 获取实例URL\n- `isSessionValid()`: 检查会话是否有效\n\n### 📋 依赖注入\n- `ISalesforceLoginService`: 登录服务\n- `IDataiSfLoginHistoryService`: 登录历史服务\n\n```mermaid\nflowchart TD\n A[获取会话信息] --> B{缓存中有会话?}\n B -->|是| C{会话有效?}\n B -->|否| D[自动重新登录]\n C -->|是| E[返回会话信息]\n C -->|否| D\n D --> F{登录成功?}\n F -->|是| G[更新缓存]\n F -->|否| H[抛出异常]\n G --> E\n```","parentNode":"group_integration","x":-400,"y":1025,"width":500,"height":400,"color":"4"},
{"id":"node_login_history_controller","type":"text","text":"## [[DataiSfLoginHistoryController]]\n> [!info] 职责描述\n> 处理Salesforce登录历史相关的HTTP请求\n\n### 🛠️ 核心方法\n- 管理登录历史记录的CRUD操作\n\n### 📋 依赖注入\n- `IDataiSfLoginHistoryService`: 登录历史服务\n\n**设计意图**:提供登录历史的管理接口,方便查询和分析登录记录","parentNode":"group_auth","x":-2400,"y":590,"width":500,"height":250,"color":"5"},
{"id":"node_login_session_controller","type":"text","text":"## [[DataiSfLoginSessionController]]\n> [!info] 职责描述\n> 处理Salesforce登录会话相关的HTTP请求\n\n### 🛠️ 核心方法\n- 管理登录会话的CRUD操作\n\n### 📋 依赖注入\n- `IDataiSfLoginSessionService`: 登录会话服务\n\n**设计意图**:提供登录会话的管理接口,方便查询和管理当前活跃会话","parentNode":"group_auth","x":-2900,"y":1225,"width":500,"height":250,"color":"5"},
{"id":"node_auth_controller","type":"text","text":"## [[DataISfLoginController]]\n> [!info] 职责描述\n> 处理Salesforce登录相关的HTTP请求包括登录、登出、获取当前登录信息和自动登录\n\n### 🛠️ 核心方法\n- `login()`: 执行Salesforce登录操作\n- `logout()`: 执行Salesforce登出操作\n- `getCurrentLoginInfo()`: 获取当前登录信息\n- `autoLogin()`: 自动登录\n\n### 📋 依赖注入\n- `ISalesforceLoginService`: 登录服务\n- `IDataiSfLoginHistoryService`: 登录历史服务\n\n```mermaid\nflowchart TD\n A[接收登录请求] --> B[参数验证]\n B --> C[调用登录服务]\n C --> D{登录成功?}\n D -->|是| E[返回成功响应]\n D -->|否| F[返回失败响应]\n E --> G[记录登录历史]\n F --> G\n```","parentNode":"group_auth","x":-1900,"y":-160,"width":500,"height":350,"color":"5"},
{"id":"node_oauth2_strategy","type":"text","text":"## [[OAuth2LoginStrategy]]\n> [!info] 职责描述\n> OAuth 2.0登录策略实现,支持多种授权流程\n\n### 🛠️ 核心方法\n- `login()`: 执行OAuth 2.0登录\n- `refreshToken()`: 刷新Token\n- `logout()`: 执行登出操作\n- `generateAuthorizationUrl()`: 生成授权URL\n\n### 支持的授权流程\n- 密码流程\n- 客户端凭证流程\n- 授权码流程支持PKCE\n\n### 🏷️ 设计模式\n- **策略模式**: 实现LoginStrategy接口\n\n```mermaid\nflowchart TD\n A[开始OAuth2登录] --> B{选择授权类型}\n B -->|密码流程| C[执行密码授权]\n B -->|客户端凭证| D[执行客户端凭证授权]\n B -->|授权码| E[生成授权URL]\n E --> F[用户授权]\n F --> G[获取授权码]\n G --> H[执行授权码授权]\n C --> I[获取Token]\n D --> I\n H --> I\n I --> J[存储会话信息]\n J --> K[登录完成]\n```","parentNode":"group_auth","x":-1050,"y":-410,"width":600,"height":400,"color":"4"},
{"id":"node_login_strategy_factory","type":"text","text":"## [[LoginStrategyFactory]]\n> [!info] 职责描述\n> 登录策略工厂,负责根据登录类型创建对应的登录策略\n\n### 🛠️ 核心方法\n- `getLoginStrategy()`: 根据登录类型获取登录策略\n- `getSupportedLoginTypes()`: 获取所有支持的登录类型\n\n### 📋 依赖注入\n- `List<LoginStrategy>`: 所有登录策略的列表\n\n### 🏷️ 设计模式\n- **工厂模式**: 创建不同的登录策略\n- **依赖注入**: 通过构造函数注入所有登录策略\n\n```mermaid\nflowchart TD\n A[获取登录策略] --> B[验证登录类型]\n B --> C{策略存在?}\n C -->|是| D[返回策略]\n C -->|否| E[抛出异常]\n```","parentNode":"group_auth","x":-1200,"y":340,"width":500,"height":300,"color":"4"},
{"id":"node_salesforce_login_service","type":"text","text":"## [[SalesforceLoginServiceImpl]]\n> [!info] 职责描述\n> 实现Salesforce登录的业务逻辑管理登录策略的调用处理登录状态的保存与获取记录登录历史\n\n### 🛠️ 核心方法\n- `login()`: 执行Salesforce登录操作\n- `logout()`: 执行Salesforce登出操作\n- `getCurrentLoginResult()`: 获取当前登录结果\n- `autoLogin()`: 自动登录\n- `getCurrentLoginInfo()`: 获取当前登录信息\n\n### 📋 依赖注入\n- `LoginStrategyFactory`: 登录策略工厂\n- `IDataiSfLoginSessionService`: 登录会话服务\n- `IDataiSfLoginHistoryService`: 登录历史服务\n\n### 🏷️ 设计模式\n- **策略模式**: 使用不同的登录策略处理不同类型的登录\n- **工厂模式**: 通过工厂创建登录策略\n\n```mermaid\nflowchart TD\n A[开始登录] --> B[获取登录策略]\n B --> C[执行登录]\n C --> D{登录成功?}\n D -->|是| E[保存登录会话]\n D -->|否| F[保存失败历史]\n E --> G[保存成功历史]\n G --> H[更新缓存]\n F --> I[返回失败结果]\n H --> J[返回成功结果]\n```","parentNode":"group_auth","x":-2700,"y":2050,"width":600,"height":400,"color":"4"},
{"id":"node_integration_model","type":"text","text":"## 集成模型\n> [!info] 职责描述\n> 定义集成相关的数据模型\n\n### 领域模型\n- [[DataiIntegrationApiCallLog]]: API调用日志\n- [[DataiIntegrationBatch]]: 批处理任务\n- [[DataiIntegrationBatchHistory]]: 批处理历史\n- [[DataiIntegrationField]]: 字段映射\n- [[DataiIntegrationFilterLookup]]: 过滤查询\n- [[DataiIntegrationMetadataChange]]: 元数据变更\n- [[DataiIntegrationObject]]: 对象映射\n- [[DataiIntegrationPicklist]]: 选择列表\n- [[DataiIntegrationRateLimit]]: 限流记录\n- [[DataiIntegrationSyncLog]]: 同步日志\n\n### DTO\n- [[AlertDTO]]: 告警DTO\n- [[DataiConfigurationDto]]: 配置DTO\n- [[LimitConfigDTO]]: 限流配置DTO\n- [[LogStatisticsDTO]]: 日志统计DTO\n- [[RealTimeStatusDTO]]: 实时状态DTO\n- [[TrendDTO]]: 趋势DTO\n- [[UsageStatisticsDTO]]: 使用统计DTO\n\n### 参数\n- [[DataiSyncParam]]: 同步参数\n\n### VO\n- [[DataiIntegrationApiCallLogVo]]: API调用日志VO\n- [[DataiIntegrationBatchVo]]: 批处理任务VO\n- [[DataiIntegrationFieldVo]]: 字段映射VO\n- [[DataiIntegrationObjectVo]]: 对象映射VO\n- [[DataiIntegrationSyncLogVo]]: 同步日志VO\n\n**设计意图**:定义集成相关的数据模型,支持数据同步、监控和管理功能","parentNode":"group_integration","x":850,"y":-360,"width":600,"height":300,"color":"1"},
{"id":"node_setting_config","type":"text","text":"## [[SalesforceConfigCacheManager]]\n> [!info] 职责描述\n> 管理Salesforce配置信息包括配置缓存、环境切换等功能\n\n### 🛠️ 核心方法\n- `init()`: 系统启动时初始化配置缓存\n- `loadConfigToCache()`: 将配置加载到缓存\n- `resetConfigCache()`: 重置配置缓存\n- `clearConfigCache()`: 清空配置缓存\n- `getConfigValue(String configKey)`: 获取配置值\n- `switchEnvironment(String environmentCode)`: 动态切换环境\n\n### 📋 依赖注入\n- `DataiConfigurationMapper`: 配置Mapper\n- `DataiConfigEnvironmentMapper`: 环境配置Mapper\n\n### 核心功能\n- **缓存管理**: 管理Salesforce配置的缓存\n- **环境切换**: 支持不同环境的配置切换\n- **配置同步**: 确保配置的一致性\n- **默认配置**: 当当前环境无配置时加载默认环境配置作为fallback\n\n```mermaid\nflowchart TD\n A[系统启动] --> B[初始化环境信息]\n B --> C[加载配置到缓存]\n C --> D{当前环境有配置?}\n D -->|是| E[加载当前环境配置]\n D -->|否| F[加载默认环境配置]\n E --> G[配置加载完成]\n F --> G\n H[环境切换请求] --> I[清理旧环境缓存]\n I --> J[更新当前环境信息]\n J --> C\n K[配置变更] --> L[重置配置缓存]\n L --> C\n```\n\n**设计意图**:提供集中的配置管理功能,确保配置的一致性和可靠性,支持环境切换和配置缓存,提高系统性能和可维护性","parentNode":"group_setting","x":2020,"y":140,"width":600,"height":400,"color":"4"},
{"id":"node_setting_controller","type":"text","text":"## 配置控制器\n> [!info] 职责描述\n> 处理配置相关的HTTP请求\n\n### 核心控制器\n- [[DataiConfigurationController]]: 配置主控制器\n- [[DataiConfigEnvironmentController]]: 环境配置控制器\n- [[DataiConfigAuditLogController]]: 审计日志控制器\n- [[DataiConfigSnapshotController]]: 配置快照控制器\n\n### 🛠️ 核心方法\n- **配置管理**: 创建、更新、删除、查询配置\n- **环境管理**: 环境的切换和管理\n- **审计日志**: 配置变更的审计记录查询\n- **快照管理**: 配置快照的创建和恢复\n\n### 📋 依赖注入\n- `IDataiConfigurationService`: 配置服务\n- `IDataiConfigEnvironmentService`: 环境配置服务\n- `IDataiConfigAuditLogService`: 审计日志服务\n- `IDataiConfigSnapshotService`: 快照服务\n\n**设计意图**提供配置管理的REST接口支持前端操作和集成调用实现配置的完整生命周期管理","parentNode":"group_setting","x":2020,"y":740,"width":600,"height":300,"color":"5"},
{"id":"node_setting_service","type":"text","text":"## 配置服务\n> [!info] 职责描述\n> 实现配置管理的业务逻辑\n\n### 核心服务接口\n- [[IDataiConfigurationService]]: 配置服务\n- [[IDataiConfigEnvironmentService]]: 环境配置服务\n- [[IDataiConfigAuditLogService]]: 审计日志服务\n- [[IDataiConfigSnapshotService]]: 快照服务\n\n### 服务实现\n- [[DataiConfigurationServiceImpl]]: 配置服务实现\n- [[DataiConfigEnvironmentServiceImpl]]: 环境配置服务实现\n- [[DataiConfigAuditLogServiceImpl]]: 审计日志服务实现\n- [[DataiConfigSnapshotServiceImpl]]: 快照服务实现\n\n### 🛠️ 核心方法\n- **配置服务**: 创建、更新、删除、查询配置\n- **环境服务**: 环境的切换和管理\n- **审计服务**: 记录和查询配置变更\n- **快照服务**: 配置快照的创建和恢复\n\n### 📋 依赖注入\n- **配置服务**: DataiConfigurationMapper, ConfigChangeEventPublisher\n- **环境服务**: DataiConfigEnvironmentMapper, EnvironmentSwitchEventPublisher\n- **审计服务**: DataiConfigAuditLogMapper\n- **快照服务**: DataiConfigSnapshotMapper, DataiConfigurationMapper\n\n### 服务功能\n- **配置CRUD**: 配置的增删改查\n- **环境管理**: 环境的切换和管理\n- **审计记录**: 记录配置变更\n- **快照管理**: 配置快照的创建和恢复\n\n**设计意图**:实现配置管理的业务逻辑,为控制器提供服务支持,处理配置的完整生命周期,包括创建、更新、删除、查询、审计和快照管理","parentNode":"group_setting","x":2020,"y":1300,"width":600,"height":350,"color":"4"},
{"id":"node_setting_event","type":"text","text":"## 配置事件\n> [!info] 职责描述\n> 处理配置变更和环境切换事件\n\n### 核心事件\n- [[ConfigChangeEvent]]: 配置变更事件\n- [[EnvironmentSwitchEvent]]: 环境切换事件\n\n### 事件监听器\n- [[ConfigChangeListener]]: 配置变更监听器\n- [[EnvironmentSwitchListener]]: 环境切换监听器\n\n### 事件流程\n1. 配置变更时触发 ConfigChangeEvent\n2. 环境切换时触发 EnvironmentSwitchEvent\n3. 监听器捕获事件并执行相应处理\n\n```mermaid\nflowchart TD\n A[配置变更] --> B[触发ConfigChangeEvent]\n B --> C[ConfigChangeListener处理]\n C --> D[重置配置缓存]\n E[环境切换] --> F[触发EnvironmentSwitchEvent]\n F --> G[EnvironmentSwitchListener处理]\n G --> H[更新系统状态]\n```\n\n**设计意图**:通过事件机制实现配置变更的解耦处理,提高系统的可扩展性和模块化程度","parentNode":"group_setting","x":2020,"y":1825,"width":600,"height":300,"color":"4"},
{"id":"node_setting_model","type":"text","text":"## 配置模型\n> [!info] 职责描述\n> 定义配置相关的数据模型\n\n### 领域模型\n- [[DataiConfiguration]]: 配置主模型\n- [[DataiConfigEnvironment]]: 环境配置模型\n- [[DataiConfigAuditLog]]: 审计日志模型\n- [[DataiConfigSnapshot]]: 配置快照模型\n\n### DTO\n- [[DataiConfigurationDto]]: 配置DTO\n- [[DataiConfigEnvironmentDto]]: 环境配置DTO\n- [[DataiConfigAuditLogDto]]: 审计日志DTO\n- [[DataiConfigSnapshotDto]]: 快照DTO\n\n### VO\n- [[DataiConfigurationVo]]: 配置VO\n- [[DataiConfigEnvironmentVo]]: 环境配置VO\n- [[DataiConfigAuditLogVo]]: 审计日志VO\n- [[DataiConfigSnapshotVo]]: 快照VO\n\n### 核心属性\n- **配置主模型**: id, configKey, configValue, environmentId, isActive, createTime, updateTime\n- **环境配置模型**: id, environmentCode, environmentName, isActive, createTime, updateTime\n- **审计日志模型**: id, operationType, operationUser, objectId, objectName, beforeValue, afterValue, createTime\n- **快照模型**: id, snapshotName, snapshotDescription, snapshotTime, createUser, configCount\n\n**设计意图**定义清晰的配置数据模型分离领域模型、DTO和VO提高代码可维护性和数据传输的规范性","parentNode":"group_setting","x":2020,"y":2300,"width":600,"height":300,"color":"1"},
{"id":"node_setting_mapper","type":"text","text":"## 配置Mapper\n> [!info] 职责描述\n> 处理配置相关数据的持久化操作\n\n### 核心Mapper\n- [[DataiConfigurationMapper]]: 配置Mapper\n- [[DataiConfigEnvironmentMapper]]: 环境配置Mapper\n- [[DataiConfigAuditLogMapper]]: 审计日志Mapper\n- [[DataiConfigSnapshotMapper]]: 快照Mapper\n\n### 核心方法\n- **配置Mapper**: 配置的CRUD操作\n- **环境Mapper**: 环境的CRUD操作\n- **审计Mapper**: 审计日志的CRUD操作\n- **快照Mapper**: 快照的CRUD操作\n\n**设计意图**:提供配置数据的访问层,处理数据库操作,为服务层提供数据支持","parentNode":"group_setting","x":2020,"y":2725,"width":600,"height":200,"color":"6"},
{"id":"node_setting_future","type":"text","text":"## 异步任务\n> [!info] 职责描述\n> 提供异步任务执行和管理功能\n\n### 核心类\n- [[ComparableFutureTask]]: 可比较的Future任务\n- [[SalesforceExecutor]]: Salesforce执行器\n\n### 🛠️ 核心方法\n- **异步执行**: 支持异步执行任务\n- **任务管理**: 管理任务的执行状态\n- **结果处理**: 处理任务执行结果\n\n### 功能特性\n- **可比较性**: 支持任务优先级比较\n- **线程池管理**: 合理管理线程资源\n- **异常处理**: 完善的异常处理机制\n\n**设计意图**:提供异步任务执行能力,提高系统的并发处理能力和响应速度,支持配置管理中的异步操作","parentNode":"group_setting","x":1300,"y":3325,"width":600,"height":250,"color":"4"},
{"id":"node_integration_proxy","type":"text","text":"## 集成代理\n> [!info] 职责描述\n> 为Salesforce连接提供代理功能\n\n### 核心代理\n- [[ConnectionProxy]]: 连接代理\n\n### 功能特性\n- **连接监控**: 监控连接的使用情况\n- **错误处理**: 统一处理连接错误\n- **重试机制**: 自动重试失败的请求\n- **性能统计**: 统计连接的性能指标\n\n**设计意图**为Salesforce连接提供代理功能增强连接的可靠性和可监控性","parentNode":"group_integration","x":360,"y":1650,"width":500,"height":200,"color":"5"}
],
"edges":[
{"id":"edge_auth_controller_to_service","fromNode":"node_auth_controller","fromSide":"bottom","toNode":"node_salesforce_login_service","toSide":"top","color":"4","label":"调用"},
{"id":"edge_login_history_controller_to_service","fromNode":"node_login_history_controller","fromSide":"bottom","toNode":"node_salesforce_login_service","toSide":"top","color":"4","label":"调用"},
{"id":"edge_login_session_controller_to_service","fromNode":"node_login_session_controller","fromSide":"bottom","toNode":"node_salesforce_login_service","toSide":"top","color":"4","label":"调用"},
{"id":"edge_salesforce_login_service_to_strategy","fromNode":"node_salesforce_login_service","fromSide":"right","toNode":"node_login_strategy","toSide":"left","color":"4","label":"使用策略"},
{"id":"edge_salesforce_login_service_to_oauth2","fromNode":"node_salesforce_login_service","fromSide":"right","toNode":"node_oauth2_strategy","toSide":"left","color":"4","label":"使用OAuth2策略"},
{"id":"edge_salesforce_login_service_to_model","fromNode":"node_salesforce_login_service","fromSide":"right","toNode":"node_auth_model","toSide":"left","color":"4","label":"使用模型"},
{"id":"edge_salesforce_login_service_to_mapper","fromNode":"node_salesforce_login_service","fromSide":"right","toNode":"node_auth_mapper","toSide":"left","color":"4","label":"调用"},
{"id":"edge_login_strategy_to_factory","fromNode":"node_login_strategy","fromSide":"right","toNode":"node_login_strategy_factory","toSide":"left","color":"4","label":"使用工厂"},
{"id":"edge_auth_to_integration","fromNode":"node_salesforce_login_service","fromSide":"right","toNode":"node_session_manager_detail","toSide":"left","color":"4","label":"提供登录服务"},
{"id":"edge_integration_to_common","fromNode":"node_integration_core","fromSide":"right","toNode":"node_common_util","toSide":"left","color":"4","label":"使用工具类"},
{"id":"edge_auth_to_common","fromNode":"node_login_strategy","fromSide":"right","toNode":"node_common_constant","toSide":"left","color":"4","label":"使用常量"},
{"id":"edge_oauth2_to_session","fromNode":"node_oauth2_strategy","fromSide":"right","toNode":"node_session_manager_detail","toSide":"left","color":"4","label":"提供登录结果"},
{"id":"edge_session_to_connections","fromNode":"node_session_manager_detail","fromSide":"bottom","toNode":"node_integration_connections","toSide":"top","color":"4","label":"提供会话信息"},
{"id":"edge_integration_core_to_task","fromNode":"node_integration_core","fromSide":"bottom","toNode":"node_integration_task","toSide":"top","color":"4","label":"提供连接"},
{"id":"edge_integration_core_to_model","fromNode":"node_integration_core","fromSide":"bottom","toNode":"node_integration_model","toSide":"top","color":"4","label":"使用模型"},
{"id":"edge_integration_task_to_mapper","fromNode":"node_integration_task","fromSide":"bottom","toNode":"node_integration_mapper","toSide":"top","color":"4","label":"调用"},
{"id":"edge_integration_core_to_proxy","fromNode":"node_integration_core","fromSide":"bottom","toNode":"node_integration_proxy","toSide":"top","color":"4","label":"使用代理"},
{"id":"edge_salesforce_login_service_to_exception","fromNode":"node_salesforce_login_service","fromSide":"right","toNode":"node_common_exception","toSide":"left","color":"4","label":"使用异常类"},
{"id":"edge_oauth2_strategy_to_exception","fromNode":"node_oauth2_strategy","fromSide":"right","toNode":"node_common_exception","toSide":"left","color":"4","label":"使用异常类"},
{"id":"edge_session_manager_to_exception","fromNode":"node_session_manager_detail","fromSide":"right","toNode":"node_common_exception","toSide":"left","color":"4","label":"使用异常类"},
{"id":"edge_login_service_to_setting","fromNode":"node_salesforce_login_service","fromSide":"right","toNode":"node_setting_config","toSide":"left","color":"4","label":"使用配置管理"},
{"id":"edge_oauth2_strategy_to_setting","fromNode":"node_oauth2_strategy","fromSide":"right","toNode":"node_setting_config","toSide":"left","color":"4","label":"使用配置管理"},
{"id":"edge_setting_controller_to_service","fromNode":"node_setting_controller","fromSide":"bottom","toNode":"node_setting_service","toSide":"top","color":"4","label":"调用"},
{"id":"edge_setting_service_to_model","fromNode":"node_setting_service","fromSide":"bottom","toNode":"node_setting_model","toSide":"top","color":"4","label":"使用模型"},
{"id":"edge_setting_service_to_mapper","fromNode":"node_setting_service","fromSide":"bottom","toNode":"node_setting_mapper","toSide":"top","color":"4","label":"调用"},
{"id":"edge_setting_service_to_event","fromNode":"node_setting_service","fromSide":"left","toNode":"node_setting_event","toSide":"right","color":"4","label":"触发事件"},
{"id":"edge_integration_to_realtime_sync","fromNode":"node_integration_core","fromSide":"bottom","toNode":"node_realtime_sync","toSide":"top","color":"4","label":"提供连接"},
{"id":"edge_realtime_sync_to_mapper","fromNode":"node_realtime_sync","fromSide":"bottom","toNode":"node_integration_mapper","toSide":"top","color":"4","label":"调用"},
{"id":"edge_realtime_sync_to_log","fromNode":"node_realtime_sync","fromSide":"right","toNode":"node_realtime_sync_log","toSide":"left","color":"4","label":"记录日志"}
],
"groups":[
{"id":"group_auth","label":"📦 认证模块 (datai-salesforce-auth)","x":-1200,"y":0,"width":900,"height":3000,"color":"4"},
{"id":"group_integration","label":"📦 集成模块 (datai-salesforce-integration)","x":-150,"y":0,"width":750,"height":3300,"color":"4"},
{"id":"group_common","label":"📦 通用模块 (datai-salesforce-common)","x":550,"y":0,"width":650,"height":2300,"color":"6"},
{"id":"group_setting","label":"📦 配置模块 (datai-salesforce-setting)","x":1200,"y":0,"width":800,"height":3300,"color":"4"}
]
}