Skip to content

Commit

Permalink
fix: dataSource 생성자 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
yunuo46 authored and peageon committed Dec 11, 2023
1 parent 9cee9f8 commit c041327
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
5 changes: 2 additions & 3 deletions back/src/modules/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable, UnauthorizedException } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { InjectRepository } from '@nestjs/typeorm';
import { UserEntity } from '../user/entity/user.entity';
import { DataSource, Repository } from 'typeorm';
import { Repository } from 'typeorm';
import { Response } from 'express';

export interface payload {
Expand All @@ -15,8 +15,7 @@ export class AuthService {
constructor(
private readonly jwtService: JwtService,
@InjectRepository(UserEntity)
private readonly UserRepository: Repository<UserEntity>,
private readonly dataSource: DataSource
private readonly UserRepository: Repository<UserEntity>
) {}

async getUserInfo(user: any): Promise<payload> {
Expand Down
15 changes: 3 additions & 12 deletions back/src/modules/message/message.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
NotFoundException
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { DataSource, Repository } from 'typeorm';
import { Repository } from 'typeorm';
import { ReqCreateMessageDto } from './dto/request/req-create-message.dto';
import { MessageEntity } from './entity/message.entity';
import { ResCreateMessageDto } from './dto/response/res-create-message.dto';
Expand All @@ -33,8 +33,7 @@ export class MessageService {
@InjectRepository(LetterEntity)
private readonly letterRepository: Repository<LetterEntity>,
@InjectRepository(DecorationPrefixEntity)
private readonly decorationPrefixRepository: Repository<DecorationPrefixEntity>,
private readonly dataSource: DataSource
private readonly decorationPrefixRepository: Repository<DecorationPrefixEntity>
) {}
async createMessage(
createMessageDto: ReqCreateMessageDto,
Expand Down Expand Up @@ -196,14 +195,10 @@ export class MessageService {
async updateMessageLocation(
updateDto: UpdateMessageLocationDto
): Promise<boolean> {
const queryRunner = this.dataSource.createQueryRunner();
await queryRunner.connect();
await queryRunner.startTransaction('READ COMMITTED');

const { message_id, location } = updateDto;

try {
await queryRunner.manager
await this.messageRepository
.createQueryBuilder()
.update(MessageEntity)
.set({
Expand All @@ -214,13 +209,9 @@ export class MessageService {
is_deleted: new Date(`${process.env.DATE_DEFAULT}`)
})
.execute();
await queryRunner.commitTransaction();
} catch (err) {
await queryRunner.rollbackTransaction();
console.log(err.sqlMessage);
return false;
} finally {
await queryRunner.release();
}
return true;
}
Expand Down
5 changes: 2 additions & 3 deletions back/src/modules/snowball/snowball.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
NotFoundException
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { DataSource, Repository } from 'typeorm';
import { Repository } from 'typeorm';
import { SnowballEntity } from './entity/snowball.entity';
import { ReqCreateSnowballDto } from './dto/request/req-create-snowball.dto';
import { ReqUpdateSnowballDto } from './dto/request/req-update-snowball.dto';
Expand All @@ -30,8 +30,7 @@ export class SnowballService {
@InjectRepository(SnowballEntity)
private readonly snowballRepository: Repository<SnowballEntity>,
@InjectRepository(DecorationPrefixEntity)
private readonly snowballDecoRepository: Repository<DecorationPrefixEntity>,
private readonly dataSource: DataSource
private readonly snowballDecoRepository: Repository<DecorationPrefixEntity>
) {}

async createSnowball(
Expand Down
5 changes: 2 additions & 3 deletions back/src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { UserEntity } from './entity/user.entity';
import { DataSource, Repository } from 'typeorm';
import { Repository } from 'typeorm';
import { InjectRepository } from '@nestjs/typeorm';
import { ResInfoDto } from './dto/response/res-info.dto';
import { UserDto } from './dto/user.dto';
Expand All @@ -20,8 +20,7 @@ export class UserService {
constructor(
private readonly snowballService: SnowballService,
@InjectRepository(UserEntity)
private readonly userRepository: Repository<UserEntity>,
private readonly dataSource: DataSource
private readonly userRepository: Repository<UserEntity>
) {}

async getUserData(auth_id: string): Promise<userData> {
Expand Down

0 comments on commit c041327

Please sign in to comment.