feat: add org-tree-with-users and import-users endpoints
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { BadRequestException, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { BadRequestException, Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { RequirePermission } from '../auth/decorators/permission.decorator';
|
||||
import { SyncService } from './sync.service';
|
||||
@@ -40,6 +40,21 @@ export class SyncController {
|
||||
return { success: true, data: tree };
|
||||
}
|
||||
|
||||
/** 获取钉钉组织部门树(含用户),供同步用户选择器使用 */
|
||||
@Get('dingtalk/org-tree-with-users')
|
||||
@RequirePermission('sync:read')
|
||||
async getDingTalkOrgTreeWithUsers(@Query('rootDeptId') rootDeptId?: string) {
|
||||
const rootId = rootDeptId ? this.parseRootDeptId(rootDeptId) : 1;
|
||||
const tree = await this.syncService.getDingTalkOrgTreeWithUsers(rootId);
|
||||
return { success: true, data: tree };
|
||||
}
|
||||
/** 导入钉钉用户:老师分配角色,学生创建 Student */
|
||||
@Post('dingtalk/import-users')
|
||||
@RequirePermission('sync:trigger')
|
||||
async importDingTalkUsers(@Body() body: { users: Array<{ dingUserId: string; name: string; mobile: string; roleId: number | null }> }) {
|
||||
const result = await this.syncService.importDingTalkUsers(body.users);
|
||||
return { success: true, ...result };
|
||||
}
|
||||
@Get('logs')
|
||||
@RequirePermission('sync:read')
|
||||
async getLogs(
|
||||
|
||||
Reference in New Issue
Block a user