community controller

This commit is contained in:
hannathkadher
2024-10-15 11:01:56 +04:00
parent a157444897
commit 2292c01220
23 changed files with 822 additions and 259 deletions

View File

@ -0,0 +1,38 @@
import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
import { CommunityDto } from '../dtos';
import { RegionEntity } from '../../region/entities';
import { SpaceEntity } from '../../space/entities';
import { RoleEntity } from '../../role/entities';
@Entity({ name: 'community' })
@Unique(['name'])
export class CommunityEntity extends AbstractEntity<CommunityDto> {
@Column({
type: 'uuid',
default: () => 'gen_random_uuid()',
nullable: false,
})
public uuid: string;
@Column({
length: 255,
nullable: false,
})
name: string;
@Column({ length: 255, nullable: true })
description: string;
@ManyToOne(() => RegionEntity, (region) => region.communities, {
nullable: false,
onDelete: 'CASCADE',
})
region: RegionEntity;
@OneToMany(() => SpaceEntity, (space) => space.community)
spaces: SpaceEntity[];
@OneToMany(() => RoleEntity, (role) => role.community)
roles: RoleEntity[];
}