mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 18:24:54 +00:00
add contract dates to invite user & return them in user details
This commit is contained in:
3
libs/common/src/constants/timer-job-type.enum.ts
Normal file
3
libs/common/src/constants/timer-job-type.enum.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export enum TimerJobTypeEnum {
|
||||
INVITE_USER_EMAIL = 'INVITE_USER_EMAIL',
|
||||
}
|
||||
@ -54,6 +54,7 @@ import { SpaceEntity } from '../modules/space/entities/space.entity';
|
||||
import { SubspaceProductAllocationEntity } from '../modules/space/entities/subspace/subspace-product-allocation.entity';
|
||||
import { SubspaceEntity } from '../modules/space/entities/subspace/subspace.entity';
|
||||
import { NewTagEntity } from '../modules/tag/entities/tag.entity';
|
||||
import { TimerEntity } from '../modules/timer/entities/timer.entity';
|
||||
import { TimeZoneEntity } from '../modules/timezone/entities';
|
||||
import {
|
||||
UserNotificationEntity,
|
||||
@ -121,6 +122,7 @@ import { VisitorPasswordEntity } from '../modules/visitor-password/entities';
|
||||
SpaceDailyOccupancyDurationEntity,
|
||||
BookableSpaceEntity,
|
||||
BookingEntity,
|
||||
TimerEntity,
|
||||
],
|
||||
namingStrategy: new SnakeNamingStrategy(),
|
||||
synchronize: Boolean(JSON.parse(configService.get('DB_SYNC'))),
|
||||
|
||||
@ -15,17 +15,16 @@ import { ProjectEntity } from '../../project/entities';
|
||||
import { RoleTypeEntity } from '../../role-type/entities';
|
||||
import { SpaceEntity } from '../../space/entities/space.entity';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
import { InviteUserDto, InviteUserSpaceDto } from '../dtos';
|
||||
|
||||
@Entity({ name: 'invite-user' })
|
||||
@Unique(['email', 'project'])
|
||||
export class InviteUserEntity extends AbstractEntity<InviteUserDto> {
|
||||
export class InviteUserEntity extends AbstractEntity {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
@ -49,50 +48,67 @@ export class InviteUserEntity extends AbstractEntity<InviteUserDto> {
|
||||
status: string;
|
||||
|
||||
@Column()
|
||||
public firstName: string;
|
||||
firstName: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public lastName: string;
|
||||
lastName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
})
|
||||
public phoneNumber: string;
|
||||
phoneNumber: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: true,
|
||||
})
|
||||
public isActive: boolean;
|
||||
isActive: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: true,
|
||||
})
|
||||
public isEnabled: boolean;
|
||||
isEnabled: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
unique: true,
|
||||
})
|
||||
public invitationCode: string;
|
||||
invitationCode: string;
|
||||
|
||||
@Column({
|
||||
default: new Date(),
|
||||
type: 'date',
|
||||
})
|
||||
accessStartDate: Date;
|
||||
|
||||
@Column({
|
||||
type: 'date',
|
||||
nullable: true,
|
||||
})
|
||||
accessEndDate?: Date;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
enum: Object.values(RoleType),
|
||||
})
|
||||
public invitedBy: string;
|
||||
invitedBy: string;
|
||||
|
||||
@ManyToOne(() => RoleTypeEntity, (roleType) => roleType.invitedUsers, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
public roleType: RoleTypeEntity;
|
||||
roleType: RoleTypeEntity;
|
||||
|
||||
@OneToOne(() => UserEntity, (user) => user.inviteUser, {
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'user_uuid' })
|
||||
user: UserEntity;
|
||||
|
||||
@OneToMany(
|
||||
() => InviteUserSpaceEntity,
|
||||
(inviteUserSpace) => inviteUserSpace.inviteUser,
|
||||
@ -103,32 +119,34 @@ export class InviteUserEntity extends AbstractEntity<InviteUserDto> {
|
||||
nullable: true,
|
||||
})
|
||||
@JoinColumn({ name: 'project_uuid' })
|
||||
public project: ProjectEntity;
|
||||
project: ProjectEntity;
|
||||
|
||||
constructor(partial: Partial<InviteUserEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'invite-user-space' })
|
||||
@Unique(['inviteUser', 'space'])
|
||||
export class InviteUserSpaceEntity extends AbstractEntity<InviteUserSpaceDto> {
|
||||
export class InviteUserSpaceEntity extends AbstractEntity {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
uuid: string;
|
||||
|
||||
@ManyToOne(() => InviteUserEntity, (inviteUser) => inviteUser.spaces, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'invite_user_uuid' })
|
||||
public inviteUser: InviteUserEntity;
|
||||
inviteUser: InviteUserEntity;
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.invitedUsers)
|
||||
@JoinColumn({ name: 'space_uuid' })
|
||||
public space: SpaceEntity;
|
||||
space: SpaceEntity;
|
||||
|
||||
constructor(partial: Partial<InviteUserSpaceEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
|
||||
37
libs/common/src/modules/timer/entities/timer.entity.ts
Normal file
37
libs/common/src/modules/timer/entities/timer.entity.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { TimerJobTypeEnum } from '@app/common/constants/timer-job-type.enum';
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
|
||||
@Entity({ name: 'timer' })
|
||||
export class TimerEntity extends AbstractEntity {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
enum: Object.values(TimerJobTypeEnum),
|
||||
type: String,
|
||||
})
|
||||
type: TimerJobTypeEnum;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
type: 'date',
|
||||
})
|
||||
triggerDate: Date;
|
||||
|
||||
@Column({
|
||||
type: 'jsonb',
|
||||
nullable: true,
|
||||
})
|
||||
metadata?: Record<string, any>;
|
||||
|
||||
constructor(partial: Partial<TimerEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { TimerEntity } from '../entities/timer.entity';
|
||||
|
||||
@Injectable()
|
||||
export class TimerRepository extends Repository<TimerEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(TimerEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
12
libs/common/src/modules/timer/timer.repository.module.ts
Normal file
12
libs/common/src/modules/timer/timer.repository.module.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { TimerEntity } from './entities/timer.entity';
|
||||
import { TimerRepository } from './repositories/timer.repository';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([TimerEntity])],
|
||||
providers: [TimerRepository],
|
||||
exports: [TimerRepository],
|
||||
})
|
||||
export class TimerRepositoryModule {}
|
||||
@ -11,6 +11,7 @@ import {
|
||||
} from 'typeorm';
|
||||
import { OtpType } from '../../../../src/constants/otp-type.enum';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { BookingEntity } from '../../booking/entities/booking.entity';
|
||||
import { ClientEntity } from '../../client/entities';
|
||||
import {
|
||||
DeviceNotificationEntity,
|
||||
@ -29,7 +30,6 @@ import {
|
||||
UserOtpDto,
|
||||
UserSpaceDto,
|
||||
} from '../dtos';
|
||||
import { BookingEntity } from '../../booking/entities/booking.entity';
|
||||
|
||||
@Entity({ name: 'user' })
|
||||
export class UserEntity extends AbstractEntity<UserDto> {
|
||||
@ -101,6 +101,9 @@ export class UserEntity extends AbstractEntity<UserDto> {
|
||||
@Column({ type: 'timestamp', nullable: true })
|
||||
appAgreementAcceptedAt: Date;
|
||||
|
||||
@Column({ type: Boolean, default: false })
|
||||
bookingEnabled: boolean;
|
||||
|
||||
@OneToMany(() => UserSpaceEntity, (userSpace) => userSpace.user, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user