mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 18:56:22 +00:00
merged with dev
This commit is contained in:
@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { DeviceNotificationEntity } from './entities';
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([DeviceNotificationEntity])],
|
||||
})
|
||||
export class DeviceNotificationRepositoryModule {}
|
@ -1,15 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class DeviceNotificationDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public deviceUuid: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.notification.dto';
|
@ -1,33 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceNotificationDto } from '../dtos';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'device-notification' })
|
||||
@Unique(['userUuid', 'deviceUuid'])
|
||||
export class DeviceNotificationEntity extends AbstractEntity<DeviceNotificationDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public userUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
deviceUuid: string;
|
||||
|
||||
@ManyToOne(() => DeviceEntity, (device) => device.permission, {
|
||||
nullable: false,
|
||||
})
|
||||
device: DeviceEntity;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
constructor(partial: Partial<DeviceNotificationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.notification.entity';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DeviceNotificationEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class DeviceNotificationRepository extends Repository<DeviceNotificationEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(DeviceNotificationEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.notification.repository';
|
@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { DeviceUserPermissionEntity } from './entities';
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([DeviceUserPermissionEntity])],
|
||||
})
|
||||
export class DeviceUserPermissionRepositoryModule {}
|
@ -1,19 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class DeviceUserPermissionDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public deviceUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public permissionTypeUuid: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.user.permission.dto';
|
@ -1,43 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceUserPermissionDto } from '../dtos';
|
||||
import { PermissionTypeEntity } from '../../permission/entities';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'device-user-permission' })
|
||||
@Unique(['userUuid', 'deviceUuid'])
|
||||
export class DeviceUserPermissionEntity extends AbstractEntity<DeviceUserPermissionDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public userUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
deviceUuid: string;
|
||||
|
||||
@ManyToOne(() => DeviceEntity, (device) => device.permission, {
|
||||
nullable: false,
|
||||
})
|
||||
device: DeviceEntity;
|
||||
|
||||
@ManyToOne(
|
||||
() => PermissionTypeEntity,
|
||||
(permissionType) => permissionType.permission,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
permissionType: PermissionTypeEntity;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
constructor(partial: Partial<DeviceUserPermissionEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.user.permission.entity';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DeviceUserPermissionEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class DeviceUserPermissionRepository extends Repository<DeviceUserPermissionEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(DeviceUserPermissionEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './device.user.permission.repository';
|
@ -1,11 +1,21 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { DeviceEntity } from './entities';
|
||||
import {
|
||||
DeviceEntity,
|
||||
DeviceNotificationEntity,
|
||||
DeviceUserPermissionEntity,
|
||||
} from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([DeviceEntity])],
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([
|
||||
DeviceEntity,
|
||||
DeviceNotificationEntity,
|
||||
DeviceUserPermissionEntity,
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class DeviceRepositoryModule {}
|
||||
|
@ -21,3 +21,35 @@ export class DeviceDto {
|
||||
@IsNotEmpty()
|
||||
productUuid: string;
|
||||
}
|
||||
|
||||
export class DeviceUserPermissionDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public deviceUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public permissionTypeUuid: string;
|
||||
}
|
||||
|
||||
export class DeviceNotificationDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public deviceUuid: string;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany, Unique, Index } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { DeviceDto } from '../dtos/device.dto';
|
||||
import { DeviceDto, DeviceUserPermissionDto } from '../dtos/device.dto';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
import { ProductEntity } from '../../product/entities';
|
||||
import { DeviceUserPermissionEntity } from '../../device-user-permission/entities';
|
||||
import { DeviceNotificationEntity } from '../../device-notification/entities';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
import { DeviceNotificationDto } from '../dtos';
|
||||
import { PermissionTypeEntity } from '../../permission/entities';
|
||||
|
||||
@Entity({ name: 'device' })
|
||||
@Unique(['deviceTuyaUuid'])
|
||||
@ -60,3 +60,68 @@ export class DeviceEntity extends AbstractEntity<DeviceDto> {
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'device-notification' })
|
||||
@Unique(['userUuid', 'deviceUuid'])
|
||||
export class DeviceNotificationEntity extends AbstractEntity<DeviceNotificationDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public userUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
deviceUuid: string;
|
||||
|
||||
@ManyToOne(() => DeviceEntity, (device) => device.permission, {
|
||||
nullable: false,
|
||||
})
|
||||
device: DeviceEntity;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
constructor(partial: Partial<DeviceNotificationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'device-user-permission' })
|
||||
@Unique(['userUuid', 'deviceUuid'])
|
||||
export class DeviceUserPermissionEntity extends AbstractEntity<DeviceUserPermissionDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public userUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
deviceUuid: string;
|
||||
|
||||
@ManyToOne(() => DeviceEntity, (device) => device.permission, {
|
||||
nullable: false,
|
||||
})
|
||||
device: DeviceEntity;
|
||||
|
||||
@ManyToOne(
|
||||
() => PermissionTypeEntity,
|
||||
(permissionType) => permissionType.permission,
|
||||
{
|
||||
nullable: false,
|
||||
},
|
||||
)
|
||||
permissionType: PermissionTypeEntity;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userPermission, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
constructor(partial: Partial<DeviceUserPermissionEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { DeviceEntity } from '../entities';
|
||||
import {
|
||||
DeviceEntity,
|
||||
DeviceNotificationEntity,
|
||||
DeviceUserPermissionEntity,
|
||||
} from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class DeviceRepository extends Repository<DeviceEntity> {
|
||||
@ -8,3 +12,15 @@ export class DeviceRepository extends Repository<DeviceEntity> {
|
||||
super(DeviceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
@Injectable()
|
||||
export class DeviceNotificationRepository extends Repository<DeviceNotificationEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(DeviceNotificationEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
@Injectable()
|
||||
export class DeviceUserPermissionRepository extends Repository<DeviceUserPermissionEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(DeviceUserPermissionEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { PermissionType } from '@app/common/constants/permission-type.enum';
|
||||
import { PermissionTypeDto } from '../dtos/permission.dto';
|
||||
import { DeviceUserPermissionEntity } from '../../device-user-permission/entities';
|
||||
import { DeviceUserPermissionEntity } from '../../device/entities';
|
||||
|
||||
@Entity({ name: 'permission-type' })
|
||||
export class PermissionTypeEntity extends AbstractEntity<PermissionTypeDto> {
|
||||
|
@ -2,7 +2,7 @@ import { Column, Entity, OneToMany, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { RoleTypeDto } from '../dtos/role.type.dto';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { UserRoleEntity } from '../../user-role/entities';
|
||||
import { UserRoleEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'role-type' })
|
||||
@Unique(['type'])
|
||||
|
@ -1 +0,0 @@
|
||||
export * from './space.type.dto';
|
@ -1,11 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class SpaceTypeDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public type: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './space.type.entity';
|
@ -1,26 +0,0 @@
|
||||
import { Column, Entity, OneToMany } from 'typeorm';
|
||||
import { SpaceTypeDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'space-type' })
|
||||
export class SpaceTypeEntity extends AbstractEntity<SpaceTypeDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
type: string;
|
||||
|
||||
@OneToMany(() => SpaceEntity, (space) => space.spaceType)
|
||||
spaces: SpaceEntity[];
|
||||
constructor(partial: Partial<SpaceTypeEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './space.type.repository';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { SpaceTypeEntity } from '../entities/space.type.entity';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceTypeRepository extends Repository<SpaceTypeEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SpaceTypeEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { SpaceTypeEntity } from './entities/space.type.entity';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([SpaceTypeEntity])],
|
||||
})
|
||||
export class SpaceTypeRepositoryModule {}
|
@ -21,3 +21,13 @@ export class SpaceDto {
|
||||
@IsNotEmpty()
|
||||
public invitationCode: string;
|
||||
}
|
||||
|
||||
export class SpaceTypeDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public type: string;
|
||||
}
|
||||
|
@ -1,16 +1,37 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany, Unique } from 'typeorm';
|
||||
import { SpaceDto } from '../dtos';
|
||||
import { SpaceDto, SpaceTypeDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceTypeEntity } from '../../space-type/entities';
|
||||
import { UserSpaceEntity } from '../../user-space/entities';
|
||||
import { UserSpaceEntity } from '../../user/entities';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
|
||||
@Entity({ name: 'space-type' })
|
||||
export class SpaceTypeEntity extends AbstractEntity<SpaceTypeDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
type: string;
|
||||
|
||||
@OneToMany(() => SpaceEntity, (space) => space.spaceType)
|
||||
spaces: SpaceEntity[];
|
||||
constructor(partial: Partial<SpaceTypeEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'space' })
|
||||
@Unique(['invitationCode'])
|
||||
export class SpaceEntity extends AbstractEntity<SpaceDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { SpaceEntity } from '../entities/space.entity';
|
||||
import { SpaceEntity, SpaceTypeEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class SpaceRepository extends Repository<SpaceEntity> {
|
||||
@ -8,3 +8,10 @@ export class SpaceRepository extends Repository<SpaceEntity> {
|
||||
super(SpaceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SpaceTypeRepository extends Repository<SpaceTypeEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(SpaceTypeEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { SpaceEntity } from './entities/space.entity';
|
||||
import { SpaceEntity, SpaceTypeEntity } from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([SpaceEntity])],
|
||||
imports: [TypeOrmModule.forFeature([SpaceEntity, SpaceTypeEntity])],
|
||||
})
|
||||
export class SpaceRepositoryModule {}
|
||||
|
@ -1 +0,0 @@
|
||||
export * from './user.notification.dto';
|
@ -1,19 +0,0 @@
|
||||
import { IsBoolean, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserNotificationDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public subscriptionUuid: string;
|
||||
|
||||
@IsBoolean()
|
||||
@IsNotEmpty()
|
||||
public active: boolean;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.notification.entity';
|
@ -1,27 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserNotificationDto } from '../dtos';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'user-notification' })
|
||||
@Unique(['user', 'subscriptionUuid'])
|
||||
export class UserNotificationEntity extends AbstractEntity<UserNotificationDto> {
|
||||
@ManyToOne(() => UserEntity, (user) => user.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
subscriptionUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: true,
|
||||
})
|
||||
active: boolean;
|
||||
constructor(partial: Partial<UserNotificationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.notification.repository';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserNotificationEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class UserNotificationRepository extends Repository<UserNotificationEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserNotificationEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserNotificationEntity } from './entities';
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserNotificationEntity])],
|
||||
})
|
||||
export class UserNotificationRepositoryModule {}
|
@ -1 +0,0 @@
|
||||
export * from './user-otp.dto';
|
@ -1,19 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserOtpDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public email: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public otpCode: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public expiryTime: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user-otp.entity';
|
@ -1,37 +0,0 @@
|
||||
import { Column, DeleteDateColumn, Entity } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserOtpDto } from '../dtos';
|
||||
import { OtpType } from '../../../../src/constants/otp-type.enum';
|
||||
|
||||
@Entity({ name: 'user-otp' })
|
||||
export class UserOtpEntity extends AbstractEntity<UserOtpDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
email: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
otpCode: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
expiryTime: Date;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: Object.values(OtpType),
|
||||
})
|
||||
type: OtpType;
|
||||
|
||||
@DeleteDateColumn({ nullable: true })
|
||||
deletedAt?: Date;
|
||||
|
||||
constructor(partial: Partial<UserOtpEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserOtpEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class UserOtpRepository extends Repository<UserOtpEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserOtpEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserOtpEntity } from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserOtpEntity])],
|
||||
})
|
||||
export class UserOtpRepositoryModule {}
|
@ -1 +0,0 @@
|
||||
export * from './user.role.dto';
|
@ -1,15 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserRoleDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public roleTypeUuid: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.role.entity';
|
@ -1,24 +0,0 @@
|
||||
import { Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserRoleDto } from '../dtos';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
import { RoleTypeEntity } from '../../role-type/entities';
|
||||
|
||||
@Entity({ name: 'user-role' })
|
||||
@Unique(['user', 'roleType'])
|
||||
export class UserRoleEntity extends AbstractEntity<UserRoleDto> {
|
||||
@ManyToOne(() => UserEntity, (user) => user.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
|
||||
@ManyToOne(() => RoleTypeEntity, (roleType) => roleType.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
roleType: RoleTypeEntity;
|
||||
|
||||
constructor(partial: Partial<UserRoleEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.role.repository';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserRoleEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class UserRoleRepository extends Repository<UserRoleEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserRoleEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserRoleEntity } from './entities';
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserRoleEntity])],
|
||||
})
|
||||
export class UserRoleRepositoryModule {}
|
@ -1 +0,0 @@
|
||||
export * from './user.space.dto';
|
@ -1,15 +0,0 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserSpaceDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public spaceUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.space.entity';
|
@ -1,29 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from 'typeorm';
|
||||
import { UserSpaceDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
import { UserEntity } from '../../user/entities';
|
||||
|
||||
@Entity({ name: 'user-space' })
|
||||
@Unique(['user', 'space'])
|
||||
export class UserSpaceEntity extends AbstractEntity<UserSpaceDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userSpaces, { nullable: false })
|
||||
user: UserEntity;
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.userSpaces, {
|
||||
nullable: false,
|
||||
})
|
||||
space: SpaceEntity;
|
||||
|
||||
constructor(partial: Partial<UserSpaceEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
export * from './user.space.repository';
|
@ -1,10 +0,0 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserSpaceEntity } from '../entities/user.space.entity';
|
||||
|
||||
@Injectable()
|
||||
export class UserSpaceRepository extends Repository<UserSpaceEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserSpaceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserSpaceEntity } from './entities/user.space.entity';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserSpaceEntity])],
|
||||
})
|
||||
export class UserSpaceRepositoryModule {}
|
@ -1,4 +1,4 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
import { IsBoolean, IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class UserDto {
|
||||
@IsString()
|
||||
@ -21,3 +21,67 @@ export class UserDto {
|
||||
@IsNotEmpty()
|
||||
public lastName: string;
|
||||
}
|
||||
|
||||
export class UserNotificationDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public subscriptionUuid: string;
|
||||
|
||||
@IsBoolean()
|
||||
@IsNotEmpty()
|
||||
public active: boolean;
|
||||
}
|
||||
|
||||
export class UserOtpDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public email: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public otpCode: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public expiryTime: string;
|
||||
}
|
||||
|
||||
export class UserRoleDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public roleTypeUuid: string;
|
||||
}
|
||||
|
||||
export class UserSpaceDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public spaceUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public userUuid: string;
|
||||
}
|
||||
|
@ -1,15 +1,30 @@
|
||||
import { DeviceUserPermissionEntity } from '../../device-user-permission/entities/device.user.permission.entity';
|
||||
import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { UserDto } from '../dtos';
|
||||
import {
|
||||
Column,
|
||||
DeleteDateColumn,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
Unique,
|
||||
} from 'typeorm';
|
||||
import {
|
||||
UserDto,
|
||||
UserNotificationDto,
|
||||
UserOtpDto,
|
||||
UserRoleDto,
|
||||
UserSpaceDto,
|
||||
} from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserSpaceEntity } from '../../user-space/entities';
|
||||
import { UserRoleEntity } from '../../user-role/entities';
|
||||
import { DeviceNotificationEntity } from '../../device-notification/entities';
|
||||
import { UserNotificationEntity } from '../../user-notification/entities';
|
||||
import { DeviceEntity } from '../../device/entities';
|
||||
import {
|
||||
DeviceEntity,
|
||||
DeviceNotificationEntity,
|
||||
DeviceUserPermissionEntity,
|
||||
} from '../../device/entities';
|
||||
import { defaultProfilePicture } from '@app/common/constants/default.profile.picture';
|
||||
import { RegionEntity } from '../../region/entities';
|
||||
import { TimeZoneEntity } from '../../timezone/entities';
|
||||
import { OtpType } from '../../../../src/constants/otp-type.enum';
|
||||
import { RoleTypeEntity } from '../../role-type/entities';
|
||||
import { SpaceEntity } from '../../space/entities';
|
||||
|
||||
@Entity({ name: 'user' })
|
||||
export class UserEntity extends AbstractEntity<UserDto> {
|
||||
@ -99,3 +114,102 @@ export class UserEntity extends AbstractEntity<UserDto> {
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'user-notification' })
|
||||
@Unique(['user', 'subscriptionUuid'])
|
||||
export class UserNotificationEntity extends AbstractEntity<UserNotificationDto> {
|
||||
@ManyToOne(() => UserEntity, (user) => user.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
subscriptionUuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
default: true,
|
||||
})
|
||||
active: boolean;
|
||||
constructor(partial: Partial<UserNotificationEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'user-otp' })
|
||||
export class UserOtpEntity extends AbstractEntity<UserOtpDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()',
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
email: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
otpCode: string;
|
||||
|
||||
@Column({ nullable: false })
|
||||
expiryTime: Date;
|
||||
|
||||
@Column({
|
||||
type: 'enum',
|
||||
enum: Object.values(OtpType),
|
||||
})
|
||||
type: OtpType;
|
||||
|
||||
@DeleteDateColumn({ nullable: true })
|
||||
deletedAt?: Date;
|
||||
|
||||
constructor(partial: Partial<UserOtpEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'user-role' })
|
||||
@Unique(['user', 'roleType'])
|
||||
export class UserRoleEntity extends AbstractEntity<UserRoleDto> {
|
||||
@ManyToOne(() => UserEntity, (user) => user.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
user: UserEntity;
|
||||
|
||||
@ManyToOne(() => RoleTypeEntity, (roleType) => roleType.roles, {
|
||||
nullable: false,
|
||||
})
|
||||
roleType: RoleTypeEntity;
|
||||
|
||||
constructor(partial: Partial<UserRoleEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@Entity({ name: 'user-space' })
|
||||
@Unique(['user', 'space'])
|
||||
export class UserSpaceEntity extends AbstractEntity<UserSpaceDto> {
|
||||
@Column({
|
||||
type: 'uuid',
|
||||
default: () => 'gen_random_uuid()', // Use gen_random_uuid() for default value
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.userSpaces, { nullable: false })
|
||||
user: UserEntity;
|
||||
|
||||
@ManyToOne(() => SpaceEntity, (space) => space.userSpaces, {
|
||||
nullable: false,
|
||||
})
|
||||
space: SpaceEntity;
|
||||
|
||||
constructor(partial: Partial<UserSpaceEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserEntity } from '../entities/user.entity';
|
||||
import {
|
||||
UserEntity,
|
||||
UserNotificationEntity,
|
||||
UserOtpEntity,
|
||||
UserRoleEntity,
|
||||
UserSpaceEntity,
|
||||
} from '../entities/';
|
||||
|
||||
@Injectable()
|
||||
export class UserRepository extends Repository<UserEntity> {
|
||||
@ -8,3 +14,31 @@ export class UserRepository extends Repository<UserEntity> {
|
||||
super(UserEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserNotificationRepository extends Repository<UserNotificationEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserNotificationEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserOtpRepository extends Repository<UserOtpEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserOtpEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserRoleRepository extends Repository<UserRoleEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserRoleEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserSpaceRepository extends Repository<UserSpaceEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserSpaceEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,25 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserEntity } from './entities/user.entity';
|
||||
import {
|
||||
UserEntity,
|
||||
UserNotificationEntity,
|
||||
UserOtpEntity,
|
||||
UserRoleEntity,
|
||||
UserSpaceEntity,
|
||||
} from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserEntity])],
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([
|
||||
UserEntity,
|
||||
UserNotificationEntity,
|
||||
UserOtpEntity,
|
||||
UserRoleEntity,
|
||||
UserSpaceEntity,
|
||||
]),
|
||||
],
|
||||
})
|
||||
export class UserRepositoryModule {}
|
||||
|
Reference in New Issue
Block a user