- Updated role.entity.ts: slug is now required (NOT NULL) - Updated rbac.service.ts: generate slug from code when creating roles - Tenant entity already complete with all DDL fields (no changes needed) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
66 lines
1.4 KiB
TypeScript
66 lines
1.4 KiB
TypeScript
import {
|
|
Entity,
|
|
Column,
|
|
PrimaryGeneratedColumn,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
Index,
|
|
ManyToMany,
|
|
JoinTable,
|
|
} from 'typeorm';
|
|
import { Permission } from './permission.entity';
|
|
|
|
@Entity({ schema: 'users', name: 'roles' })
|
|
export class Role {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ type: 'uuid' })
|
|
@Index()
|
|
tenant_id: string;
|
|
|
|
@Column({ type: 'varchar', length: 100 })
|
|
name: string;
|
|
|
|
@Column({ type: 'varchar', length: 50 })
|
|
@Index()
|
|
code: string;
|
|
|
|
@Column({ type: 'varchar', length: 100 })
|
|
@Index()
|
|
slug: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
description: string | null;
|
|
|
|
@Column({ type: 'jsonb', nullable: true })
|
|
permissions: string[] | null;
|
|
|
|
@Column({ type: 'uuid', nullable: true })
|
|
parent_role_id: string | null;
|
|
|
|
@Column({ type: 'int', default: 0 })
|
|
level: number;
|
|
|
|
@Column({ type: 'boolean', default: false })
|
|
is_system: boolean;
|
|
|
|
@Column({ type: 'boolean', default: true })
|
|
is_active: boolean;
|
|
|
|
@Column({ type: 'jsonb', nullable: true })
|
|
metadata: Record<string, any> | null;
|
|
|
|
@CreateDateColumn({ type: 'timestamp with time zone' })
|
|
created_at: Date;
|
|
|
|
@UpdateDateColumn({ type: 'timestamp with time zone' })
|
|
updated_at: Date;
|
|
|
|
@Column({ type: 'uuid', nullable: true })
|
|
created_by: string | null;
|
|
|
|
// Relations will be handled via service queries for now
|
|
// to avoid complex eager loading issues
|
|
}
|