forked from wangziqi/gongxue-base
feat(sync): add import request/result logging
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { BadRequestException, Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
import { BadRequestException, Body, Controller, Get, Logger, Post, Query, UseGuards } from '@nestjs/common';
|
||||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||||
import { RequirePermission } from '../auth/decorators/permission.decorator';
|
import { RequirePermission } from '../auth/decorators/permission.decorator';
|
||||||
import { SyncService } from './sync.service';
|
import { SyncService } from './sync.service';
|
||||||
@@ -8,6 +8,7 @@ import { ImportUsersDto } from './dto/import-users.dto';
|
|||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@Controller('sync')
|
@Controller('sync')
|
||||||
export class SyncController {
|
export class SyncController {
|
||||||
|
private readonly logger = new Logger(SyncController.name);
|
||||||
constructor(private readonly syncService: SyncService) {}
|
constructor(private readonly syncService: SyncService) {}
|
||||||
|
|
||||||
@Post('trigger')
|
@Post('trigger')
|
||||||
@@ -54,7 +55,10 @@ export class SyncController {
|
|||||||
@Post('dingtalk/import-users')
|
@Post('dingtalk/import-users')
|
||||||
@RequirePermission('sync:trigger')
|
@RequirePermission('sync:trigger')
|
||||||
async importDingTalkUsers(@Body() body: ImportUsersDto) {
|
async importDingTalkUsers(@Body() body: ImportUsersDto) {
|
||||||
|
this.logger.log(`[import] users=${body.users.length} classes=${body.classes?.length || 0}`);
|
||||||
|
this.logger.log(`[import] sample user: ${JSON.stringify(body.users[0])}`);
|
||||||
const result = await this.syncService.importDingTalkUsers(body.users, body.classes);
|
const result = await this.syncService.importDingTalkUsers(body.users, body.classes);
|
||||||
|
this.logger.log(`[import result] ${JSON.stringify(result)}`);
|
||||||
return { success: true, ...result };
|
return { success: true, ...result };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user