mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 08:54:54 +00:00
Add invitedBy field to InviteUserDto and InviteUserEntity
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { UserStatusEnum } from '@app/common/constants/user-status.enum';
|
||||
import { IsEnum, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
@ -9,12 +10,15 @@ export class InviteUserDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public email: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public jobTitle: string;
|
||||
|
||||
@IsEnum(UserStatusEnum)
|
||||
@IsNotEmpty()
|
||||
public status: UserStatusEnum;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public firstName: string;
|
||||
@ -22,6 +26,10 @@ export class InviteUserDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public lastName: string;
|
||||
|
||||
@IsEnum(RoleType)
|
||||
@IsNotEmpty()
|
||||
public invitedBy: RoleType;
|
||||
}
|
||||
export class InviteUserSpaceDto {
|
||||
@IsString()
|
||||
|
||||
@ -13,6 +13,7 @@ import { RoleTypeEntity } from '../../role-type/entities';
|
||||
import { UserStatusEnum } from '@app/common/constants/user-status.enum';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
|
||||
@Entity({ name: 'invite-user' })
|
||||
@Unique(['email', 'invitationCode'])
|
||||
@ -69,14 +70,20 @@ export class InviteUserEntity extends AbstractEntity<InviteUserDto> {
|
||||
unique: true,
|
||||
})
|
||||
public invitationCode: string;
|
||||
// Relation with RoleTypeEntity
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
enum: Object.values(RoleType),
|
||||
})
|
||||
public invitedBy: string;
|
||||
|
||||
@ManyToOne(() => RoleTypeEntity, (roleType) => roleType.invitedUsers, {
|
||||
nullable: false,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
public roleType: RoleTypeEntity;
|
||||
@OneToOne(() => UserEntity, (user) => user.inviteUser, { nullable: true })
|
||||
@JoinColumn({ name: 'user_uuid' }) // Foreign key in InviteUserEntity
|
||||
@JoinColumn({ name: 'user_uuid' })
|
||||
user: UserEntity;
|
||||
@OneToMany(
|
||||
() => InviteUserSpaceEntity,
|
||||
|
||||
Reference in New Issue
Block a user