Skip to content

Commit

Permalink
✨ add v3 lent module #114
Browse files Browse the repository at this point in the history
add v3 lent module #114
  • Loading branch information
sichoi42 committed Nov 2, 2022
1 parent e633df9 commit de7ed88
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 1 deletion.
11 changes: 11 additions & 0 deletions backend/src/v3/lent/lent.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Controller, Get, Logger, UseGuards } from '@nestjs/common';
import { JWTAuthGuard } from 'src/auth/auth.guard';
import { LentService } from './lent.service';

@Controller('lent')
@UseGuards(JWTAuthGuard)
export class LentController {
private logger = new Logger(LentController.name);

constructor(private lentService: LentService) {}
}
19 changes: 19 additions & 0 deletions backend/src/v3/lent/lent.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from 'src/auth/auth.module';
import Lent from 'src/entities/lent.entity';
import { LentController } from './lent.controller';
import { LentService } from './lent.service';
import { LentRepository } from './repository/lent.repository';

const repo = {
provide: 'ILentRepository',
useClass: LentRepository,
};

@Module({
controllers: [LentController],
providers: [LentService, repo],
imports: [AuthModule, TypeOrmModule.forFeature([Lent])], // for JWTAuthGuard
})
export class LentModule {}
12 changes: 12 additions & 0 deletions backend/src/v3/lent/lent.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Inject, Injectable, Logger } from '@nestjs/common';
import { ILentRepository } from './repository/lent.repository.interface';

@Injectable()
export class LentService {
private logger = new Logger(LentService.name);

constructor(
@Inject('ILentRepository')
private lentRepository: ILentRepository,
) {}
}
4 changes: 4 additions & 0 deletions backend/src/v3/lent/repository/lent.repository.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ILentRepository {

}
11 changes: 11 additions & 0 deletions backend/src/v3/lent/repository/lent.repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { InjectRepository } from "@nestjs/typeorm";
import Lent from "src/entities/lent.entity";
import { Repository } from "typeorm";
import { ILentRepository } from "./lent.repository.interface";

export class LentRepository implements ILentRepository {
constructor(
@InjectRepository(Lent)
private lentRepository: Repository<Lent>,
) {}
}
3 changes: 2 additions & 1 deletion backend/src/v3/v3.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Module } from '@nestjs/common';
import { AuthModule } from 'src/auth/auth.module';
import { CabinetModule } from './cabinet/cabinet.module';
import { LentModule } from './lent/lent.module';
import { ReturnModule } from './return/return.module';
import { SearchModule } from './search/search.module';
import { UserModule } from './user/user.module';

@Module({
imports: [AuthModule, CabinetModule, ReturnModule, SearchModule, UserModule],
imports: [AuthModule, CabinetModule, LentModule, ReturnModule, SearchModule, UserModule],
controllers: [],
providers: [],
})
Expand Down

0 comments on commit de7ed88

Please sign in to comment.