feat: add response DTOs for various services across modules
- Created response DTOs for ConfigService, AppService, AuthService, CatalogsService, AccountsService, BusinessActivityComplexesService, ComplexPosesService, SalesInvoicesService, BusinessActivitiesService, ConsumerBusinessActivityGoodsService, and others. - Implemented Create, FindAll, FindOne, and Update response types for services in consumer, partners, and POS modules. - Added request DTOs for creating and updating goods in the consumer business activities module. - Introduced filtering DTO for partner licenses. - Enhanced response mapping for partner license activations.
This commit is contained in:
@@ -2,6 +2,7 @@ import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { AccountsService } from './accounts.service'
|
||||
import { CreateConsumerAccountDto, UpdateAccountDto } from './dto/account.dto'
|
||||
import type { AccountsServiceCreateResponseDto, AccountsServiceFindAllResponseDto, AccountsServiceFindOneResponseDto, AccountsServiceUpdateResponseDto } from './dto/accounts-response.dto'
|
||||
|
||||
@ApiTags('AdminConsumerAccounts')
|
||||
@Controller('admin/consumers/:consumerId/accounts')
|
||||
@@ -9,12 +10,12 @@ export class AccountsController {
|
||||
constructor(private readonly accountsService: AccountsService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(@Param('consumerId') consumerId: string) {
|
||||
async findAll(@Param('consumerId') consumerId: string): Promise<AccountsServiceFindAllResponseDto> {
|
||||
return this.accountsService.findAll(consumerId)
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async findOne(@Param('id') id: string) {
|
||||
async findOne(@Param('id') id: string): Promise<AccountsServiceFindOneResponseDto> {
|
||||
return this.accountsService.findOne(id)
|
||||
}
|
||||
|
||||
@@ -22,12 +23,12 @@ export class AccountsController {
|
||||
async create(
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Body() data: CreateConsumerAccountDto,
|
||||
) {
|
||||
): Promise<AccountsServiceCreateResponseDto> {
|
||||
return this.accountsService.create(consumerId, data)
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
async update(@Param('id') id: string, @Body() data: UpdateAccountDto) {
|
||||
async update(@Param('id') id: string, @Body() data: UpdateAccountDto): Promise<AccountsServiceUpdateResponseDto> {
|
||||
return this.accountsService.update(id, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { AccountsService } from '../accounts.service'
|
||||
|
||||
export type AccountsServiceCreateResponseDto = Awaited<ReturnType<AccountsService['create']>>
|
||||
export type AccountsServiceDeleteResponseDto = Awaited<ReturnType<AccountsService['delete']>>
|
||||
export type AccountsServiceFindAllResponseDto = Awaited<ReturnType<AccountsService['findAll']>>
|
||||
export type AccountsServiceFindOneResponseDto = Awaited<ReturnType<AccountsService['findOne']>>
|
||||
export type AccountsServiceUpdateResponseDto = Awaited<ReturnType<AccountsService['update']>>
|
||||
@@ -1,17 +1,18 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common'
|
||||
import { BusinessActivitiesService } from './business-activities.service'
|
||||
import type { BusinessActivitiesServiceFindAllResponseDto, BusinessActivitiesServiceFindOneResponseDto } from './dto/business-activities-response.dto'
|
||||
|
||||
@Controller('admin/consumers/:consumerId/business_activities')
|
||||
export class BusinessActivitiesController {
|
||||
constructor(private readonly businessActivitiesService: BusinessActivitiesService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(@Param('consumerId') consumerId: string) {
|
||||
async findAll(@Param('consumerId') consumerId: string): Promise<BusinessActivitiesServiceFindAllResponseDto> {
|
||||
return this.businessActivitiesService.findAll(consumerId)
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async findOne(@Param('consumerId') consumerId: string, @Param('id') id: string) {
|
||||
async findOne(@Param('consumerId') consumerId: string, @Param('id') id: string): Promise<BusinessActivitiesServiceFindOneResponseDto> {
|
||||
return this.businessActivitiesService.findOne(consumerId, id)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { BusinessActivityComplexesService } from './complexes.service'
|
||||
import type { BusinessActivityComplexesServiceFindAllResponseDto, BusinessActivityComplexesServiceFindOneResponseDto } from './dto/complexes-response.dto'
|
||||
|
||||
@ApiTags('AdminBusinessActivityComplexes')
|
||||
@Controller(
|
||||
@@ -13,7 +14,7 @@ export class BusinessActivityComplexesController {
|
||||
async findAll(
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
) {
|
||||
): Promise<BusinessActivityComplexesServiceFindAllResponseDto> {
|
||||
return this.service.findAll(consumerId, businessActivityId)
|
||||
}
|
||||
|
||||
@@ -22,7 +23,7 @@ export class BusinessActivityComplexesController {
|
||||
@Param('consumerId') consumerId: string,
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
): Promise<BusinessActivityComplexesServiceFindOneResponseDto> {
|
||||
return this.service.findOne(consumerId, businessActivityId, id)
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { BusinessActivityComplexesService } from '../complexes.service'
|
||||
|
||||
export type BusinessActivityComplexesServiceFindAllResponseDto = Awaited<ReturnType<BusinessActivityComplexesService['findAll']>>
|
||||
export type BusinessActivityComplexesServiceFindOneResponseDto = Awaited<ReturnType<BusinessActivityComplexesService['findOne']>>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { ComplexPosesService } from '../poses.service'
|
||||
|
||||
export type ComplexPosesServiceFindAllResponseDto = Awaited<ReturnType<ComplexPosesService['findAll']>>
|
||||
export type ComplexPosesServiceFindOneResponseDto = Awaited<ReturnType<ComplexPosesService['findOne']>>
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { ComplexPosesService } from './poses.service'
|
||||
import type { ComplexPosesServiceFindAllResponseDto, ComplexPosesServiceFindOneResponseDto } from './dto/poses-response.dto'
|
||||
|
||||
@ApiTags('AdminComplexPoses')
|
||||
@Controller('admin/business_activities/:businessActivityId/complexes/:complexId/poses')
|
||||
@@ -11,7 +12,7 @@ export class ComplexPosesController {
|
||||
async findAll(
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Param('complexId') complexId: string,
|
||||
) {
|
||||
): Promise<ComplexPosesServiceFindAllResponseDto> {
|
||||
return this.service.findAll(businessActivityId, complexId)
|
||||
}
|
||||
|
||||
@@ -20,7 +21,7 @@ export class ComplexPosesController {
|
||||
@Param('businessActivityId') businessActivityId: string,
|
||||
@Param('complexId') complexId: string,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
): Promise<ComplexPosesServiceFindOneResponseDto> {
|
||||
return this.service.findOne(businessActivityId, complexId, id)
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { BusinessActivitiesService } from '../business-activities.service'
|
||||
|
||||
export type BusinessActivitiesServiceFindAllResponseDto = Awaited<ReturnType<BusinessActivitiesService['findAll']>>
|
||||
export type BusinessActivitiesServiceFindOneResponseDto = Awaited<ReturnType<BusinessActivitiesService['findOne']>>
|
||||
@@ -1,17 +1,18 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common'
|
||||
import { AdminConsumersService } from './consumers.service'
|
||||
import type { AdminConsumersServiceFindAllResponseDto, AdminConsumersServiceFindOneResponseDto } from './dto/consumers-response.dto'
|
||||
|
||||
@Controller('admin/consumers')
|
||||
export class AdminUsersController {
|
||||
constructor(private readonly usersService: AdminConsumersService) {}
|
||||
|
||||
@Get()
|
||||
async findAll() {
|
||||
async findAll(): Promise<AdminConsumersServiceFindAllResponseDto> {
|
||||
return this.usersService.findAll()
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async findOne(@Param('id') id: string) {
|
||||
async findOne(@Param('id') id: string): Promise<AdminConsumersServiceFindOneResponseDto> {
|
||||
return this.usersService.findOne(id)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { QUERY_CONSTANTS } from '@/common/queryConstants'
|
||||
import consumer_mappersUtil from '@/common/utils/mappers/consumer_mappers.util'
|
||||
import { ConsumerSelect } from '@/generated/prisma/models'
|
||||
import mapConsumerWithLicenseUtil from '@/modules/consumer/utils/mapConsumerWithLicense.util'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
@@ -8,41 +9,41 @@ import { ResponseMapper } from 'common/response/response-mapper'
|
||||
export class AdminConsumersService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
private readonly now = new Date()
|
||||
|
||||
private readonly defaultSelect: ConsumerSelect = {
|
||||
id: true,
|
||||
first_name: true,
|
||||
last_name: true,
|
||||
mobile_number: true,
|
||||
type: true,
|
||||
...QUERY_CONSTANTS.CONSUMER.infoSelect,
|
||||
status: true,
|
||||
partner: {
|
||||
|
||||
created_at: true,
|
||||
_count: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
code: true,
|
||||
business_activities: {
|
||||
where: {
|
||||
license_activation: {
|
||||
OR: [
|
||||
{
|
||||
expires_at: {
|
||||
gt: this.now,
|
||||
},
|
||||
},
|
||||
{
|
||||
license_renews: {
|
||||
some: {
|
||||
expires_at: {
|
||||
gt: this.now,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
created_at: true,
|
||||
// activation: {
|
||||
// select: {
|
||||
// id: true,
|
||||
// starts_at: true,
|
||||
// expires_at: true,
|
||||
// license: {
|
||||
// select: {
|
||||
// charge_transaction: {
|
||||
// select: {
|
||||
// partner: {
|
||||
// select: {
|
||||
// id: true,
|
||||
// name: true,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
}
|
||||
|
||||
async findAll() {
|
||||
@@ -53,7 +54,7 @@ export class AdminConsumersService {
|
||||
this.prisma.consumer.count(),
|
||||
])
|
||||
|
||||
return ResponseMapper.paginate(consumers.map(mapConsumerWithLicenseUtil), { total })
|
||||
return ResponseMapper.paginate(consumers.map(consumer_mappersUtil), { total })
|
||||
}
|
||||
|
||||
async findOne(id: string) {
|
||||
@@ -62,7 +63,7 @@ export class AdminConsumersService {
|
||||
select: this.defaultSelect,
|
||||
})
|
||||
|
||||
return ResponseMapper.single(mapConsumerWithLicenseUtil(consumer))
|
||||
return ResponseMapper.single(consumer_mappersUtil(consumer))
|
||||
}
|
||||
|
||||
// async create(data: CreateConsumerDto) {
|
||||
@@ -72,7 +73,7 @@ export class AdminConsumersService {
|
||||
// const { username, password, partner_id, ...rest } = data
|
||||
// const dataToCreate: ConsumerCreateInput = {
|
||||
// ...rest,
|
||||
// consumer_accounts: {
|
||||
// accounts: {
|
||||
// create: {
|
||||
// role: ConsumerRole.OWNER,
|
||||
// account: {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import type { AdminConsumersService } from '../consumers.service'
|
||||
|
||||
export type AdminConsumersServiceFindAllResponseDto = Awaited<ReturnType<AdminConsumersService['findAll']>>
|
||||
export type AdminConsumersServiceFindOneResponseDto = Awaited<ReturnType<AdminConsumersService['findOne']>>
|
||||
@@ -0,0 +1,3 @@
|
||||
import type { LicensesService } from '../licenses.service'
|
||||
|
||||
export type LicensesServiceFindAllResponseDto = Awaited<ReturnType<LicensesService['findAll']>>
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
import { LicensesService } from './licenses.service'
|
||||
import type { LicensesServiceFindAllResponseDto } from './dto/licenses-response.dto'
|
||||
|
||||
@ApiTags('AdminConsumerAccounts')
|
||||
@Controller('admin/consumers/:consumerId/licenses')
|
||||
@@ -8,7 +9,7 @@ export class LicensesController {
|
||||
constructor(private readonly service: LicensesService) {}
|
||||
|
||||
@Get()
|
||||
async findAll(@Param('consumerId') consumerId: string) {
|
||||
async findAll(@Param('consumerId') consumerId: string): Promise<LicensesServiceFindAllResponseDto> {
|
||||
return this.service.findAll(consumerId)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user