This repository has been archived by the owner on May 11, 2021. It is now read-only.
-
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(money): add statistics controllers declaration
- Loading branch information
1 parent
d930817
commit 48d9e1e
Showing
9 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
back/src/money/presentation/http/controller/StatisticsController.ts
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,64 @@ | ||
import { Controller, Get, Query } from '@nestjs/common' | ||
import { | ||
ApiBearerAuth, | ||
ApiOkResponse, | ||
ApiOperation, | ||
ApiUseTags, | ||
} from '@nestjs/swagger' | ||
|
||
import { DateRange } from '@back/utils/infrastructure/dto/DateRange' | ||
import { ApiQueryDateRange } from '@back/utils/presentation/http/api/ApiQueryDateRange' | ||
import { ParseDateRangePipe } from '@back/utils/presentation/http/pipes/dateRange/ParseDateRangePipe' | ||
import { GroupBy } from '@shared/enum/GroupBy' | ||
|
||
import { CategoryGroupOutcomeResponse } from '../response/CategoryGroupOutcomeResponse' | ||
import { DateGroupResponse } from '../response/DateGroupResponse' | ||
import { SourceGroupIncomeResponse } from '../response/SourceGroupIncomeResponse' | ||
|
||
@Controller('money/statistics') | ||
@ApiUseTags('money') | ||
@ApiBearerAuth() | ||
export class StatisticsController { | ||
@Get('date-range') | ||
@ApiOperation({ title: 'Show date range statistics' }) | ||
@ApiOkResponse({ | ||
description: 'Fetching stats sucess', | ||
type: DateGroupResponse, | ||
isArray: true, | ||
}) | ||
@ApiQueryDateRange() | ||
public async showDateRangeStats( | ||
@Query(ParseDateRangePipe) range: DateRange, | ||
@Query('by') by: GroupBy = GroupBy.Month, | ||
): Promise<DateGroupResponse[]> { | ||
return [] | ||
} | ||
|
||
@Get('income-sources') | ||
@ApiOperation({ title: 'Show income sources' }) | ||
@ApiOkResponse({ | ||
description: 'Fetching stats sucess', | ||
type: SourceGroupIncomeResponse, | ||
isArray: true, | ||
}) | ||
@ApiQueryDateRange() | ||
public async showIncomeSourcesStats( | ||
@Query(ParseDateRangePipe) range: DateRange, | ||
): Promise<SourceGroupIncomeResponse[]> { | ||
return [] | ||
} | ||
|
||
@Get('outcome-categories') | ||
@ApiOperation({ title: 'Show outcome categories' }) | ||
@ApiOkResponse({ | ||
description: 'Fetching stats sucess', | ||
type: CategoryGroupOutcomeResponse, | ||
isArray: true, | ||
}) | ||
@ApiQueryDateRange() | ||
public async showOutcomeCategoriesStats( | ||
@Query(ParseDateRangePipe) range: DateRange, | ||
): Promise<CategoryGroupOutcomeResponse[]> { | ||
return [] | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
back/src/money/presentation/http/response/CategoryGroupOutcomeResponse.ts
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,15 @@ | ||
import { ApiModelProperty } from '@nestjs/swagger' | ||
|
||
import { Currency } from '@shared/enum/Currency' | ||
import { CategoryGroupOutcomeModel } from '@shared/models/money/CategoryGroupOutcomeModel' | ||
|
||
export class CategoryGroupOutcomeResponse implements CategoryGroupOutcomeModel { | ||
@ApiModelProperty({ example: 'NASA' }) | ||
public readonly category: string | ||
|
||
@ApiModelProperty({ example: 20000 }) | ||
public readonly outcome: number | ||
|
||
@ApiModelProperty({ example: Currency.RUB, enum: Object.values(Currency) }) | ||
public readonly currency: Currency | ||
} |
21 changes: 21 additions & 0 deletions
21
back/src/money/presentation/http/response/DateGroupResponse.ts
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,21 @@ | ||
import { ApiModelProperty } from '@nestjs/swagger' | ||
|
||
import { Currency } from '@shared/enum/Currency' | ||
import { DateGroupModel } from '@shared/models/money/DateGroupModel' | ||
|
||
export class DateGroupResponse implements DateGroupModel { | ||
@ApiModelProperty({ example: 'Jan 2019' }) | ||
public readonly start: string | ||
|
||
@ApiModelProperty({ example: 'Feb 2019' }) | ||
public readonly end: string | ||
|
||
@ApiModelProperty({ example: 12000 }) | ||
public readonly income: number | ||
|
||
@ApiModelProperty({ example: 3000 }) | ||
public readonly outcome: number | ||
|
||
@ApiModelProperty({ example: Currency.RUB, enum: Object.values(Currency) }) | ||
public readonly currency: Currency | ||
} |
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
15 changes: 15 additions & 0 deletions
15
back/src/money/presentation/http/response/SourceGroupIncomeResponse.ts
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,15 @@ | ||
import { ApiModelProperty } from '@nestjs/swagger' | ||
|
||
import { Currency } from '@shared/enum/Currency' | ||
import { SourceGroupIncomeModel } from '@shared/models/money/SourceGroupIncomeModel' | ||
|
||
export class SourceGroupIncomeResponse implements SourceGroupIncomeModel { | ||
@ApiModelProperty({ example: 'NASA' }) | ||
public readonly source: string | ||
|
||
@ApiModelProperty({ example: 20000 }) | ||
public readonly income: number | ||
|
||
@ApiModelProperty({ example: Currency.RUB, enum: Object.values(Currency) }) | ||
public readonly currency: Currency | ||
} |
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,7 @@ | ||
import { Currency } from '@shared/enum/Currency' | ||
|
||
export interface CategoryGroupOutcomeModel { | ||
readonly category: string | ||
readonly outcome: number | ||
readonly currency: Currency | ||
} |
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 @@ | ||
import { Currency } from '@shared/enum/Currency' | ||
|
||
export interface DateGroupModel { | ||
readonly start: string | ||
readonly end: string | ||
readonly income: number | ||
readonly outcome: number | ||
readonly currency: Currency | ||
} |
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,7 @@ | ||
import { Currency } from '@shared/enum/Currency' | ||
|
||
export interface SourceGroupIncomeModel { | ||
readonly source: string | ||
readonly income: number | ||
readonly currency: Currency | ||
} |