mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 02:36:19 +00:00
Add Visitor Password Management Module
This commit is contained in:
1
libs/common/src/modules/visitor-password/dtos/index.ts
Normal file
1
libs/common/src/modules/visitor-password/dtos/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './visitor-password.dto';
|
@ -0,0 +1,15 @@
|
||||
import { IsNotEmpty, IsString } from 'class-validator';
|
||||
|
||||
export class VisitorPasswordDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public authorizerUuid: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public passwordTuyaUuid: string;
|
||||
}
|
@ -0,0 +1 @@
|
||||
export * from './visitor-password.entity';
|
@ -0,0 +1,25 @@
|
||||
import { Column, Entity, ManyToOne, JoinColumn, Index } from 'typeorm';
|
||||
import { VisitorPasswordDto } from '../dtos';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { UserEntity } from '../../user/entities/user.entity';
|
||||
|
||||
@Entity({ name: 'visitor-password' })
|
||||
@Index('IDX_PASSWORD_TUYA_UUID', ['passwordTuyaUuid'])
|
||||
export class VisitorPasswordEntity extends AbstractEntity<VisitorPasswordDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
unique: true,
|
||||
})
|
||||
public passwordTuyaUuid: string;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.visitorPasswords, {
|
||||
nullable: false,
|
||||
})
|
||||
@JoinColumn({ name: 'authorizer_uuid' })
|
||||
public user: UserEntity;
|
||||
|
||||
constructor(partial: Partial<VisitorPasswordEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
export * from './visitor-password.repository';
|
@ -0,0 +1,10 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { VisitorPasswordEntity } from '../entities/visitor-password.entity';
|
||||
|
||||
@Injectable()
|
||||
export class VisitorPasswordRepository extends Repository<VisitorPasswordEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(VisitorPasswordEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { VisitorPasswordEntity } from './entities/visitor-password.entity';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([VisitorPasswordEntity])],
|
||||
})
|
||||
export class VisitorPasswordRepositoryModule {}
|
Reference in New Issue
Block a user