liuyun 13510ee216 feat(tenant): 租户 onboarding 模板 + 级联删除
- 抽取 seed 资源/字典到 tenant-template.ts,initTenant 幂等初始化租户
- 创建租户自动初始化管理员/根组织/角色/资源/字典
- 删除租户级联清理全部业务数据
- 修复 BaseCrudService 对 Tenant 模型的 tenantCode 大小写注入 bug

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-11 16:32:46 +08:00

71 lines
1.8 KiB
TypeScript
Raw 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.

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsIn, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { PageQuery } from '../common/page.dto.js';
import { CommonStatus } from '../common/enums.js';
export class CreateTenantDto {
@ApiProperty({ description: '租户编码' })
@IsString()
@IsNotEmpty()
code!: string;
@ApiProperty({ description: '租户名称' })
@IsString()
@IsNotEmpty()
name!: string;
@ApiPropertyOptional({ description: '状态:enabled/disabled', default: 'enabled' })
@IsOptional()
@IsIn(Object.values(CommonStatus))
status?: string;
@ApiPropertyOptional({ description: '初始管理员用户名', default: 'admin' })
@IsOptional()
@IsString()
adminUsername?: string;
@ApiPropertyOptional({ description: '初始管理员密码', default: 'Admin@123456' })
@IsOptional()
@IsString()
adminPassword?: string;
@ApiPropertyOptional({ description: '备注' })
@IsOptional()
@IsString()
remark?: string;
}
export class UpdateTenantDto {
@ApiPropertyOptional({ description: '租户名称' })
@IsOptional()
@IsString()
name?: string;
@ApiPropertyOptional({ description: '状态:enabled/disabled' })
@IsOptional()
@IsIn(Object.values(CommonStatus))
status?: string;
@ApiPropertyOptional({ description: '备注' })
@IsOptional()
@IsString()
remark?: string;
}
export class ListTenantQuery extends PageQuery {
@ApiPropertyOptional({ description: '租户名称(模糊)' })
@IsOptional()
@IsString()
name?: string;
@ApiPropertyOptional({ description: '租户编码(模糊)' })
@IsOptional()
@IsString()
code?: string;
@ApiPropertyOptional({ description: '状态:enabled/disabled' })
@IsOptional()
@IsIn(Object.values(CommonStatus))
status?: string;
}