mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-27 18:44:54 +00:00
authentication module done
This commit is contained in:
26
libs/common/src/modules/session/dtos/session.dto.ts
Normal file
26
libs/common/src/modules/session/dtos/session.dto.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import {
|
||||
IsBoolean,
|
||||
IsDate,
|
||||
IsNotEmpty,
|
||||
IsNumber,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
export class SessionDto {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
public uuid: string;
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
userId: number;
|
||||
|
||||
@IsDate()
|
||||
@IsNotEmpty()
|
||||
public loginTime: Date;
|
||||
|
||||
@IsBoolean()
|
||||
@IsNotEmpty()
|
||||
public isLoggedOut: boolean;
|
||||
|
||||
}
|
||||
1
libs/common/src/modules/session/entities/index.ts
Normal file
1
libs/common/src/modules/session/entities/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './session.entity'
|
||||
31
libs/common/src/modules/session/entities/session.entity.ts
Normal file
31
libs/common/src/modules/session/entities/session.entity.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
|
||||
import { SessionDto } from '../dtos/session.dto';
|
||||
|
||||
@Entity({ name: 'userSession' })
|
||||
export class UserSessionEntity extends AbstractEntity<SessionDto> {
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public uuid: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
userId: string;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public loginTime: Date;
|
||||
|
||||
@Column({
|
||||
nullable: false,
|
||||
})
|
||||
public isLoggedOut: boolean;
|
||||
|
||||
constructor(partial: Partial<UserSessionEntity>) {
|
||||
super();
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
import { DataSource, Repository } from 'typeorm';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { UserSessionEntity } from '../entities';
|
||||
|
||||
@Injectable()
|
||||
export class UserSessionRepository extends Repository<UserSessionEntity> {
|
||||
constructor(private dataSource: DataSource) {
|
||||
super(UserSessionEntity, dataSource.createEntityManager());
|
||||
}
|
||||
}
|
||||
11
libs/common/src/modules/session/session.repository.module.ts
Normal file
11
libs/common/src/modules/session/session.repository.module.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UserSessionEntity } from './entities';
|
||||
|
||||
@Module({
|
||||
providers: [],
|
||||
exports: [],
|
||||
controllers: [],
|
||||
imports: [TypeOrmModule.forFeature([UserSessionEntity])],
|
||||
})
|
||||
export class UserSessionRepositoryModule {}
|
||||
Reference in New Issue
Block a user