53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import {
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
Unique,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { BookingEntity } from './booking.entity';
|
|
import { BusinessServiceEntity } from './business-service.entity';
|
|
import { UserEntity } from './user.entity';
|
|
|
|
@Entity('customer_service_loyalty')
|
|
@Unique('UQ_customer_service_loyalty', ['customerId', 'businessServiceId'])
|
|
export class CustomerServiceLoyaltyEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@ManyToOne(() => UserEntity, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'customerId' })
|
|
customer!: UserEntity;
|
|
|
|
@Column('uuid')
|
|
customerId!: string;
|
|
|
|
@ManyToOne(() => BusinessServiceEntity, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'businessServiceId' })
|
|
businessService!: BusinessServiceEntity;
|
|
|
|
@Column('uuid')
|
|
businessServiceId!: string;
|
|
|
|
/** Number of paid completed visits toward the next free service. */
|
|
@Column({ type: 'int', default: 0 })
|
|
paidCount!: number;
|
|
|
|
/** Booking currently holding a reserved free redeem (awaiting payment / confirmed). */
|
|
@ManyToOne(() => BookingEntity, { nullable: true, onDelete: 'SET NULL' })
|
|
@JoinColumn({ name: 'reservedBookingId' })
|
|
reservedBooking!: BookingEntity | null;
|
|
|
|
@Column({ type: 'uuid', nullable: true })
|
|
reservedBookingId!: string | null;
|
|
|
|
@CreateDateColumn()
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updatedAt!: Date;
|
|
}
|