Skip to content

Commit

Permalink
💄 lint check #136
Browse files Browse the repository at this point in the history
lint check #136
  • Loading branch information
sichoi42 committed Oct 28, 2022
1 parent 2df7f60 commit 9604aa8
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 90 deletions.
12 changes: 10 additions & 2 deletions backend/src/cabinet/cabinet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ export class CabinetService {
return result;
}

async getCabinetIdBySection(location: string, floor: number, section: string): Promise<number[]> {
async getCabinetIdBySection(
location: string,
floor: number,
section: string,
): Promise<number[]> {
this.logger.debug(`Called ${this.getCabinetIdBySection.name}`);
return await this.cabinetRepository.getCabinetIdBySection(location, floor, section);
return await this.cabinetRepository.getCabinetIdBySection(
location,
floor,
section,
);
}
}
14 changes: 9 additions & 5 deletions backend/src/cabinet/repository/cabinet.repository.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ export interface ICabinetRepository {

/**
* section별로 lent된 cabinetid list를 가져옵니다.
*
* @param location
* @param floor
* @param section
*
* @param location
* @param floor
* @param section
*/
getCabinetIdBySection(location: string, floor: number, section: string): Promise<number[]>;
getCabinetIdBySection(
location: string,
floor: number,
section: string,
): Promise<number[]>;
}
23 changes: 14 additions & 9 deletions backend/src/cabinet/repository/cabinet.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,20 @@ export class CabinetRepository implements ICabinetRepository {
return result;
}

async getCabinetIdBySection(location: string, floor: number, section: string): Promise<number[]> {
const result = await this.cabinetRepository.createQueryBuilder('c')
.innerJoin('c.lent', 'lent')
.select('lent_cabinet_id')
.where( {location} )
.andWhere({ floor })
.andWhere({ section })
.getRawMany();
async getCabinetIdBySection(
location: string,
floor: number,
section: string,
): Promise<number[]> {
const result = await this.cabinetRepository
.createQueryBuilder('c')
.innerJoin('c.lent', 'lent')
.select('lent_cabinet_id')
.where({ location })
.andWhere({ floor })
.andWhere({ section })
.getRawMany();

return result.map((c) => c.lent_cabinet_id)
return result.map((c) => c.lent_cabinet_id);
}
}
2 changes: 0 additions & 2 deletions backend/src/return/return.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
BadRequestException,
Controller,
Delete,
Get,
Logger,
Param,
ParseIntPipe,
Patch,
Query,
Expand Down
12 changes: 10 additions & 2 deletions backend/src/return/return.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ export class ReturnService {
return result;
}

async sectionReturn(location: string, floor: number, section: string): Promise<void> {
async sectionReturn(
location: string,
floor: number,
section: string,
): Promise<void> {
this.logger.debug(`Called ${this.sectionReturn.name}`);
const cabinetList = await this.cabinetService.getCabinetIdBySection(location, floor, section);
const cabinetList = await this.cabinetService.getCabinetIdBySection(
location,
floor,
section,
);
cabinetList.forEach(async (id) => await this.patchReturn(id));
}
}
25 changes: 17 additions & 8 deletions backend/src/search/repository/search.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ export class SearchRepository implements ISearchRepository {
) {}

