mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-08-26 06:49:39 +00:00
feat: add BookableSpace entity, DTO, repository, and integrate with Space entity
This commit is contained in:
@ -0,0 +1,51 @@
|
||||
import {
|
||||
Entity,
|
||||
Column,
|
||||
ManyToOne,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
Unique,
|
||||
} from 'typeorm';
|
||||
import { SpaceEntity } from '../../space/entities/space.entity';
|
||||
import { DaysEnum } from '@app/common/constants/days.enum';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { BookableSpaceDto } from '../dtos';
|
||||
|
||||
@Entity('bookable-space')
|
||||
@Unique(['space'])
|
||||
export class BookableSpaceEntity extends AbstractEntity<BookableSpaceDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.bookableConfigs, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
space: SpaceEntity;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: DaysEnum,
|
||||
array: true,
|
||||
nullable: false,
|
||||
})
|
||||
daysAvailable: DaysEnum[];
|
||||
|
||||
@Column({ type: 'time' })
|
||||
startTime: string;
|
||||
|
||||
@Column({ type: 'time' })
|
||||
endTime: string;
|
||||
|
||||
@Column({ type: 'int' })
|
||||
points: number;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
}
|
Reference in New Issue
Block a user