-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: transaction module * feat: find transactions by period * fix: npm test * fix: transaction.interface.ts * refactor: change function name * refactor: change dto and func name * fix: memberExcel > memberFile --------- Co-authored-by: 박근형 <[email protected]>
- Loading branch information
Showing
15 changed files
with
331 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsNotEmpty, IsNumber, IsString } from 'class-validator'; | ||
|
||
class Metadata { | ||
@IsString() | ||
@ApiProperty({ description: '모임 ID', example: '64125455d454s' }) | ||
groupId: string; | ||
|
||
@IsString() | ||
@ApiProperty({ description: '거래 유형', example: '입금' }) | ||
transactionType: string; | ||
|
||
@IsNumber() | ||
@ApiProperty({ description: '거래 금액', example: 25000 }) | ||
amount: number; | ||
|
||
@IsString() | ||
@ApiProperty({ description: '내용', example: '이소현' }) | ||
name: string; | ||
} | ||
|
||
export class CreateTransactionDto { | ||
@IsNotEmpty() | ||
@IsString() | ||
@ApiProperty({ | ||
description: '거래 내역의 메타데이터', | ||
example: { | ||
groupId: '64125455d454s', | ||
transactionType: '입금', | ||
amount: 25000, | ||
}, | ||
}) | ||
readonly metadata: Metadata; | ||
|
||
@ApiProperty({ | ||
description: '거래 일시', | ||
example: new Date(), | ||
}) | ||
readonly timestamp: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Transform } from 'class-transformer'; | ||
import { IsDate, IsNotEmpty } from 'class-validator'; | ||
|
||
export class GetTransactionsPeriodDto { | ||
@IsNotEmpty() | ||
@IsDate() | ||
@Transform(({ value }) => new Date(value)) | ||
@ApiProperty({ | ||
description: '2023-06-25T15:09:34.778Z', | ||
example: new Date(), | ||
}) | ||
readonly startDate: Date; | ||
|
||
@IsNotEmpty() | ||
@IsDate() | ||
@Transform(({ value }) => new Date(value)) | ||
@ApiProperty({ | ||
description: '2023-08-25T15:09:34.778Z', | ||
example: new Date(), | ||
}) | ||
readonly endDate: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class Transaction { | ||
metadata: { | ||
groupId: string; | ||
transactionType: string; | ||
amount: number; | ||
name: string; | ||
}; | ||
timestamp: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface TransactionInterface extends Document { | ||
metadata: { | ||
groupId: string; | ||
transactionType: string; | ||
amount: number; | ||
name: string; | ||
}; | ||
timestamp: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Schema } from 'mongoose'; | ||
|
||
export const TransactionSchema = new Schema({ | ||
metadata: { | ||
groupId: String, | ||
transactionType: String, | ||
amount: Number, | ||
name: String, | ||
}, | ||
timestamp: Date, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { applyDecorators } from '@nestjs/common'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
|
||
export function Transaction() { | ||
return applyDecorators(ApiTags('Transaction')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
import { DatabaseModule } from '../database/database.module'; | ||
import { ExcelService } from '../excel/excel.service'; | ||
import { transactionProviders } from './transaction.providers'; | ||
import { TransactionRepository } from './transaction.repository'; | ||
import { TransactionService } from './transaction.service'; | ||
|
||
@Module({ | ||
imports: [DatabaseModule], | ||
providers: [ | ||
TransactionService, | ||
...transactionProviders, | ||
TransactionRepository, | ||
ExcelService, | ||
], | ||
exports: [TransactionService], | ||
}) | ||
export class TransactionModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Connection } from 'mongoose'; | ||
|
||
import { TransactionSchema } from './schemas/transaction.schema'; | ||
|
||
export const transactionProviders = [ | ||
{ | ||
provide: 'TRANSACTION_MODEL', | ||
useFactory: (connection: Connection) => | ||
connection.model('Transaction', TransactionSchema), | ||
inject: ['MONGODB_CONNECTION'], | ||
}, | ||
]; |
Oops, something went wrong.