async getLentByIntraId(intraId: string): Promise<LentDto[]> {
const result = await this.userRepository.createQueryBuilder('u')
.select(['u.intra_id', 'u.state'])
.addSelect(['c.cabinet_id', 'c.cabinet_id', 'c.cabinet_num', 'c.location', 'c.section', 'c.floor', 'c.cabinet_status'])
.addSelect(['l.lent_id', 'l.lent_time', 'l.expire_time'])
.leftJoin('lent', 'l', 'l.lent_user_id = u.user_id')
.leftJoin('cabinet', 'c', 'c.cabinet_id = l.lent_cabinet_id')
.where('u.intra_id = :intraId', { intraId })
.execute();
const result = await this.userRepository
.createQueryBuilder('u')
.select(['u.intra_id', 'u.state'])
.addSelect([
'c.cabinet_id',
'c.cabinet_id',
'c.cabinet_num',
'c.location',
'c.section',
'c.floor',
'c.cabinet_status',
])
.addSelect(['l.lent_id', 'l.lent_time', 'l.expire_time'])
.leftJoin('lent', 'l', 'l.lent_user_id = u.user_id')
.leftJoin('cabinet', 'c', 'c.cabinet_id = l.lent_cabinet_id')
.where('u.intra_id = :intraId', { intraId })
.execute();
if (result.length === 0) {
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/search/search.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class SearchController {
intra_id: resultFromLentLog[0].intra_id,
auth: 0,
cabinet_id: null,
cabinet_num:null,
cabinet_num: null,
location: null,
section: null,
floor: null,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/v3/cabinet/cabinet.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Get, Logger, UseGuards } from '@nestjs/common';
import { Controller, Logger, UseGuards } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { JWTAuthGuard } from 'src/auth/auth.guard';
import { CabinetService } from './cabinet.service';
Expand Down
16 changes: 8 additions & 8 deletions backend/src/v3/cabinet/cabinet.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { AuthModule } from "src/auth/auth.module";
import Cabinet from "src/entities/cabinet.entity";
import { CabinetController } from "./cabinet.controller";
import { CabinetService } from "./cabinet.service";
import { CabinetRepository } from "./repository/cabinet.repository";
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from 'src/auth/auth.module';
import Cabinet from 'src/entities/cabinet.entity';
import { CabinetController } from './cabinet.controller';
import { CabinetService } from './cabinet.service';
import { CabinetRepository } from './repository/cabinet.repository';

const repo = {
provide: 'ICabinetRepository',
useClass: CabinetRepository,
};

@Module({
@Module({
imports: [AuthModule, TypeOrmModule.forFeature([Cabinet])],
exports: [CabinetService],
controllers: [CabinetController],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export interface ICabinetRepository {

}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ICabinetRepository {}
8 changes: 4 additions & 4 deletions backend/src/v3/cabinet/repository/cabinet.repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InjectRepository } from "@nestjs/typeorm";
import Cabinet from "src/entities/cabinet.entity";
import { Repository } from "typeorm";
import { ICabinetRepository } from "./cabinet.repository.interface";
import { InjectRepository } from '@nestjs/typeorm';
import Cabinet from 'src/entities/cabinet.entity';
import { Repository } from 'typeorm';
import { ICabinetRepository } from './cabinet.repository.interface';

export class CabinetRepository implements ICabinetRepository {
constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export interface IReturnRepository {

}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface IReturnRepository {}
10 changes: 5 additions & 5 deletions backend/src/v3/return/repository/return.repository.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { InjectRepository } from "@nestjs/typeorm";
import Cabinet from "src/entities/cabinet.entity";
import { Repository } from "typeorm";
import { IReturnRepository } from "./return.repository.interface";
import { InjectRepository } from '@nestjs/typeorm';
import Cabinet from 'src/entities/cabinet.entity';
import { Repository } from 'typeorm';
import { IReturnRepository } from './return.repository.interface';

export class ReturnRepository implements IReturnRepository {
constructor(
@InjectRepository(Cabinet) private cabinetRepository: Repository<Cabinet>,
@InjectRepository(Cabinet) private cabinetRepository: Repository<Cabinet>,
) {}
}
6 changes: 1 addition & 5 deletions backend/src/v3/return/return.controller.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
Controller,
Logger,
UseGuards,
} from '@nestjs/common';
import { Controller, Logger, UseGuards } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { JWTAuthGuard } from 'src/auth/auth.guard';
import { ReturnService } from './return.service';
Expand Down
16 changes: 8 additions & 8 deletions backend/src/v3/return/return.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { AuthModule } from "src/auth/auth.module";
import Cabinet from "src/entities/cabinet.entity";
import { CabinetModule } from "../cabinet/cabinet.module";
import { ReturnRepository } from "./repository/return.repository";
import { ReturnController } from "./return.controller";
import { ReturnService } from "./return.service";
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from 'src/auth/auth.module';
import Cabinet from 'src/entities/cabinet.entity';
import { CabinetModule } from '../cabinet/cabinet.module';
import { ReturnRepository } from './repository/return.repository';
import { ReturnController } from './return.controller';
import { ReturnService } from './return.service';

const repo = {
provide: 'IReturnRepository',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export interface ISearchRepository {

}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ISearchRepository {}
12 changes: 6 additions & 6 deletions backend/src/v3/search/repository/search.repository.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { InjectRepository } from "@nestjs/typeorm";
import Cabinet from "src/entities/cabinet.entity";
import LentLog from "src/entities/lent.log.entity";
import User from "src/entities/user.entity";
import { Repository } from "typeorm";
import { ISearchRepository } from "./search.repository.interface";
import { InjectRepository } from '@nestjs/typeorm';
import Cabinet from 'src/entities/cabinet.entity';
import LentLog from 'src/entities/lent.log.entity';
import User from 'src/entities/user.entity';
import { Repository } from 'typeorm';
import { ISearchRepository } from './search.repository.interface';

export class SearchRepository implements ISearchRepository {
constructor(
Expand Down
7 changes: 1 addition & 6 deletions backend/src/v3/search/search.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Controller,
Get,
Logger,
UseGuards,
} from '@nestjs/common';
import { Controller, Logger, UseGuards } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { JWTAuthGuard } from 'src/auth/auth.guard';
import { SearchService } from './search.service';
Expand Down
4 changes: 2 additions & 2 deletions backend/src/v3/search/search.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Injectable, Logger } from "@nestjs/common";
import { ISearchRepository } from "./repository/search.repository.interface";
import { Inject, Injectable, Logger } from '@nestjs/common';
import { ISearchRepository } from './repository/search.repository.interface';

@Injectable()
export class SearchService {
Expand Down
5 changes: 2 additions & 3 deletions backend/src/v3/user/repository/user.repository.interface.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export interface IUserRepository {

}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface IUserRepository {}
8 changes: 4 additions & 4 deletions backend/src/v3/user/repository/user.repository.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InjectRepository } from "@nestjs/typeorm";
import User from "src/entities/user.entity";
import { Repository } from "typeorm";
import { IUserRepository } from "./user.repository.interface";
import { InjectRepository } from '@nestjs/typeorm';
import User from 'src/entities/user.entity';
import { Repository } from 'typeorm';
import { IUserRepository } from './user.repository.interface';

export class UserRepository implements IUserRepository {
constructor(
Expand Down

0 comments on commit 9604aa8

Please sign in to comment.