Restore system sync configuration page

This commit is contained in:
2026-06-10 11:57:02 +08:00
parent 7c0c230c36
commit f6f37e2d7d
9 changed files with 2614 additions and 40 deletions
@@ -0,0 +1,233 @@
import { requestClient } from '#/api/request';
/**
* 连接测试请求
*/
export interface TestConnectionParams {
app_key?: string;
app_secret?: string;
}
/**
* 同步配置
*/
export interface DingtalkSyncConfig {
callback_aes_key?: string;
callback_token?: string;
callback_url?: string;
corp_id?: string;
app_key?: string;
app_secret?: string;
sync_dept_id?: string;
sync_root_dept_id?: string;
enable_dept_event?: string;
enable_user_event?: string;
}
/**
* 回调状态
*/
export interface CallbackStatus {
registered: boolean;
callback_url?: string;
subscribed_events?: string[];
}
/**
* 同步统计项
*/
export interface SyncTypeStats {
total_count: number;
success_count: number;
fail_count: number;
not_synced: number;
status: null | string;
sync_time: null | string;
}
/**
* 同步统计
*/
export interface SyncStats {
dept: SyncTypeStats;
user: SyncTypeStats;
}
/**
* 钉钉部门树节点
*/
export interface DingtalkDeptTreeNode {
dept_id: number;
name: string;
children?: DingtalkDeptTreeNode[];
}
/**
* 异步同步任务返回
*/
export interface SyncTaskResult {
log_id: string;
}
/**
* 同步任务状态查询结果
*/
export interface SyncStatusResult {
id: string;
sync_type: string;
total_count: number;
success_count: number;
fail_count: number;
status: string;
started_at: null | string;
finished_at: null | string;
}
/**
* Stream 增量事件日志
*/
export interface StreamEventLog {
id: string;
event_type: string;
target_type: string;
target_name: null | string;
dingtalk_dept_id: null | string;
dingtalk_userid: null | string;
status: string;
error_detail: null | string;
event_time: null | string;
}
/**
* Stream 事件日志分页结果
*/
export interface StreamEventsResult {
items: StreamEventLog[];
total: number;
page: number;
page_size: number;
}
/**
* 连接测试
*/
export async function testConnectionApi(data: TestConnectionParams) {
return requestClient.post('/api/core/dingtalk-sync/test-connection', data);
}
/**
* 获取同步配置
*/
export async function getSyncConfigApi() {
return requestClient.get<Record<string, any>>(
'/api/core/dingtalk-sync/config',
);
}
/**
* 保存同步配置
*/
export async function updateSyncConfigApi(data: DingtalkSyncConfig) {
return requestClient.put('/api/core/dingtalk-sync/config', data);
}
/**
* 同步组织架构(异步任务)
*/
export async function syncDeptApi() {
return requestClient.post<SyncTaskResult>('/api/core/dingtalk-sync/sync/dept');
}
/**
* 同步用户(异步任务)
*/
export async function syncUserApi() {
return requestClient.post<SyncTaskResult>('/api/core/dingtalk-sync/sync/user');
}
/**
* 查询同步任务状态
*/
export async function getSyncStatusApi(logId: string) {
return requestClient.get<SyncStatusResult>(
`/api/core/dingtalk-sync/sync/status/${logId}`,
);
}
/**
* 获取 Stream 增量事件日志
*/
export async function getStreamEventsApi(page: number = 1, pageSize: number = 20) {
return requestClient.get<StreamEventsResult>('/api/core/dingtalk-sync/stream/events', {
params: { page, page_size: pageSize },
});
}
/**
* 获取同步统计
*/
export async function getSyncStatsApi() {
return requestClient.get<SyncStats>('/api/core/dingtalk-sync/stats');
}
/**
* 获取同步日志
*/
export async function getSyncLogsApi(page: number = 1, pageSize: number = 20) {
return requestClient.get('/api/core/dingtalk-sync/logs', {
params: { page, page_size: pageSize },
});
}
/**
* 获取钉钉部门树(选择同步范围)
*/
export async function getDeptTreeApi(data?: TestConnectionParams) {
return requestClient.post<DingtalkDeptTreeNode[]>(
'/api/core/dingtalk-sync/dept-tree',
data || {},
);
}
/**
* 注册事件回调
*/
export async function registerCallbackApi() {
return requestClient.post('/api/core/dingtalk-sync/callback/register');
}
/**
* 删除事件回调
*/
export async function deleteCallbackApi() {
return requestClient.delete('/api/core/dingtalk-sync/callback/register');
}
/**
* 查询回调注册状态
*/
export async function getCallbackStatusApi() {
return requestClient.get<CallbackStatus>(
'/api/core/dingtalk-sync/callback/status',
);
}
/**
* Stream 模式连接状态
*/
export interface StreamStatus {
stream_mode: boolean;
running: boolean;
total_events: number;
last_event_type: string | null;
last_event_time: string | null;
}
/**
* 查询 Stream 模式状态
*/
export async function getStreamStatusApi() {
return requestClient.get<StreamStatus>(
'/api/core/dingtalk-sync/stream/status',
);
}
@@ -0,0 +1,134 @@
import { requestClient } from '#/api/request';
/**
* 连接测试请求
*/
export interface TestConnectionParams {
app_id?: string;
app_secret?: string;
}
/**
* 同步配置
*/
export interface FeishuSyncConfig {
app_id?: string;
app_secret?: string;
sync_dept_id?: string;
sync_root_dept_id?: string;
enable_dept_event?: string;
enable_user_event?: string;
encrypt_key?: string;
verification_token?: string;
callback_url?: string;
}
/**
* 回调状态
*/
export interface CallbackStatus {
registered: boolean;
callback_url?: string;
subscribed_events?: string[];
}
/**
* 同步统计项
*/
export interface SyncTypeStats {
total_count: number;
success_count: number;
fail_count: number;
not_synced: number;
status: null | string;
sync_time: null | string;
}
/**
* 同步统计
*/
export interface SyncStats {
dept: SyncTypeStats;
user: SyncTypeStats;
}
/**
* 飞书部门树节点
*/
export interface FeishuDeptTreeNode {
dept_id: string;
name: string;
children?: FeishuDeptTreeNode[];
}
/**
* 连接测试
*/
export async function testConnectionApi(data: TestConnectionParams) {
return requestClient.post('/api/core/feishu-sync/test-connection', data);
}
/**
* 获取同步配置
*/
export async function getSyncConfigApi() {
return requestClient.get<Record<string, any>>(
'/api/core/feishu-sync/config',
);
}
/**
* 保存同步配置
*/
export async function updateSyncConfigApi(data: FeishuSyncConfig) {
return requestClient.put('/api/core/feishu-sync/config', data);
}
/**
* 同步组织架构
*/
export async function syncDeptApi() {
return requestClient.post('/api/core/feishu-sync/sync/dept');
}
/**
* 同步用户
*/
export async function syncUserApi() {
return requestClient.post('/api/core/feishu-sync/sync/user');
}
/**
* 获取同步统计
*/
export async function getSyncStatsApi() {
return requestClient.get<SyncStats>('/api/core/feishu-sync/stats');
}
/**
* 获取同步日志
*/
export async function getSyncLogsApi(page: number = 1, pageSize: number = 20) {
return requestClient.get('/api/core/feishu-sync/logs', {
params: { page, page_size: pageSize },
});
}
/**
* 获取飞书部门树(选择同步范围)
*/
export async function getDeptTreeApi(data?: TestConnectionParams) {
return requestClient.post<FeishuDeptTreeNode[]>(
'/api/core/feishu-sync/dept-tree',
data || {},
);
}
/**
* 查询回调注册状态
*/
export async function getCallbackStatusApi() {
return requestClient.get<CallbackStatus>(
'/api/core/feishu-sync/callback/status',
);
}
@@ -0,0 +1,83 @@
import { requestClient } from '#/api/request';
export interface TestConnectionParams {
corp_id?: string;
corp_secret?: string;
}
export interface WecomSyncConfig {
callback_aes_key?: string;
callback_token?: string;
callback_url?: string;
corp_id?: string;
corp_secret?: string;
sync_dept_id?: string;
sync_root_dept_id?: string;
enable_dept_event?: string;
enable_user_event?: string;
}
export interface CallbackStatus {
registered: boolean;
callback_url?: string;
subscribed_events?: string[];
}
export interface SyncTypeStats {
total_count: number;
success_count: number;
fail_count: number;
not_synced: number;
status: null | string;
sync_time: null | string;
}
export interface SyncStats {
dept: SyncTypeStats;
user: SyncTypeStats;
}
export interface WecomDeptTreeNode {
dept_id: number;
name: string;
children?: WecomDeptTreeNode[];
}
export async function testConnectionApi(data: TestConnectionParams) {
return requestClient.post('/api/core/wecom-sync/test-connection', data);
}
export async function getSyncConfigApi() {
return requestClient.get<Record<string, any>>(
'/api/core/wecom-sync/config',
);
}
export async function updateSyncConfigApi(data: WecomSyncConfig) {
return requestClient.put('/api/core/wecom-sync/config', data);
}
export async function syncDeptApi() {
return requestClient.post('/api/core/wecom-sync/sync/dept');
}
export async function syncUserApi() {
return requestClient.post('/api/core/wecom-sync/sync/user');
}
export async function getSyncStatsApi() {
return requestClient.get<SyncStats>('/api/core/wecom-sync/stats');
}
export async function getDeptTreeApi(data?: TestConnectionParams) {
return requestClient.post<WecomDeptTreeNode[]>(
'/api/core/wecom-sync/dept-tree',
data || {},
);
}
export async function getCallbackStatusApi() {
return requestClient.get<CallbackStatus>(
'/api/core/wecom-sync/callback/status',
);
}