feat: P2-15 cron-based DingTalk/WeCom sync with logging and incremental sync
- Add @nestjs/schedule dependency
- Create SyncLog entity (platform, syncType, status, recordsCount, errorMessage, timestamps)
- Create SyncState entity for tracking lastSyncAt per platform
- SyncService with @Cron('0 2 * * *') daily scheduled sync
- Incremental sync: tracks last_sync_at per platform, passes to integration APIs
- Full/incremental mode determined by existence of prior sync
- SyncController: POST /sync/trigger (manual), GET /sync/logs (history)
- Register SyncModule in AppModule with ScheduleModule
This commit is contained in:
@@ -25,6 +25,8 @@ import {
|
||||
ClassSchedule,
|
||||
AttendanceRecord,
|
||||
DingAttendanceRaw,
|
||||
SyncLog,
|
||||
SyncState,
|
||||
} from './entities';
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { RbacModule } from './rbac/rbac.module';
|
||||
@@ -43,6 +45,7 @@ import { TenantsModule } from './tenants/tenants.module';
|
||||
import { AttendanceModule } from './attendance/attendance.module';
|
||||
import { SchedulesModule } from './schedules/schedules.module';
|
||||
import { ClassroomRentalsModule } from './classroom-rentals/classroom-rentals.module';
|
||||
import { SyncModule } from './sync/sync.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -77,6 +80,8 @@ import { ClassroomRentalsModule } from './classroom-rentals/classroom-rentals.mo
|
||||
ClassSchedule,
|
||||
AttendanceRecord,
|
||||
DingAttendanceRaw,
|
||||
SyncLog,
|
||||
SyncState,
|
||||
];
|
||||
if (dbType === 'mysql') {
|
||||
return {
|
||||
@@ -115,6 +120,7 @@ import { ClassroomRentalsModule } from './classroom-rentals/classroom-rentals.mo
|
||||
TenantsModule,
|
||||
SchedulesModule,
|
||||
ClassroomRentalsModule,
|
||||
SyncModule,
|
||||
],
|
||||
providers: [
|
||||
{ provide: APP_GUARD, useClass: ThrottlerGuard },
|
||||
|
||||
Reference in New Issue
Block a user