From 14d30a294961a27973dc2978567c9ad4e898fde6 Mon Sep 17 00:00:00 2001 From: niamu01 Date: Fri, 8 Dec 2023 23:52:35 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20utilModule=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - #189 --- src/auth/auth.controller.ts | 2 +- src/auth/auth.module.ts | 4 ++-- src/data-calculator/data-calculator.module.ts | 8 ++++++++ .../date-calculator.component.spec.ts | 0 .../date-calculator.component.ts | 0 src/ext/ext.module.ts | 9 +-------- src/{utils => google-api}/google-api.component.ts | 2 +- src/google-api/google-api.module.ts | 8 ++++++++ src/tag-log-v1/tag-log-admin.service.ts | 2 +- src/tag-log-v1/tag-log.module.ts | 6 ++---- src/tag-log-v1/tag-log.service.ts | 2 +- src/tag-log-v2/tag-log-v2-admin.service.ts | 2 +- src/tag-log-v2/tag-log-v2.module.ts | 7 ++----- src/tag-log-v2/tag-log-v2.service.spec.ts | 6 +++--- src/tag-log-v2/tag-log-v2.service.ts | 12 ++++++------ src/utils/utils.module.ts | 9 --------- 16 files changed, 37 insertions(+), 42 deletions(-) create mode 100644 src/data-calculator/data-calculator.module.ts rename src/{utils => data-calculator}/date-calculator.component.spec.ts (100%) rename src/{utils => data-calculator}/date-calculator.component.ts (100%) rename src/{utils => google-api}/google-api.component.ts (96%) create mode 100644 src/google-api/google-api.module.ts delete mode 100644 src/utils/utils.module.ts diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 9c8fe57..feca410 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -14,7 +14,7 @@ import { ApiResponse, ApiTags, } from '@nestjs/swagger'; -import { GoogleApi } from 'src/utils/google-api.component'; +import { GoogleApi } from 'src/google-api/google-api.component'; import { FtOAuthGuard } from './guard/ft-oauth.guard'; import { JWTSignGuard } from './guard/jwt-sign.guard'; import { UserAuthGuard } from './guard/user-auth.guard'; diff --git a/src/auth/auth.module.ts b/src/auth/auth.module.ts index 634ed9d..a0f0448 100644 --- a/src/auth/auth.module.ts +++ b/src/auth/auth.module.ts @@ -4,7 +4,7 @@ import { JwtModule } from '@nestjs/jwt'; import { PassportModule } from '@nestjs/passport'; import { TypeOrmModule } from '@nestjs/typeorm'; import { UserInfo } from 'src/entities/user-info.entity'; -import { UtilsModule } from 'src/utils/utils.module'; +import { GoogleModule } from 'src/google-api/google-api.module'; import { Auth42Controller } from './auth.controller'; import { AuthService } from './auth.service'; import { AuthRepository } from './repository/auth.repository'; @@ -21,7 +21,7 @@ const repo = { @Module({ imports: [ TypeOrmModule.forFeature([UserInfo]), - UtilsModule, + GoogleModule, PassportModule, JwtModule.registerAsync({ useFactory: async (configService: ConfigService) => ({ diff --git a/src/data-calculator/data-calculator.module.ts b/src/data-calculator/data-calculator.module.ts new file mode 100644 index 0000000..d6d5d29 --- /dev/null +++ b/src/data-calculator/data-calculator.module.ts @@ -0,0 +1,8 @@ +import { Module } from '@nestjs/common'; +import { DateCalculator } from './date-calculator.component'; + +@Module({ + providers: [DateCalculator], + exports: [DateCalculator], +}) +export class DateCalculatorModule {} diff --git a/src/utils/date-calculator.component.spec.ts b/src/data-calculator/date-calculator.component.spec.ts similarity index 100% rename from src/utils/date-calculator.component.spec.ts rename to src/data-calculator/date-calculator.component.spec.ts diff --git a/src/utils/date-calculator.component.ts b/src/data-calculator/date-calculator.component.ts similarity index 100% rename from src/utils/date-calculator.component.ts rename to src/data-calculator/date-calculator.component.ts diff --git a/src/ext/ext.module.ts b/src/ext/ext.module.ts index 3074b69..c54bd36 100644 --- a/src/ext/ext.module.ts +++ b/src/ext/ext.module.ts @@ -1,10 +1,8 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { AuthModule } from 'src/auth/auth.module'; import { DeviceInfo } from 'src/entities/device-info.entity'; import { TagLog } from 'src/entities/tag-log.entity'; import { TagLogRepository } from 'src/tag-log-v1/repository/mysql/tag-log.repository'; -import { TagLogModule } from 'src/tag-log-v1/tag-log.module'; import { UserModule } from 'src/user/user.module'; import { ExtService } from './ext.service'; import { DeviceInfoRepository } from './repository/mysql/device-info.repository'; @@ -24,12 +22,7 @@ const deviceInfoRepo = { * 24Hane 기능 외 다른 서비스에서 사용하는 외부 API 모듈 */ @Module({ - imports: [ - AuthModule, - UserModule, - TagLogModule, - TypeOrmModule.forFeature([DeviceInfo, TagLog]), - ], + imports: [UserModule, TypeOrmModule.forFeature([DeviceInfo, TagLog])], controllers: [Where42Controller], providers: [tagLogRepo, deviceInfoRepo, ExtService], }) diff --git a/src/utils/google-api.component.ts b/src/google-api/google-api.component.ts similarity index 96% rename from src/utils/google-api.component.ts rename to src/google-api/google-api.component.ts index 951ebf0..d1b4950 100644 --- a/src/utils/google-api.component.ts +++ b/src/google-api/google-api.component.ts @@ -1,6 +1,6 @@ +import { auth, sheets } from '@googleapis/sheets'; import { Inject, Injectable, Logger } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; -import { sheets, auth } from '@googleapis/sheets'; /** * doosoo 팀장님의 요청에 따라 Google API를 이용해서 Spread Sheet로 Data를 송부하기 위한 컴포넌트입니다. diff --git a/src/google-api/google-api.module.ts b/src/google-api/google-api.module.ts new file mode 100644 index 0000000..0b5b730 --- /dev/null +++ b/src/google-api/google-api.module.ts @@ -0,0 +1,8 @@ +import { Module } from '@nestjs/common'; +import { GoogleApi } from './google-api.component'; + +@Module({ + providers: [GoogleApi], + exports: [GoogleApi], +}) +export class GoogleModule {} diff --git a/src/tag-log-v1/tag-log-admin.service.ts b/src/tag-log-v1/tag-log-admin.service.ts index a097bd0..00818f0 100644 --- a/src/tag-log-v1/tag-log-admin.service.ts +++ b/src/tag-log-v1/tag-log-admin.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; +import { DateCalculator } from 'src/data-calculator/date-calculator.component'; import { UserService } from 'src/user/user.service'; -import { DateCalculator } from 'src/utils/date-calculator.component'; import { UserAccumulationDayType } from './dto/admin/user-accumulation-day.type'; import { UserAccumulationMonthType } from './dto/admin/user-accumulation-month.type'; import { TagLogService } from './tag-log.service'; diff --git a/src/tag-log-v1/tag-log.module.ts b/src/tag-log-v1/tag-log.module.ts index 79f5240..0de3140 100644 --- a/src/tag-log-v1/tag-log.module.ts +++ b/src/tag-log-v1/tag-log.module.ts @@ -1,10 +1,9 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { AuthModule } from 'src/auth/auth.module'; +import { DateCalculatorModule } from 'src/data-calculator/data-calculator.module'; import { PairInfo } from 'src/entities/pair-info.entity'; import { TagLog } from 'src/entities/tag-log.entity'; import { UserModule } from 'src/user/user.module'; -import { UtilsModule } from 'src/utils/utils.module'; import { PairInfoRepository } from './repository/mysql/pair-info.repository'; import { TagLogRepository } from './repository/mysql/tag-log.repository'; import { TagLogAdminController } from './tag-log-admin.controller'; @@ -24,9 +23,8 @@ const pairInfoRepo = { @Module({ imports: [ - AuthModule, TypeOrmModule.forFeature([TagLog, PairInfo]), - UtilsModule, + DateCalculatorModule, UserModule, ], exports: [TypeOrmModule], diff --git a/src/tag-log-v1/tag-log.service.ts b/src/tag-log-v1/tag-log.service.ts index 6e125d8..2942cd9 100644 --- a/src/tag-log-v1/tag-log.service.ts +++ b/src/tag-log-v1/tag-log.service.ts @@ -1,7 +1,7 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; import InOut from 'src/enums/inout.enum'; import { UserService } from 'src/user/user.service'; -import { DateCalculator } from 'src/utils/date-calculator.component'; +import { DateCalculator } from 'src/data-calculator/date-calculator.component'; import { InOutDto } from './dto/inout.dto'; import { TagLogDto } from './dto/tag-log.dto'; import { PairInfoDto } from './dto/pair-info.dto'; diff --git a/src/tag-log-v2/tag-log-v2-admin.service.ts b/src/tag-log-v2/tag-log-v2-admin.service.ts index b4cff5d..3e86548 100644 --- a/src/tag-log-v2/tag-log-v2-admin.service.ts +++ b/src/tag-log-v2/tag-log-v2-admin.service.ts @@ -1,6 +1,6 @@ import { Injectable, Logger } from '@nestjs/common'; import { UserService } from 'src/user/user.service'; -import { DateCalculator } from 'src/utils/date-calculator.component'; +import { DateCalculator } from 'src/data-calculator/date-calculator.component'; import { UserAccumulationDayType } from './dto/admin/user-accumulation-day.type'; import { UserAccumulationMonthType } from './dto/admin/user-accumulation-month.type'; import { TagLogService } from './tag-log-v2.service'; diff --git a/src/tag-log-v2/tag-log-v2.module.ts b/src/tag-log-v2/tag-log-v2.module.ts index cc4161a..4968522 100644 --- a/src/tag-log-v2/tag-log-v2.module.ts +++ b/src/tag-log-v2/tag-log-v2.module.ts @@ -1,19 +1,17 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; -import { AuthModule } from 'src/auth/auth.module'; +import { DateCalculatorModule } from 'src/data-calculator/data-calculator.module'; import { DeviceInfo } from 'src/entities/device-info.entity'; import { PairInfo } from 'src/entities/pair-info.entity'; import { TagLog } from 'src/entities/tag-log.entity'; import { StatisticsModule } from 'src/statistics/statictics.module'; import { UserModule } from 'src/user/user.module'; -import { UtilsModule } from 'src/utils/utils.module'; import { Cabi42Controller } from '../ext/cabi42.controller'; import { DeviceInfoRepository } from './repository/mysql/device-info.repository'; import { PairInfoRepository } from './repository/mysql/pair-info.repository'; import { TagLogRepository } from './repository/mysql/tag-log.repository'; import { TagLogAdminController } from './tag-log-v2-admin.controller'; import { TagLogAdminService } from './tag-log-v2-admin.service'; - import { TagLogController } from './tag-log-v2.controller'; import { TagLogService } from './tag-log-v2.service'; @@ -34,9 +32,8 @@ const deviceInfoRepo = { @Module({ imports: [ - AuthModule, TypeOrmModule.forFeature([TagLog, PairInfo, DeviceInfo]), - UtilsModule, + DateCalculatorModule, UserModule, StatisticsModule, ], diff --git a/src/tag-log-v2/tag-log-v2.service.spec.ts b/src/tag-log-v2/tag-log-v2.service.spec.ts index 4fcfe89..a3e661f 100644 --- a/src/tag-log-v2/tag-log-v2.service.spec.ts +++ b/src/tag-log-v2/tag-log-v2.service.spec.ts @@ -1,9 +1,9 @@ import { Test, TestingModule } from '@nestjs/testing'; -import { TagLogService } from './tag-log-v2.service'; +import { DateCalculator } from 'src/data-calculator/date-calculator.component'; +import { UserService } from 'src/user/user.service'; import { PairInfoDto } from './dto/pair-info.dto'; import { TagLogDto } from './dto/tag-log.dto'; -import { DateCalculator } from 'src/utils/date-calculator.component'; -import { UserService } from 'src/user/user.service'; +import { TagLogService } from './tag-log-v2.service'; const mocks = [ { diff --git a/src/tag-log-v2/tag-log-v2.service.ts b/src/tag-log-v2/tag-log-v2.service.ts index 8dfb290..032c40e 100644 --- a/src/tag-log-v2/tag-log-v2.service.ts +++ b/src/tag-log-v2/tag-log-v2.service.ts @@ -1,16 +1,16 @@ import { Inject, Injectable, Logger } from '@nestjs/common'; +import { DateCalculator } from 'src/data-calculator/date-calculator.component'; import InOut from 'src/enums/inout.enum'; +import { CardDto } from 'src/user/dto/card.dto'; import { UserService } from 'src/user/user.service'; -import { DateCalculator } from 'src/utils/date-calculator.component'; +import { DeviceInfoDto } from './dto/device-info.dto'; import { InOutDto } from './dto/inout.dto'; -import { TagLogDto } from './dto/tag-log.dto'; import { PairInfoDto } from './dto/pair-info.dto'; import { InOutLogType } from './dto/subType/InOutLog.type'; -import { ITagLogRepository } from './repository/interface/tag-log-repository.interface'; -import { IPairInfoRepository } from './repository/interface/pair-info-repository.interface'; -import { CardDto } from 'src/user/dto/card.dto'; +import { TagLogDto } from './dto/tag-log.dto'; import { IDeviceInfoRepository } from './repository/interface/device-info-repository.interface'; -import { DeviceInfoDto } from './dto/device-info.dto'; +import { IPairInfoRepository } from './repository/interface/pair-info-repository.interface'; +import { ITagLogRepository } from './repository/interface/tag-log-repository.interface'; @Injectable() export class TagLogService { diff --git a/src/utils/utils.module.ts b/src/utils/utils.module.ts deleted file mode 100644 index 788a2b7..0000000 --- a/src/utils/utils.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Module } from '@nestjs/common'; -import { DateCalculator } from './date-calculator.component'; -import { GoogleApi } from './google-api.component'; - -@Module({ - providers: [DateCalculator, GoogleApi], - exports: [DateCalculator, GoogleApi], -}) -export class UtilsModule {}