Add time rezerv
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { BusinessEntity } from './business.entity';
|
||||
|
||||
/** dayOfWeek: 0=شنبه … 6=جمعه (Iranian week) */
|
||||
@Entity('business_availability_slots')
|
||||
export class BusinessAvailabilitySlotEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@ManyToOne(() => BusinessEntity, (business) => business.availabilitySlots, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'businessId' })
|
||||
business!: BusinessEntity;
|
||||
|
||||
@Column('uuid')
|
||||
businessId!: string;
|
||||
|
||||
@Column({ type: 'smallint' })
|
||||
dayOfWeek!: number;
|
||||
|
||||
/** Minutes from midnight (0–1439), inclusive start */
|
||||
@Column({ type: 'int' })
|
||||
startMinute!: number;
|
||||
|
||||
/** Minutes from midnight, exclusive end */
|
||||
@Column({ type: 'int' })
|
||||
endMinute!: number;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt!: Date;
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { BookingEntity } from './booking.entity';
|
||||
import { BusinessAttributeValueEntity } from './business-attribute-value.entity';
|
||||
import { BusinessCategoryEntity } from './business-category.entity';
|
||||
import { BusinessImageEntity } from './business-image.entity';
|
||||
import { BusinessAvailabilitySlotEntity } from './business-availability-slot.entity';
|
||||
import { BusinessServiceEntity } from './business-service.entity';
|
||||
import { UserEntity } from './user.entity';
|
||||
|
||||
@@ -77,6 +78,11 @@ export class BusinessEntity {
|
||||
@OneToMany(() => BookingEntity, (booking) => booking.business)
|
||||
bookings!: BookingEntity[];
|
||||
|
||||
@OneToMany(() => BusinessAvailabilitySlotEntity, (slot) => slot.business, {
|
||||
cascade: true,
|
||||
})
|
||||
availabilitySlots!: BusinessAvailabilitySlotEntity[];
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user