first commit
This commit is contained in:
35
myteamwallet_backend/src/forgot/entities/forgot.entity.ts
Normal file
35
myteamwallet_backend/src/forgot/entities/forgot.entity.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
DeleteDateColumn,
|
||||
} from 'typeorm';
|
||||
import { User } from '../../users/entities/user.entity';
|
||||
import { Allow } from 'class-validator';
|
||||
import { EntityHelper } from 'src/utils/entity-helper';
|
||||
|
||||
@Entity()
|
||||
export class Forgot extends EntityHelper {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Allow()
|
||||
@Column()
|
||||
@Index()
|
||||
hash: string;
|
||||
|
||||
@Allow()
|
||||
@ManyToOne(() => User, {
|
||||
eager: true,
|
||||
})
|
||||
user: User;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@DeleteDateColumn()
|
||||
deletedAt: Date;
|
||||
}
|
||||
11
myteamwallet_backend/src/forgot/forgot.module.ts
Normal file
11
myteamwallet_backend/src/forgot/forgot.module.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Forgot } from './entities/forgot.entity';
|
||||
import { ForgotService } from './forgot.service';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Forgot])],
|
||||
providers: [ForgotService],
|
||||
exports: [ForgotService],
|
||||
})
|
||||
export class ForgotModule {}
|
||||
34
myteamwallet_backend/src/forgot/forgot.service.ts
Normal file
34
myteamwallet_backend/src/forgot/forgot.service.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { DeepPartial } from 'src/utils/types/deep-partial.type';
|
||||
import { FindOptions } from 'src/utils/types/find-options.type';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Forgot } from './entities/forgot.entity';
|
||||
|
||||
@Injectable()
|
||||
export class ForgotService {
|
||||
constructor(
|
||||
@InjectRepository(Forgot)
|
||||
private forgotRepository: Repository<Forgot>,
|
||||
) {}
|
||||
|
||||
async findOne(options: FindOptions<Forgot>) {
|
||||
return this.forgotRepository.findOne({
|
||||
where: options.where,
|
||||
});
|
||||
}
|
||||
|
||||
async findMany(options: FindOptions<Forgot>) {
|
||||
return this.forgotRepository.find({
|
||||
where: options.where,
|
||||
});
|
||||
}
|
||||
|
||||
async create(data: DeepPartial<Forgot>) {
|
||||
return this.forgotRepository.save(this.forgotRepository.create(data));
|
||||
}
|
||||
|
||||
async softDelete(id: number): Promise<void> {
|
||||
await this.forgotRepository.softDelete(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user