-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
945da99
commit c83642a
Showing
10 changed files
with
405 additions
and
2 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
8 changes: 8 additions & 0 deletions
8
apps/e-commerce/src/report/vendor-sale/dto/get-vendor-sale.dto.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,8 @@ | ||
import { IntersectionType } from '@nestjs/swagger'; | ||
import { ListFilter } from '@rahino/query-filter'; | ||
import { VendorSaleDto } from './vendor-sale-dto'; | ||
|
||
export class GetVendorSaleDto extends IntersectionType( | ||
VendorSaleDto, | ||
ListFilter, | ||
) {} |
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 @@ | ||
export * from './get-vendor-sale.dto'; |
34 changes: 34 additions & 0 deletions
34
apps/e-commerce/src/report/vendor-sale/dto/vendor-sale-dto.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,34 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { I18nTranslations } from 'apps/main/src/generated/i18n.generated'; | ||
import { Type } from 'class-transformer'; | ||
import { IsInt, IsNumber, IsOptional, IsString } from 'class-validator'; | ||
import { i18nValidationMessage } from 'nestjs-i18n'; | ||
|
||
export class VendorSaleDto { | ||
@ApiProperty({ | ||
required: true, | ||
type: IsString, | ||
description: 'beginDate', | ||
}) | ||
@IsString() | ||
beginDate: string; | ||
|
||
@ApiProperty({ | ||
required: true, | ||
type: IsString, | ||
description: 'endDate', | ||
}) | ||
@IsString() | ||
endDate: string; | ||
|
||
@ApiProperty({ | ||
required: true, | ||
type: IsNumber, | ||
description: 'vendorId', | ||
}) | ||
@IsInt({ | ||
message: i18nValidationMessage<I18nTranslations>('validation.NUMBER'), | ||
}) | ||
@Type(() => Number) | ||
vendorId: number; | ||
} |
64 changes: 64 additions & 0 deletions
64
apps/e-commerce/src/report/vendor-sale/vendor-sale.controller.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, | ||
HttpCode, | ||
HttpStatus, | ||
Query, | ||
UseGuards, | ||
UseInterceptors, | ||
} from '@nestjs/common'; | ||
import { CheckPermission } from '@rahino/permission-checker/decorator'; | ||
import { PermissionGuard } from '@rahino/permission-checker/guard'; | ||
import { JsonResponseTransformInterceptor } from '@rahino/response/interceptor'; | ||
import { | ||
ApiBearerAuth, | ||
ApiOperation, | ||
ApiQuery, | ||
ApiTags, | ||
} from '@nestjs/swagger'; | ||
|
||
import { JwtGuard } from '@rahino/auth/guard'; | ||
import { VendorSaleService } from './vendor-sale.service'; | ||
import { GetVendorSaleDto } from './dto'; | ||
import { GetUser } from '@rahino/auth/decorator'; | ||
import { User } from '@rahino/database/models/core/user.entity'; | ||
|
||
@ApiTags('Report-VendorSales') | ||
@UseGuards(JwtGuard, PermissionGuard) | ||
@UseInterceptors(JsonResponseTransformInterceptor) | ||
@ApiBearerAuth() | ||
@Controller({ | ||
path: '/api/ecommerce/report/vendorSales', | ||
version: ['1'], | ||
}) | ||
export class VendorSaleController { | ||
constructor(private service: VendorSaleService) {} | ||
|
||
@ApiOperation({ description: 'show all vendor sales' }) | ||
@CheckPermission({ permissionSymbol: 'ecommerce.report.vendorsales.getall' }) | ||
@Get('/') | ||
@ApiQuery({ | ||
name: 'filter', | ||
type: GetVendorSaleDto, | ||
style: 'deepObject', | ||
explode: true, | ||
}) | ||
@HttpCode(HttpStatus.OK) | ||
async findAll(@GetUser() user: User, @Query() filter: GetVendorSaleDto) { | ||
return await this.service.findAll(user, filter); | ||
} | ||
|
||
@ApiOperation({ description: 'show total vendor sales' }) | ||
@CheckPermission({ permissionSymbol: 'ecommerce.report.vendorsales.getall' }) | ||
@Get('/total') | ||
@ApiQuery({ | ||
name: 'filter', | ||
type: GetVendorSaleDto, | ||
style: 'deepObject', | ||
explode: true, | ||
}) | ||
@HttpCode(HttpStatus.OK) | ||
async total(@GetUser() user: User, @Query() filter: GetVendorSaleDto) { | ||
return await this.service.total(user, filter); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
apps/e-commerce/src/report/vendor-sale/vendor-sale.module.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 { Module } from '@nestjs/common'; | ||
import { VendorSaleService } from './vendor-sale.service'; | ||
import { VendorSaleController } from './vendor-sale.controller'; | ||
import { SequelizeModule } from '@nestjs/sequelize'; | ||
import { User } from '@rahino/database/models/core/user.entity'; | ||
import { Permission } from '@rahino/database/models/core/permission.entity'; | ||
import { ECOrderDetail } from '@rahino/database/models/ecommerce-eav/ec-order-detail.entity'; | ||
import { PersianDate } from '@rahino/database/models/core/view/persiandate.entity'; | ||
import { AdminSaleQueryBuilderModule } from '../admin-sale-query-builder/admin-sale-query-builder.module'; | ||
import { UserVendorModule } from '@rahino/ecommerce/user/vendor/user-vendor.module'; | ||
|
||
@Module({ | ||
imports: [ | ||
AdminSaleQueryBuilderModule, | ||
SequelizeModule.forFeature([User, Permission, ECOrderDetail, PersianDate]), | ||
UserVendorModule, | ||
], | ||
controllers: [VendorSaleController], | ||
providers: [VendorSaleService], | ||
}) | ||
export class VendorSaleModule {} |
Oops, something went wrong.