refactor: organize backend by business responsibility
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { Controller, Get, Param, Query, Req, UseGuards } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||
import type { Request } from 'express';
|
||||
import { ApiProblemResponses } from '../../../common/decorators/api-safe-error-response.decorator';
|
||||
import { AccessPayload, JwtAuthGuard } from '../../auth/auth.api';
|
||||
import {
|
||||
IncomeAnalyticsDto,
|
||||
IncomeAnalyticsQueryDto,
|
||||
IncomeSummaryDto,
|
||||
} from './income-analytics.dto';
|
||||
import { IncomeAnalyticsService } from './income-analytics.service';
|
||||
|
||||
@ApiTags('brokerage-accounts')
|
||||
@ApiProblemResponses()
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('brokerage-accounts')
|
||||
export class IncomeAnalyticsController {
|
||||
constructor(private readonly income: IncomeAnalyticsService) {}
|
||||
|
||||
@Get('all/income-summary')
|
||||
@ApiOkResponse({ type: IncomeSummaryDto })
|
||||
allSummary(@Req() request: Request & { user: AccessPayload }) {
|
||||
return this.income.summary(request.user.sub, 'all');
|
||||
}
|
||||
|
||||
@Get('all/income-analytics')
|
||||
@ApiOkResponse({ type: IncomeAnalyticsDto })
|
||||
allAnalytics(
|
||||
@Req() request: Request & { user: AccessPayload },
|
||||
@Query() query: IncomeAnalyticsQueryDto,
|
||||
) {
|
||||
return this.income.analytics(request.user.sub, 'all', query.from, query.to);
|
||||
}
|
||||
|
||||
@Get(':accountId/income-summary')
|
||||
@ApiOkResponse({ type: IncomeSummaryDto })
|
||||
summary(
|
||||
@Req() request: Request & { user: AccessPayload },
|
||||
@Param('accountId') accountId: string,
|
||||
) {
|
||||
return this.income.summary(request.user.sub, accountId);
|
||||
}
|
||||
|
||||
@Get(':accountId/income-analytics')
|
||||
@ApiOkResponse({ type: IncomeAnalyticsDto })
|
||||
analytics(
|
||||
@Req() request: Request & { user: AccessPayload },
|
||||
@Param('accountId') accountId: string,
|
||||
@Query() query: IncomeAnalyticsQueryDto,
|
||||
) {
|
||||
return this.income.analytics(
|
||||
request.user.sub,
|
||||
accountId,
|
||||
query.from,
|
||||
query.to,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user